两种方式

 

<c:set var="s1" value="This is One" scope="request" />

out.print(request.getAttribute("s1") ;

<c:set var="s2" value="This is Two"/>

out.print(pageContext.getAttribute("s2"));

 

----------------------------------------------------

JSTL 变量由 JSP 读取

 

<c:set var="JspValue1" value="Java Language One" scope="request" /> 

<c:set var="JspValue2" value="Java Language Two"/>

<%

String JspValue3 = request.getAttribute("JspValue1").toString();

String JspValue4 = pageContext.getAttribute("JspValue2").toString();

          

out.print(JspValue3);

out.print(JspValue4);

%>

 

----------------------------------------------------

 

JSP 变量由 JSTL 读取

String strContextPath = request.getContextPath();

 pageContext.setAttribute("ContextPath", strContextPath);

..

<c:out value="${ContextPath}"></out>