Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Exit a servlet on error


  • From: tony.pelton@xxxxxxxxx (Tony Pelton)
  • Subject: Exit a servlet on error
  • Date: Wed, 29 Nov 2000 14:33:28 -0800


My $0.02 worth ...

If you are going to effectively implement an exception handling
infrastructure to begin with ... which is a great thing to do ... and should
be done ... I would question making your base exception unchecked.

It might make life easier for people implementing in your framework ... but
it does not force them to *think* about why an exception might be thrown ...
and how it might affect them if it does.

Tony

> -----Original Message-----
> From: Tom Janofsky [mailto:twj175@xxxxxxxxxxxx]
> Sent: Wednesday, November 29, 2000 1:08 PM
> To: Scott Smith
> Cc: advanced-java@xxxxxxxxxxxxxxxx
> Subject: Re: Exit a servlet on error
> 
> 
> 
> A pattern I've used successfully for this in the past is like this:
> 
> MyServletException -> extends RuntimeException
> 
> MyBaseServelt -> extends Servlet
> 	override service() like:
> 		try{
> 		      doClientService()
>                 } catch (MyServletException) {
>                       response.sendRedirect("errorpage.html");
>                 }
> 
> 	abstract doClientService
> 
> MyServlet -> extends MyBaseServlet, and implements doClientService
> 
> All of you servlets now have to implement the doClientService method,
> and at any point can throw a MyServletException that will 
> propogate all
> the way up to the parent class service call, so methods between don't
> need it on their signature.
> 
> Also let's you pre-pend, post-pend on pages, and check security
> authoriztion type stuff all in one place.
> 
> --tom
> 
> Scott Smith wrote:
> > 
> > I don't think there is a "Silver Bullet" answer to your 
> question.  To
> > achieve the results you desire you will have to structure 
> the code in your
> > Servlet (using the normal, basic constructs) so that your 
> error checking is
> > done appropriately to match your algorithm.  It's all in 
> how you write the
> > code and implement your algorithm.
> > 
> > This may sound like a vague answer but I believe it to be 
> true and it is
> > much more polite than other possible answers!
> > 
> > Hope this helps.  Let me know if I can help more.
> > 
> > >From: "Kwan Hon Luen" <mailing_list_sg@xxxxxxxxx>
> > >To: <advanced-java@xxxxxxxxxxxxxxxx>
> > >Subject: Exit a servlet on error
> > >Date: Wed, 29 Nov 2000 16:47:30 +0800
> > >
> > >Hi ,
> > >         Is there a way to exit output a message from a 
> servlet and exits
> > >before the end of the servlet? For example the following 
> code is in a
> > >servlet,
> > >
> > >  if (condition A)
> > >{
> > >     do ......
> > >}
> > >else
> > >{
> > >     out.println("<HTML>");
> > >     out.println("<BODY>error!!</BODY>");
> > >     out.println("</HTML>");
> > >}
> > >
> > >other codes ...
> > >...
> > >...
> > >
> > >
> > >If condition A is not met, the error messages will be 
> output. How can I
> > >make
> > >sure that the servlet ends after this and not go on to 
> execute other codes
> > >below?
> > >
> > >Rgds,
> > >Hon Luen
> > >
> > >
> > >
> > >_________________________________________________________
> > >Do You Yahoo!?
> > >Get your free @yahoo.com address at http://mail.yahoo.com
> > >
> > >
> > >---
> > >To unsubscribe, mail advanced-java-unsubscribe@xxxxxxxxxxxxxxxx
> > >To get help, mail advanced-java-help@xxxxxxxxxxxxxxxx
> > 
> > 
> ______________________________________________________________
> _______________________
> > Get more from the Web.  FREE MSN Explorer download : 
http://explorer.msn.com
> 
> ---
> To unsubscribe, mail advanced-java-unsubscribe@xxxxxxxxxxxxxxxx
> To get help, mail advanced-java-help@xxxxxxxxxxxxxxxx

---
To unsubscribe, mail advanced-java-unsubscribe@xxxxxxxxxxxxxxxx
To get help, mail advanced-java-help@xxxxxxxxxxxxxxxx

---
To unsubscribe, mail advanced-java-unsubscribe@xxxxxxxxxxxxxxxx
To get help, mail advanced-java-help@xxxxxxxxxxxxxxxx