wood burning stoves 2.0*
The moose likes JSP and the fly likes JasperException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JasperException" Watch "JasperException" New topic
Author

JasperException

Sangeetha Rao
Ranch Hand

Joined: Aug 01, 2005
Posts: 33
JasperException is being thrown on the line below:

getServletContext().getRequestDispatcher("/confirm.jsp").forward(req, res);

The same is the case with all the servlets that have this line. But all these servlets were not throwing this exception before. No new installations were done. 'confirm.jsp' is present in the same webapplication. Had faced this problem before but it got resolved on its own after numberous Tomcat restarts. But it is not getting resolved now. Please help me solve this:

org.apache.jasper.JasperException
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:370)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
at addProject.doPost(addProject.java:103)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:407)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:534)
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8904

Is confirm.jsp working fine ?. Try calling it directly to make sure that there are no errors in confirm.jsp.


Groovy
Sangeetha Rao
Ranch Hand

Joined: Aug 01, 2005
Posts: 33
Yes, confirm.jsp is working fine. I tried calling it directly and there is no problem. Also, few of the pages are getting redirected to confirm.jsp page without any problem.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Is that the full stack trace?
There is no "Root Cause" section with the details from Jasper?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Sangeetha Rao
Ranch Hand

Joined: Aug 01, 2005
Posts: 33
That stacktrace is what I got though exception.printStackTrace();. exception.getCause() returned null.
Sangeetha Rao
Ranch Hand

Joined: Aug 01, 2005
Posts: 33
I removed the catch for Exception from my servlet and that excetion was thrown to the JSP and inturn got displayed on the browser with the root cause. The root cause was a NullpointerException which I was able to fix.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60783
    
  65

Perhaps that will teach you about when you should and should not be catching exceptions?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sangeetha Rao
Ranch Hand

Joined: Aug 01, 2005
Posts: 33
Does it mean that I should not have a catch block for the Exception class in my servlet so that the Exception propages to the JSP from which servlet was called and then let the JSP take the onus of informing the user about the Exception rather than the servlet logging the Exception itself. Is this one of the best practices? Please confirm if my understanding is correct.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60783
    
  65

You should not generally catch exceptions anywhere in a servlet or a JSP -- especially exceptions such as NPEs.

Rather, let the exception propogate outward and let the container handle it with an error-handling servlet that you declare in the deployment descriptor.

This not only keeps error-handling goop off your pages and out of your servlets, it provides for a centralized place where errors can be handled in a consistent (and complete) manner.

Sometimes you may need to catch exceptions in order to wrap them in a ServletException in order to allow them to propogate. But even in these cases, the ServletException propogates out to the container.
[ January 17, 2007: Message edited by: Bear Bibeault ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JasperException
 
Similar Threads
JasperException
getting JasperException
JasperException
NullPointerException
JasperException