You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Alex Muc <al...@utoronto.ca> on 2002/07/30 17:29:27 UTC
tomcat4 doesn't display compile or runtime errors/exceptions in jsp
pages like tomcat3
Hi,
I recently upgraded tomcat3.2.2 to tomcat 4.0.4. Most of the upgrade
went smoothly. Tomcat4 certainly seems faster than tomcat3 which is good.
One of the things that tomcat3 had which tomcat4 seems to lack is the
ability to view the compile or runtime errors and exceptions that occur
when developing a jsp page. In particular when you are doing a
<jsp:include> in tomcat3 and the included page was a jsp which had a
error then tomcat3 would send the stack trace of the error in the HTML
that it sent back to the browser and this error message was what made up
the contents of the included page. I know some people must have hated
this because it tended to jumble the HTML of the including page, but I
found it much easier to deal with than the way tomcat4 works which is to
display the stack trace in the log file for the context and then not
display anything as the result of the included file. This is less
useful because the user doesn't get any indication that something has
gone wrong. I'm wondering if there is a way to tell tomcat to display
the error messages to the browser AND the log file? I looked through
the mail archives but didn't find anything and I checked the
configuration documentation for tomcat4 but I couldn't find anything.
Can anyone tell me if this is possible, and if so how. If it is not
currently possible maybe that is a feature I could add if someone could
tell me generally where to look.
Thank you for your help.
Alex.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: tomcat4 doesn't display compile or runtime errors/exceptions
in jsp pages like tomcat3
Posted by Alex Muc <al...@utoronto.ca>.
I hate to be replying to my own messages, but I figured out a way to do
what I'm looking for. I'll describe it here in case anyone else wants
to do something similar.
I modified the org.apache.jasper.servlet.JspServlet file which appears
to be the main location where jsps are driven from. In the
service(request, response) method there are a bunch of catch blocks at
the bottom of the method to catch the various kinds of exceptions that
may come back from the executing the jsp page. There are different
catch blocks for both compile time and runtime exceptions that may be
caused by executing the jsp page. I basically just included the
following code in each of the catch blocks so that the error message
would get written to the browser as well as continue having tomcat
handle the exception normally (print to the log). This is the code I added:
// Write out the error
PrintWriter pw = response.getWriter();
pw.println("<pre>");
pw.println("Exception in page:\n\n");
pw.println("\n\n");
e.printStackTrace(pw);
pw.println("</pre>");
Now the catch block looks like this:
} catch (IOException e) {
// Write out the error
PrintWriter pw = response.getWriter();
pw.println("<pre>");
pw.println("Exception in page:\n\n");
pw.println("\n\n");
e.printStackTrace(pw);
pw.println("</pre>");
throw e;
}
It seems to work fine. If you have questions please send me a mail
privately as I don't follow this list very closely.
Thanks
Alex.
Alex Muc wrote:
> Hi,
>
> I recently upgraded tomcat3.2.2 to tomcat 4.0.4. Most of the upgrade
> went smoothly. Tomcat4 certainly seems faster than tomcat3 which is good.
>
> One of the things that tomcat3 had which tomcat4 seems to lack is the
> ability to view the compile or runtime errors and exceptions that
> occur when developing a jsp page. In particular when you are doing a
> <jsp:include> in tomcat3 and the included page was a jsp which had a
> error then tomcat3 would send the stack trace of the error in the HTML
> that it sent back to the browser and this error message was what made
> up the contents of the included page. I know some people must have
> hated this because it tended to jumble the HTML of the including page,
> but I found it much easier to deal with than the way tomcat4 works
> which is to display the stack trace in the log file for the context
> and then not display anything as the result of the included file.
> This is less useful because the user doesn't get any indication that
> something has gone wrong. I'm wondering if there is a way to tell
> tomcat to display the error messages to the browser AND the log file?
> I looked through the mail archives but didn't find anything and I
> checked the configuration documentation for tomcat4 but I couldn't
> find anything.
>
> Can anyone tell me if this is possible, and if so how. If it is not
> currently possible maybe that is a feature I could add if someone
> could tell me generally where to look.
>
> Thank you for your help.
> Alex.
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>