• Post Reply Bookmark Topic Watch Topic
  • New Topic

Response not redirecting to errorPage.jsp which is declared in web.xml  RSS feed

 
murali jackson
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am trying to understand the redirection to errorpages set in web.xml.
I have written a sample program where i intentionally throw exception to see if my error page is displayed or not.
Its not getting displayed instead i get a standard page not found error.
Please advise .

My XML, Directory Structure and Servlet Code is below






Directory Structure

Select --- project Name
|
|
WebContent
|
|
errorPage.jsp






 
K. Tsang
Bartender
Posts: 3639
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your result.jsp page have the errorPage attribute defined?



And where are you explicitly throwing exception in your program? in the servlet?
 
murali jackson
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K. Tsang wrote:Does your result.jsp page have the errorPage attribute defined?



And where are you explicitly throwing exception in your program? in the servlet?


Hi Sang,

Yes, im throwing exception inside my servlet  by using the  below statement.


There is no such file name in the path, so i get an error in the console stating no file found IO exception which is expected.
But I am expecting the server will show the error.jsp page as per the below declaration in web.xml.
But somehow thats not happening, please advise.

 
 
K. Tsang
Bartender
Posts: 3639
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try changing the web.xml to IOException and see that works.

Honestly I can't remember if you need to specify each exception type to work.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!