aspose file tools*
The moose likes JSP and the fly likes Configurting all errors to single page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Configurting all errors to single page" Watch "Configurting all errors to single page" New topic
Author

Configurting all errors to single page

vipul bondugula
Ranch Hand

Joined: Oct 14, 2010
Posts: 218
Hi All,

In web.xml i have configured 404 and 500 errors to single page./error.jsp.code looks like
<error-page>
<error-code>404</error-code>
<location>/pageNotFound.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/pageNotFound.jsp</location>
</error-page>

How to identify error codes in error.jsp and customize my messages...
Thanks in Advance...


Thanks
Vipul Kumar
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61434
    
  67

If you are going to perform any processing on the error, you should be sending the error to a servlet, not a JSP.

All of the error information is available as scoped variables placed in the request. The Servlet Specification has all the details on the names of these variable.

Once you are ready to present information to the user, the servlet can forward to a JSP to present the view.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
vipul bondugula
Ranch Hand

Joined: Oct 14, 2010
Posts: 218
Thanks for your reply

I have read the servlet specification.I tried the 5 variables in my JSP page.only request.getAttribute("javax.servlet.error.error_code") is working.Remaining 4 variables request_uri,message,exception_type,exception are not working.

A blank page is shown when i use the variables. I am pasting my jsp page..Please check the code and tell me where iam doing mistake.



Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61434
    
  67

I did not say to do this in a JSP. I explicitly said to do this in a servlet.
vipul bondugula
Ranch Hand

Joined: Oct 14, 2010
Posts: 218
Thanks For Your Reply,

I am using struts framework. Is it proper standard to write servlets for maintaining error pages in struts web application.

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61434
    
  67

It is proper in any web application.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Configurting all errors to single page