1.可以使用:
| response.sendRedirect("http://www.foo.com/path/error.html"); |
2.可以手工修改HTTP header的Location属性,如下:
<%
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
String newLocn = "/newpath/index.html";
response.setHeader("Location",newLocn);
%> |
3.也可以使用forward:
| <jsp:forward page="/newpage.jsp" /> |
请注意:只能在任何输出还没有发送到客户端之前使用这种方式。
5.6 类似global.asa的做法
在JavaScript/" target="_blank">JSP中没有global.asa的对应物。但可以有一个workaround来运行。例如,如果你需要存储或存取application scope变量,你总是可以创建一个Javabean,并在页面中需要这些变量的地方将它包含进来。
| <jsp:useBean id="globals" scope="application" class="com.xxx.GlobalBean"/> |
本文章更多内容:1 - 2 - 3 - 4 - 下一页>> |