Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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

 
Ranch Hand
Posts: 83
  • 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






 
Bartender
Posts: 3648
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
Ranch Hand
Posts: 83
  • 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: 3648
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!