• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with forwarding page towards error page

 
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am trying to forward page when an exception occured in current page. Now I am trying to handle the exception for duplicate entry in database .
But it not forward to the error page.
Here is page where i may get an duplicate entry exception:

and here is an error page:


It does not show me any exception.
Ant suggestion?
thanks in advance?
Regards
Harshal.
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you getting the exception object in the error page even though the isErrorPage property is not set to true?

And what about the messages in the catch, do they show up if uncommented?
 
Harshal Gurav
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry amit,
I had not posted full page of my error.jsp.
I had already set the iserror property true.
here is full page:


Thanks and Regards
Harshal
[ August 05, 2008: Message edited by: Harshal Gurav ]
 
Harshal Gurav
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sagar,

And what about the messages in the catch, do they show up if uncommented?


I do not want to show these message if exception is cought. just want to forward it to error.jsp page and show message displayed in error.jsp page

Thanks and Regards
Harshal
[ August 06, 2008: Message edited by: Harshal Gurav ]
 
Harshal Gurav
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
can any one help here?

Thanks and Regards
Harshal
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
whether you configure <error-page> in web.xml?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry!No need to configure in web.xml..try this simple example
index.jsp


error.jsp


Hope This Helps
 
Harshal Gurav
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi seetharaman ,
Thanks for your suggestion. I was not added error.jsp into web.xml but now added it.
But there is no change in OUTPUT. The jsp page direct to next page without showing error message OF ERROR PAGE.


I am using netbeans IDE.
Thanks and reagards
Harshal
[ August 06, 2008: Message edited by: Harshal Gurav ]
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
see my above post. and also important notes...

if you want that when exception happen your page has to forward to error page,then do not put try and catch


remove your try and catch block from your jsp

then it will run definitly

Hope This Helps
 
Harshal Gurav
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi seetharaman ,
you suggest code couses HTTP 500 Internal server error:



Here is an code

Where i doing wrong? please suggest.
Thanks and Regards
Harshal
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try in mozilla.. in IE it is not working some time...i do not know why
 
Harshal Gurav
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thank you. its working on mozilla. Is there any alternative to handle the exception particularly sql exception? becouse Not all user may using mozilla.
Any suggestion?
regards
Harshal
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi

use web.xml for configure in your error page.



remove errorPage and isErrorPage from your Page directory. if any jsp throw sqlexception it redirect to error.jsp

Hope This Helps
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or, stop putting code that can cause exceptions in your JSP which should be for display.

Put the SQL in a Servlet (or better a data access object accessed in a Servlet). The Servlet checks for the SQL error and forwards to the proper page in normal conditions or the error page in exception conditions.

The error page is a complex work-around for applications that don't follow a good MVC architecture. If you move the control to a Servlet the problem disappears (as do many other related problems).
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic