This week's book giveaway is in the Web Services forum.
We're giving away four copies of Microservices in Action and have Morgan Bruce & Paulo A. Pereira on-line!
See this thread for details.
Win a copy of Microservices in Action this week in the Web Services forum!
  • 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:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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

 
Ranch Hand
Posts: 86
  • 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: 86
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!