[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Beginner question: jsp error pages
Thank, Herb!
It does look like a bug
(http://nagoya.apache.org/bugzilla/show_bug.cgi?id=1867) although it was
reported 1.5 years ago and closed shortly thereafter. I downloaded my
Tomcat in February this year and I believe it was the latest stable
version at that time.
I did check to see, however, if the same thing happens when a jsp page
throws an exception instead of a servlet, and it does not - the implicit
exception object is initialized properly. So it seems that the problem
is with servlets only, just like in the reported bug.
I guess I am going to have to upgrade my Tomcat to see if it solves the
problem...
Milena
----- Original Message -----
From: "Herb Uhrig" <herbu44@yahoo.com>
To: "Milena Khlabystova" <milena@notnow.com>
Sent: Wednesday, June 18, 2003 1:47 PM
Subject: Re: Beginner question: jsp error pages
> This is not encouraging!
> http://www.jguru.com/faq/view.jsp?EID=1347
>
> But see if there is a clue in here.
>
http://forum.java.sun.com/thread.jsp?thread=357358&forum=45&message=1491601
>
> best Regards,
> Herb
>
> --- Milena Khlabystova <milena@notnow.com> wrote:
> > Hi, all:
> >
> > Let me begin by saying that I am new to jsp/servlets, and I would
> > appreciate it if someone could help me with the following problem.
> >
> > In my application, if a servlet or jsp page throws an exception, I
would
> > like the container to redirect to the following generic error page
that
> > would display the information about the exception:
> >
> > ----------- /error-pages/error.jsp ---------
> > <%@ page isErrorPage="true" %>
> > <html>
> > <body>
> > Oops! We got an exception:<br>
> > <pre>
> > <%
> > if (exception != null)
> > out.print(exception.getMessage());
> > else
> > out.print("exception is null...");
> > %>
> > </pre>
> > </body>
> > </html>
> > -----------------------------------
> >
> > So, in my web.xml file I added the following entry:
> >
> > ----------- web.xml ---------
> > ...
> > <error-page>
> > <exception-type>java.lang.Exception</exception-type>
> > <location>/error-pages/error.jsp</location>
> > </error-page>
> > ...
> > -----------------------------------
> >
> > Now, when a servlet throws an exception - by wrapping any exception
that
> > was thrown inside doXXX method and re-throwing it:
> >
> > ----------- Servlet's doXXX method ---------
> > try{
> > // some code ...
> > }
> > catch(Exception e){
> > throw new ServletException(e);
> > }
> > -----------------------------------
> >
> > the container correctly redirects to error.jsp. The problem is that
the
> > implicit variable "exception" that should be available to this page
is
> > always null (i.e. the message "exception is null..." is always
> > displayed). Can somebody tell me why it is so? What am I missing? I
> > would like to access the information about the thrown exception from
the
> > error page.
> >
> > I am running Tomcat 4.1.18 + Apache 2.0 + RedHat 8.0 if this helps.
> >
> > I have seen many similar postings on the web, but none of them
seemed to
> > have any solutions.
> >
> > Thanks a lot!
> >
> > Milena
> >
> >
>
>
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com
>