在JSP中 声明表达式<%! int a = 3 ; %> 中 定义的是全局变量。
在jsp脚本段中 <% int b = 3; %> 声明的变量是局部变量。
servlet是单例的。所以通过声明表达式定义的变量只有一份,会被用户客户端共享到。
******************
在使用jsp的<%@ include file="*.jsp" %> 的这条包含其他页面的语句时;
不能在被包含页面中含有 :
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
这个Java的脚本段。否则会失败。
*********************************
<jsp:forward > 用于页面的转向,该语句后的语句都不会执行。
***********************************
<jsp:include > 在包含的时候还可以向被包含页面传递参数。而<%@ include file="" %> 这个东西是做不到的。
*********************************************************************************************************
request.getParameter() 方法和 request.getAttrbute()方法是不一样的。getParameter()方法的数据是从客户端拿来的,而
getAttribute()的数据是在服务器端内部自己设置的。setAttribute()方法一般和getAttribute()方法成对出现。
在jsp脚本段中 <% int b = 3; %> 声明的变量是局部变量。
servlet是单例的。所以通过声明表达式定义的变量只有一份,会被用户客户端共享到。
******************
在使用jsp的<%@ include file="*.jsp" %> 的这条包含其他页面的语句时;
不能在被包含页面中含有 :
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
这个Java的脚本段。否则会失败。
*********************************
<jsp:forward > 用于页面的转向,该语句后的语句都不会执行。
***********************************
<jsp:include > 在包含的时候还可以向被包含页面传递参数。而<%@ include file="" %> 这个东西是做不到的。
*********************************************************************************************************
request.getParameter() 方法和 request.getAttrbute()方法是不一样的。getParameter()方法的数据是从客户端拿来的,而
getAttribute()的数据是在服务器端内部自己设置的。setAttribute()方法一般和getAttribute()方法成对出现。