| Author |
Problem with forwarding page towards error page
|
Harshal Gurav
Ranch Hand
Joined: May 29, 2008
Posts: 150
|
|
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.
|
 |
Amit Ghorpade
Bartender
Joined: Jun 06, 2007
Posts: 2562
|
|
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?
|
SCJP, SCWCD.
|Asking Good Questions|
|
 |
Harshal Gurav
Ranch Hand
Joined: May 29, 2008
Posts: 150
|
|
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
Joined: May 29, 2008
Posts: 150
|
|
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
Joined: May 29, 2008
Posts: 150
|
|
Hi, can any one help here? Thanks and Regards Harshal
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
|
whether you configure <error-page> in web.xml?
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
sorry!No need to configure in web.xml..try this simple example index.jsp error.jsp Hope This Helps
|
 |
Harshal Gurav
Ranch Hand
Joined: May 29, 2008
Posts: 150
|
|
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
Joined: Jan 28, 2008
Posts: 5575
|
|
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
Joined: May 29, 2008
Posts: 150
|
|
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
Joined: Jan 28, 2008
Posts: 5575
|
|
try in mozilla.. in IE it is not working some time...i do not know why
|
 |
Harshal Gurav
Ranch Hand
Joined: May 29, 2008
Posts: 150
|
|
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
Joined: Jan 28, 2008
Posts: 5575
|
|
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
|
 |
Steve Luke
Bartender
Joined: Jan 28, 2003
Posts: 3091
|
|
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).
|
Steve
|
 |
 |
|
|
subject: Problem with forwarding page towards error page
|
|
|