aspose file tools
The moose likes Servlets and the fly likes error page mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "error page mapping" Watch "error page mapping" New topic
Author

error page mapping

Rajeev roushan sharma
Ranch Hand

Joined: Jan 28, 2010
Posts: 50
Hi ALL, I have mapped error page in DD.

And I am setting error from servlet like .
errorpage.jsp:

Getting below ERROR in console:
SEVERE: Exception Processing ErrorPage[errorCode=404, location=/views/erorpage.jsp]
org.apache.jasper.JasperException: java.lang.NullPointerException
at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:438)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:424)
at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:343)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:144)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at org.apache.jsp.views.erorpage_jsp._jspService(erorpage_jsp.java:60)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)

I am not able to understand why NulllPointer exception is coming. Please let me know how can we pring error msg in jsp.
Your help will be highly appreciated...

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56201
    
  13

You need to check exception for null. In the case of a 404, for example, there is no exception.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Jessid Leon Velez Gutierrez
Ranch Hand

Joined: Jan 19, 2011
Posts: 35
Bear Bibeault wrote:You need to check exception for null. In the case of a 404, for example, there is no exception.


Hello Bear... I know i am not who started this thread, but I am interested in this question. Could you please explain a little more your answer. I understand that Rajeev has set an error code of 404 and it is exactly that one that is sending as an error...so what is this about null? thanks a lot!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56201
    
  13

There are a number of errors with this code:

  • Firstly, using scriptlets in a JSP is a poor practice that should have been eradicated years ago. Bad idea.


  • Secondly, the code assues that the variable exception is not null. This is an invalid assumption. Hence, when it is null, a null pointer exception is raised.



  • Jessid Leon Velez Gutierrez
    Ranch Hand

    Joined: Jan 19, 2011
    Posts: 35
    Bear Bibeault wrote:There are a number of errors with this code:

  • Firstly, using scriptlets in a JSP is a poor practice that should have been eradicated years ago. Bad idea.


  • Secondly, the code assues that the variable exception is not null. This is an invalid assumption. Hence, when it is null, a null pointer exception is raised.





  • I get it now. Thanks a lot!
    Rajeev roushan sharma
    Ranch Hand

    Joined: Jan 28, 2010
    Posts: 50
    Bear Bibeault wrote:There are a number of errors with this code:

  • Firstly, using scriptlets in a JSP is a poor practice that should have been eradicated years ago. Bad idea.


  • Secondly, the code assues that the variable exception is not null. This is an invalid assumption. Hence, when it is null, a null pointer exception is raised.





  • Thanks a lot Bear but the it is only test code not for production.
    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 56201
        
      13

    Matters not. Practice good habits at all times and it becomes second nature.
     
    I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
     
    subject: error page mapping
     
    Similar Threads
    tomcat cannot display jsp struts
    javax.servlet.jsp.JspException in Application
    java.lang.ClassNotFoundException: javax.servlet.jsp.SkipPageException getting when i run the jsp fil
    tomcat6 and eclipse - NullPointer Exception in _jspInit-method
    how to analyse log file in tomcat