易截截图软件、单文件、免安装、纯绿色、仅160KB

JSP中errorPage的问题

           当在JSP的page指令中设置errorPage="url"就可以设置处理异常事件的JSP文件。如可以这样写:
                <%@ page errorPage="error.jsp" %>
           这样的话,当页面中出现异常的时候,就会自动跳转到错误处理页面。但是要注意,
           只有当正常打开页面,然后在页面中出现异常的时候才会跳转到错误处理页面,如果页面本身有语法错误而出现了编译错误,是不会跳转的!
           例:index.jsp
<%@ page contentType="text/html; charset=GB2312" language="java" errorPage="error.jsp"%>
<html><head><title>lifecycle</title></head><body>
<%!
private int initVar = 0;
private int serviceVar = 0;
private int destroyVar = 0;
public void jspInit() { initVar ++; }
public void jspDestroy() { destroyVar ++; }
%>
<%
serviceVar ++;
String content1="初始化次数:" + initVar;
String content2="响应客户请求次数:" + serviceVar;
String content3="销毁次数:" + destroyVar;
out.println("<h1>hahaha</h1>");
               if(serviceVar==5){
                    String info = getServletInfo();
                    throw new Exception("Exception in:" + info);
               }
%>
<h1><%=content1%></h1><h1><%=content2%></h1><h1><%=content3%></h1>
<!--this is some funny words.-->
</body></html>
下面的是error.jsp
<%@ page contentType="text/html; charset=GB2312" language="java" isErrorPage="true"%>
<html><head><title>error</title></head><body>
this is the error page.
</body></html>


相关文档:

jsp中的include静态页面出现乱码问题

在当前应用系统的web.xml里加入jsp-config代码:
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<jsp-config>
< ......

JSP中页面自动定时刷新


1.JSP中页面定时刷新
Java
代码 < type="application/x-shockwave-flash" width="14" height="15" src="http://penghuaiyi.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" src="http://penghuaiyi.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=%3C%25%0A%20%20 ......

JSP中输出CSV文件

<%@page import="com.opensymphony.xwork2.util.ValueStack"%><%
    ValueStack vs = (ValueStack)request.getAttribute("struts.valueStack");  
    String aa = (String)vs.findValue("downloadContent");
    response. ......

JSP页面传值中文乱码的简单解决方法

源代码,a.jsp往b.jsp传值:
a.jsp页面内容
<%@ page language="java" import="java.util.*" pageEncoding="GB2312"%>
<form action="b.jsp">
  name:<input type=text name=name>
  <input type=submit>
</form>
b.jsp页面内容:
<%@ page language="java" import="java.ut ......

jsp和Action中Base64编码转换

jsp中用javascript将中文Base64转码, Action中再用Base64解码
javascript中使用webtoolkit.base64.js,下载地址http://www.webtoolkit.info/djs/webtoolkit.base64.js
相关介绍 http://www.webtoolkit.info/javascript-base64.html
/**
*
*  Base64 encode / decode
*  http://www.webtoolkit.info/
*
**/ ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号