• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

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

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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






 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Why fit in when you were born to stand out? - Seuss. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic