EL表达式中对pageContext隐含对象的调用

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'PageContext.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
       <table border="1" align="center" >
           <tr>
               <td>PageContext隐含对象的调用</td>
               <td>说明</td>
               <td>调用结果</td>
           </tr>
           <tr>
               <td>\${pageContext.request.queryString }</td>
               <td>获取参数</td>
               <td>${pageContext.request.queryString }</td>
           </tr>
           <tr>
               <td>\${pageContext.request.requestURL }</td>
               <td>获取当前页面的地址,但是包含请求的参数</td>
               <td>${pageContext.request.requestURL }</td>
           </tr>
           <tr>
               <td>\${pageContext.request.contextPath }</td>
               <td>web的应用名称</td>
               <td>${pageContext.request.contextPath }</td>
           </tr>
           <tr>
               <td>\${pageContext.request.method }</td>
               <td>获取http的方法(get或post)</td>
               <td>${pageContext.request.method }</td>
           </tr>
           <tr>
               <td>\${pageContext.request.remoteAddr }</td>
               <td>获取用户的IP地址</td>
               <td>${pageContext.request.remoteAddr }</td>
           </tr>
           <tr>
               <td>\${pageContext.session.id }</td>
               <td>获取session的id属性值</td>
               <td>${pageContext.session.id }</td>
           </tr>
           
       </table>
  </body>
</html>

 

你可能感兴趣的:(context)