my dog learned polymorphism*
The moose likes Servlets and the fly likes Error handling in JSp's Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Error handling in JSp Watch "Error handling in JSp New topic
Author

Error handling in JSp's

Mahesh Eshwarappa
Greenhorn

Joined: Jan 04, 2001
Posts: 28

Hi all,
How can we throw an exception from an erroneous JSP to error page.
Am using the page directive <%@ page errorPage="errorpage.jsp" %>
in each page.
But I don't know how to throw an exception in case any exception is raised.
For ex:
<%
String s[] = getNamesFromList();
%>
Say this raises an exception then how do i catch the same and throw it .
Your suggestions are welcome.
Regards,
Mahesh

Asuthosh Borikar
Ranch Hand

Joined: Sep 29, 2000
Posts: 75
From whatever minimal knowledge I have about JSPs, I will try to answer this. You don't need to catch and throw the exceptions from your first page. If and when an exception occurs, it is automagically passed to the error page and you can do whatever you want with the exception(ex:do a printStackTrace()) in the error page. Hope this Helps!
Mahesh Eshwarappa
Greenhorn

Joined: Jan 04, 2001
Posts: 28

Thanks for u r reply.
I was so dumb trying to figure out how to throw exception.
Mahesh
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Error handling in JSp's
 
Similar Threads
exception Tag in web.xml
configuring error pages in DD
error pages
error-page element in web.xml
response.sendError & error-page