aspose file tools*
The moose likes Servlets and the fly likes error page mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
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: 61648
    
  67

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by 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: 61648
    
  67

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: 61648
        
      67

    Matters not. Practice good habits at all times and it becomes second nature.
     
    It is sorta covered in the JavaRanch Style Guide.
     
    subject: error page mapping