Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

declarative exception handling in struts

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<web-app version="2.4"
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" >
...
<web-app>



struts-config : (only one global exception)
....
<global-exceptions >
<exception
path="/WEB-INF/jsp/exception.jsp"
scope="request"
type="BaseException" />
</global-exceptions >
....


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)

no

Could anybody please help ?

thank you very much.

jean217@caramail.com
 
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I feel there is some problem in ur exception.jsp r config.xml as some where syntax is the problem so its not even able to compile .............if u can paste the code in exception.jsp it will help us if not that have a close look at the xml wrote

and one more thing have u placed the BaseException class directly under web-inf classes
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"community man",

Your display name doesn't comply with our naming policy so I'll have to ask you to edit it.

Thanks.
 
John Smith
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Here is my exception.jsp :

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

<h3>In error.jsp</h3>

<%
out.println("<p><b>All Attributes in request scope:</b>");

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

out.println("<p><b>All Attributes in session scope:</b>");

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

//Object o = request.getAttribute("MYEXCEPTION");
Object o = request.getAttribute(Globals.EXCEPTION_KEY);
if (o != null) {
Throwable t = (Throwable)o;
out.println("<h3>An Exception was thrown:</h3>" + t);

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

%>
thank you for your help.
 
John Smith
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I should tell you that even with an empty exception.jsp, i've the error.

Thank you for your help.
 
Oh. Hi guys! Look at this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!