declarative exception handling in struts
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   communityman_communityman
Posted On:   Thursday, August 26, 2004 06:52 AM

Hello, I've been facing troubleshooting with declarative exception handling in struts (tomcat 5.0, struts 1.1). It does not work with : web.xml : (no error page declaration) <?xml version="1.0" encoding="ISO-8859-1"?> 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" > ... struts-config : (only one global exception) .... path="/WEB-INF/jsp/exception.jsp" scope="request" type="Bas   More>>

Hello,

I've been facing troubleshooting with declarative exception handling in struts (tomcat 5.0, struts 1.1).

It does not work with :

web.xml : (no error page declaration)
<?xml version="1.0" encoding="ISO-8859-1"?>



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" >
...




struts-config : (only one global exception)
....


path="/WEB-INF/jsp/exception.jsp"
scope="request"
type="BaseException" />

....


action:
protected ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {

int i = 0;
if(i == 0) {
throw(new BaseException());
}
...
}

result :

org.apache.jasper.JasperException: Impossible de compiler la classe pour la JSP
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:519)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:274)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)



java.lang.ArrayIndexOutOfBoundsException: 567
org.apache.jasper.compiler.JspReader.peekChar(JspReader.java:156)
org.apache.jasper.compiler.JspReader.isSpace(JspReader.java:349)
org.apache.jasper.compiler.JspReader.isDelimiter(JspReader.java:432)
org.apache.jasper.compiler.JspReader.parseToken(JspReader.java:397)
org.apache.jasper.compiler.Parser.checkUnbalancedEndTag(Parser.java:1699)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1561)
org.apache.jasper.compiler.Parser.parse(Parser.java:126)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:220)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:203)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:461)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:442)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:430)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:274)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)

Here is my exception.jsp :

<%@ page import="java.util.Enumeration,
org.apache.struts.Globals,
java.io.StringWriter,
java.io.PrintWriter"%>

In error.jsp



<%
out.println("

All Attributes in request scope: ");

Enumeration paramNames = request.getAttributeNames();
while (paramNames.hasMoreElements()) {
String name = (String) paramNames.nextElement();
Object values = request.getAttribute(name);
out.println("
" + name + ":" + values);
}

out.println("

All Attributes in session scope: ");

paramNames = session.getAttributeNames();
while (paramNames.hasMoreElements()) {
String name = (String) paramNames.nextElement();
Object values = session.getAttribute(name);
out.println("
" + name + ":" + values);
}

//Object o = request.getAttribute("MYEXCEPTION");
Object o = request.getAttribute(Globals.EXCEPTION_KEY);
if (o != null) {
Throwable t = (Throwable)o;
out.println("

An Exception was thrown:

" + t);

StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
t.printStackTrace(pw);
pw.flush();
String trace = sw.toString();
out.println("
"+trace+"
");
}

%>



Could anybody please help ?

thank you very much.


faithfully

jean217@caramail.com    <<Less
About | Sitemap | Contact