Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Configurting all errors to single page

 
vipul bondugula
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
vipul bondugula
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did not say to do this in a JSP. I explicitly said to do this in a servlet.
 
vipul bondugula
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is proper in any web application.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic