You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Fabien Modoux <fa...@voicemate.com> on 2001/11/16 17:32:08 UTC

error-page usage in web.xml

Hello,

I am having trouble understanding how to properly configure
the error-page section of my web.xml. I found some previous
posts, but could not find enough information.

There are two types of error-page element: exception-type and 
error-code. Are those complimentary -- i.e., they must both be 
defined to handle all errors -- or is there some sort of overlap? 
I did a few tests and I don't think 404 cannot be handled as an 
exception, only with the error-code element. However I am 
wondering about the difference between error-code 500 and 
exception-type java.lang.Throwable, which one is the most general 
one?

I've also seen a post (#33290) saying that

> Within the page, you can access (among others) the following request 
> attribute created by the container:
> 
>   <%
>     String requestURI = (String)
>      request.getAttribute("javax.servlet.error.request_uri");
>   %>

I am using TC3.2.2 and the attribute has the value of the error
handler page, not of the page that created the error. Is the possible
to get the latter info?

Thanks for your help,

-Fabien

---------------------------------------------      
Fabien Modoux,
Voicemate - http://www.voicemate.com

--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: PreparedStatement caching?

Posted by Nikola Milutinovic <Ni...@ev.co.yu>.
> does Tomcat implement caching for PreparedStatement objects?

PreparedStatement is a part of JDBC, which has nothing to do with Tomcat.

Nix.

PreparedStatement caching?

Posted by Marko Asplund <as...@kronodoc.fi>.
does Tomcat implement caching for PreparedStatement objects?

-- 
	aspa


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: error-page usage in web.xml (correction)

Posted by Barry White <ba...@charter.net>.
Fabien,
Just a follow-up to my previous email.
I was able to get the calling URI of the page that caused the exception
along with the time of the exception to be stored in the application log of
Tomcat (or your webapp).
In my error page (error.jsp) I put:

<% // Log the calling URL to the log file.  All other info about the
exception is logged automatically.
application.log("Exception occured on page-> " + (String)
request.getAttribute("javax.servlet.error.request_uri"), exception);
%>

This placed the calling URI and date/time in my log file as shown:

2001-11-17 01:14:26 Exception occured on page-> /rfq/inqtableman.jsp
java.sql.SQLException: Error during query: Unexpected Exception:
java.sql.SQLException message given: Column not found: Unknown column
'inqmain.inqNumberZZZ' in 'order clause'
 at org.gjt.mm.mysql.Connection.execSQL(Connection.java:807)
 at org.gjt.mm.mysql.Connection.execSQL(Connection.java:740)
 at org.gjt.mm.mysql.Statement.executeQuery(Statement.java:159) . . . . . .
. (much more information written by Tomcat)

The above example is for an SQL exception, and you must have the exception
and error page defined in the web.xml file of your web application.
I did not need the code in the calling page that I wrote in the previous
email.
BTW I am using Tomcat 4.0, W2K

Hope this helps,
Barry

----- Original Message -----
From: "Barry White" <ba...@charter.net>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Friday, November 16, 2001 3:17 PM
Subject: Re: error-page usage in web.xml


> Yes are correct in stating that the 404 error is not an exception... it is
> simply file not found error and must be handled seperatly from exception
> errors.
> I am currently exploring the exception error handling/page myself.
> You can get the URL of the page as follows:
>
> In the page you have the error, you put:
> <% request.setAttribute("sourcePage", request.getRequestURI()); %>
>
> then in your exception error page defined in web.xml (JSP) you get the URI
> by:
> <% request.getAttribute("sourcePage"); %>
>
> You would usually write the error URL in your log file for debugging
allong
> with the rest of the exception info.
>
> There are probably many beans available on the web that will do this quit
> nicely, but where is the fun in that?
> :)
> Barry
>
>
> ----- Original Message -----
> From: "Fabien Modoux" <fa...@voicemate.com>
> To: <to...@jakarta.apache.org>
> Sent: Friday, November 16, 2001 11:32 AM
> Subject: error-page usage in web.xml
>
>
> > Hello,
> >
> > I am having trouble understanding how to properly configure
> > the error-page section of my web.xml. I found some previous
> > posts, but could not find enough information.
> >
> > There are two types of error-page element: exception-type and
> > error-code. Are those complimentary -- i.e., they must both be
> > defined to handle all errors -- or is there some sort of overlap?
> > I did a few tests and I don't think 404 cannot be handled as an
> > exception, only with the error-code element. However I am
> > wondering about the difference between error-code 500 and
> > exception-type java.lang.Throwable, which one is the most general
> > one?
> >
> > I've also seen a post (#33290) saying that
> >
> > > Within the page, you can access (among others) the following request
> > > attribute created by the container:
> > >
> > >   <%
> > >     String requestURI = (String)
> > >      request.getAttribute("javax.servlet.error.request_uri");
> > >   %>
> >
> > I am using TC3.2.2 and the attribute has the value of the error
> > handler page, not of the page that created the error. Is the possible
> > to get the latter info?
> >
> > Thanks for your help,
> >
> > -Fabien
> >
> > ---------------------------------------------
> > Fabien Modoux,
> > Voicemate - http://www.voicemate.com
> >
> > --
> > To unsubscribe:   <ma...@jakarta.apache.org>
> > For additional commands: <ma...@jakarta.apache.org>
> > Troubles with the list: <ma...@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: error-page usage in web.xml

Posted by Barry White <ba...@charter.net>.
Yes are correct in stating that the 404 error is not an exception... it is
simply file not found error and must be handled seperatly from exception
errors.
I am currently exploring the exception error handling/page myself.
You can get the URL of the page as follows:

In the page you have the error, you put:
<% request.setAttribute("sourcePage", request.getRequestURI()); %>

then in your exception error page defined in web.xml (JSP) you get the URI
by:
<% request.getAttribute("sourcePage"); %>

You would usually write the error URL in your log file for debugging allong
with the rest of the exception info.

There are probably many beans available on the web that will do this quit
nicely, but where is the fun in that?
:)
Barry


----- Original Message -----
From: "Fabien Modoux" <fa...@voicemate.com>
To: <to...@jakarta.apache.org>
Sent: Friday, November 16, 2001 11:32 AM
Subject: error-page usage in web.xml


> Hello,
>
> I am having trouble understanding how to properly configure
> the error-page section of my web.xml. I found some previous
> posts, but could not find enough information.
>
> There are two types of error-page element: exception-type and
> error-code. Are those complimentary -- i.e., they must both be
> defined to handle all errors -- or is there some sort of overlap?
> I did a few tests and I don't think 404 cannot be handled as an
> exception, only with the error-code element. However I am
> wondering about the difference between error-code 500 and
> exception-type java.lang.Throwable, which one is the most general
> one?
>
> I've also seen a post (#33290) saying that
>
> > Within the page, you can access (among others) the following request
> > attribute created by the container:
> >
> >   <%
> >     String requestURI = (String)
> >      request.getAttribute("javax.servlet.error.request_uri");
> >   %>
>
> I am using TC3.2.2 and the attribute has the value of the error
> handler page, not of the page that created the error. Is the possible
> to get the latter info?
>
> Thanks for your help,
>
> -Fabien
>
> ---------------------------------------------
> Fabien Modoux,
> Voicemate - http://www.voicemate.com
>
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: error-page usage in web.xml

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Fri, 16 Nov 2001, Fabien Modoux wrote:

> Date: Fri, 16 Nov 2001 11:32:08 -0500
> From: Fabien Modoux <fa...@voicemate.com>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: tomcat-user@jakarta.apache.org
> Subject: error-page usage in web.xml
>
> Hello,
>
> I am having trouble understanding how to properly configure
> the error-page section of my web.xml. I found some previous
> posts, but could not find enough information.
>
> There are two types of error-page element: exception-type and
> error-code. Are those complimentary -- i.e., they must both be
> defined to handle all errors -- or is there some sort of overlap?

There's no overlap.

The <exception-type> error pages are consulted when your servlet throws an
exception instead of returning normally from the service() method.

The <error-code> error pages are consulted when your servlet returns
normally from the service() method, but you've set the HTTP response
status to something other than 200.

> I did a few tests and I don't think 404 cannot be handled as an
> exception, only with the error-code element. However I am
> wondering about the difference between error-code 500 and
> exception-type java.lang.Throwable, which one is the most general
> one?
>

If your servlet throws an exception, and you have *not* defined an error
page for that exception, Tomcat creates a default "error 500" page for
you.

> I've also seen a post (#33290) saying that
>
> > Within the page, you can access (among others) the following request
> > attribute created by the container:
> >
> >   <%
> >     String requestURI = (String)
> >      request.getAttribute("javax.servlet.error.request_uri");
> >   %>
>
> I am using TC3.2.2 and the attribute has the value of the error
> handler page, not of the page that created the error. Is the possible
> to get the latter info?
>

Sounds like a bug in 3.2.2 -- it should be the request URI of the original
page.

> Thanks for your help,
>
> -Fabien
>

Craig McClanahan


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>