tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ion Larranaga <ila...@s21sec.com>
Subject RE: How to add a throw exception to a servlet
Date Fri, 03 May 2002 10:26:52 GMT
Hi,

There's no way to add new exception types to the doPost method. However,
you could do something like:

public void doPost(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException
{
	try
	{
		/*
		your code
		*/
	}
	catch (SQLException exc)
	{
		throw new ServletException(exc);
	}
}

This way, the real exception goes nested within a ServletException and you
don't have to change the method signature.

Hope it helps,

   Ion



>But I want the exception to be caught in the error.jsp page, not do a try
>{...} catch{...} inside the doPost body.
>
>I don't know if I explained it correctly but is there a simple solution to
>this problem ?


--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message