Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

error-page doubt  RSS feed

 
bernard savary
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
Can we specify a servlet to handle error in error-page ...

<error-page>
<exception-type>java.lang.Exception</error-page>
<location>(can we have a servlet name or URL mapping here)</location>
</error-page>
 
Tomaszz Lewandowski
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlet spec says:
The location element contains the location of the resource in the web application relative to the root of the web application. The value of the location must have a leading '/'.

Yes, you can specify location that maps to servlet.
 
bernard savary
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tomaszz . just one more question , ca we have 2 error-page element one specifying an error-code and one with exception-type ? .
I mean not under same error-page element in but 2 different error-page elemens in web.xml.
 
Tomaszz Lewandowski
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!