tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Len Popp" <len.p...@gmail.com>
Subject Re: servlet init error pages
Date Wed, 14 Nov 2007 16:24:03 GMT
HTTP error 503 is "service unavailable", which means the servlet or
web app is not running. There's a specific exception,
UnavailableException, that tells Tomcat to remove the servlet from
service. Is your servlet throwing that exception?

I've found that <error-page> doesn't work with error 503 when the
entire web app is down, but I'm not sure what happens when just one
servlet is unavailable. Maybe error 503 acts differently in this case
too.

To answer one of your questions, yes the error page location is
relative to the root of the web app. Sorry, I don't have the other
answers right now.
-- 
Len

On Nov 14, 2007 12:37 AM, Adam Parker <tforcram@gmail.com> wrote:
> Thanks for the reply, at least I know someone else has gotten it to work at
> this point.
>
> Sorry for the lack of information.  I am on a deadline and trying to do too
> many things at once.  I've included all the important things I can think of
> below.
>
> Tomcat Version: 5.5.17
> Error type:  I am seeing a 503 http error code being returned, but I want to
> be able to catch exception classes rather than specific error codes.
>
> I have tried
>
> <error-page>
>                <exception-type>java.lang.Throwable</exception-type>
>                <location>/yourErrorPage.jsp</location>
> </error-page>
>
> and
>
> <error-page>
>                <error-code>503</exception-type>
>                <location>/yourErrorPage.jsp</location>
> </error-page>
>
> in both my application web.xml, and in the tomcat web.xml (with the default
> servlet) with no success.  I still get a generic tomcat error page showing a
> stack trace.
>
> How is the error-page location related to my app?  I assumed that the root
> of the location corresponded to the root of my app, but maybe I am
> mistaken.  Would tomcat still use the default error page if it can't find
> the error page, or would it give me a different error?  Oh, and can the
> error pages be static html (mine are, perhaps that is the problem)?
>
> As for the application, the servlet init method sets up all the servlet
> dependencies through spring config.  When there is a problem with the config
> file an exception is thrown and I see the error page.
>
> Thanks for any help,
> Adam Parker
>
>
>
>
> On Nov 13, 2007 6:12 PM, Len Popp <len.popp@gmail.com> wrote:
>
> > I do get my custom error page when an error happens in a servlet
> > init() method. But you didn't give many details about your problem, so
> > I can't say whether you should be seeing custom error pages on your
> > system.
> >
> > First of all, you didn't say what version of Tomcat you're using. If
> > it's older than 5.5, it could act differently from what I've seen.
> >
> > Secondly, I'm assuming the "errors" you speak of are exceptions that
> > are thrown by the init() method. Not HTTP error status codes. (You
> > can't call response.sendError() in init().).
> >
> > Normally, the servlet's init() is called when the first HTTP request
> > is received for that servlet, and if it throws an exception a custom
> > error page will be displayed as usual.
> >
> > If the servlet has "load-on-startup" specified in web.xml, init() is
> > called when the server starts up, before there are any web requests -
> > so obviously it can't return an error page to anyone. But then init()
> > will be called *again* when a request is received for the servlet, and
> > you'll see your error page then.
> >
> > Two reasons why you might not see your custom error page:
> > 1. Error in the custom error page.
> > 2. Error in the <error-page> declaration. To define a custom error
> > page for all exceptions, do this in your application's web.xml:
> >        <error-page>
> >                <exception-type>java.lang.Throwable</exception-type>
> >                <location>/yourErrorPage.jsp</location>
> >        </error-page>
> > --
> > Len
> >
> > On Nov 13, 2007 6:19 PM, Adam Parker <tforcram@gmail.com> wrote:
> > > I am trying to override tomcat error pages, and I have tried various
> > > combinations of the <error-pages> element in both the global web.xml,
> > and my
> > > application web.xml.  Nothing is working.
> > >
> > > After some research I believe the problem is that the error I am looking
> > at
> > > actually occurs in the servlet.init(config) call.  This call doesn't
> > seem to
> > > happen in the normal request processing loop, and hence the
> > <error-pages> is
> > > never used and a generic tomcat error is returned.
> > >
> > > Is there anyway to override this error even when outside the context of
> > a
> > > request/reply?
> > >
> > > Any info on how the error is returned without a request/reply would be
> > > greatly appreciated.
> > >
> > > -Adam Parker
> > >
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message