You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Christopher Schultz <ch...@christopherschultz.net> on 2011/04/12 22:38:25 UTC

[OT] servlet-specific error pages

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

All,

I have a webapp where some of the servlets are expected to return XML
all the time, even for error conditions. I'd like to be able to set an
error page for those servlets so the response will be in XML instead of
HTML like you'd get with the default Tomcat error page or an error page
we might have configured for the rest of the site.

I didn't see anything in web.xml that would allow me to set an error
page for a particular servlet.

Any good ideas?

Obviously, I can create a system-wide "error" resource that determines
the resource that was being used and then dispatch to either an
HTML-oriented or XML-oriented error page, but I was wondering if
something like that already existed or if there was a better approach.

Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2kuEEACgkQ9CaO5/Lv0PBpqACfVky6ZZvG/Rgpt4XK804jdbei
JpEAnj/NF2td4NNHoBAbFBRAgsUDkC0v
=xjBP
-----END PGP SIGNATURE-----

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


Re: [OT] servlet-specific error pages

Posted by Justin Randall <ra...@hotmail.com>.
Hi Martin,

What Chris is actually looking for is custom servlet specific error handling in addition to web application error handling (the later is what you have described below).

In other words, 401 for Servlet X is directed to a different JSP than 401 for the entire web application.

Regards,

Justin Randall
Sent from my BlackBerry device

-----Original Message-----
From: Martin Gainty <mg...@hotmail.com>
Date: Wed, 13 Apr 2011 21:47:51 
To: Tomcat Users List<us...@tomcat.apache.org>
Reply-To: "Tomcat Users List" <us...@tomcat.apache.org>
Subject: RE: [OT] servlet-specific error pages


in web.xml for your webapp
map a custom jsp for each returned HTTP status code e.g:

  <error-page>
    <error-code>401</error-code>
    <location>/401.jsp</location>
  </error-page>
  <error-page>
    <error-code>403</error-code>
    <location>/403.jsp</location>
  </error-page>
  <error-page>
    <error-code>404</error-code>
    <location>/404.jsp</location>
  </error-page>

Martin  
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




> From: randju@hotmail.com
> To: users@tomcat.apache.org
> Subject: RE: [OT] servlet-specific error pages
> Date: Wed, 13 Apr 2011 20:10:48 -0400
> 
> 
> Hi Chris,
> 
> > Of course. I was wondering about other exceptions or errors that maybe I
> > cannot control from that code.
> 
> Are you referring to internal exceptions within Tomcat's own code or simply unexpected exceptions within the servlet's implemented code?  If it's the later you could always just wrap your code with a try block that catches "Throwable" which will catch any possible exception thrown by Java and properly implemented library exceptions.  Perhaps not ideal but considering the available options it might not be too bad.
> 
> Technically speaking, catching Throwable isn't such a bad practice for end-user facing applications because you can at least redirect to a more elegant "Unexpected Exception has occurred" page rather than an error page showing a stack trace of a NullPointerException or some other unexpected errors due to programming mistakes as an example.
> 
> Regards,
> 
> Justin Randall
> 
> > Date: Wed, 13 Apr 2011 16:11:09 -0400
> > From: chris@christopherschultz.net
> > To: users@tomcat.apache.org
> > Subject: Re: [OT] servlet-specific error pages
> > 
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> > 
> > Justin,
> > 
> > On 4/13/2011 9:17 AM, Justin Randall wrote:
> > > Hi Chris,
> > > 
> > > I'm assuming the servlet is in control of generating all of the
> > > errors you are implying?
> > 
> > Yes and no:
> > 
> > > For example, if the servlet doesn't load properly and a 404 would be
> > > generated, the servlet would obviously not be in control of handling
> > > this exception and this would would have to make use of <error-page>
> > > directives in web.xml, specifically for <error-code> 404 which would
> > > redirect to a JSP that just so happens to be an XML file.
> > 
> > Right, but I want the default 404 error page to be in HTML.
> > 
> > Basically, I want two defaults.
> > 
> > If the servlet spec allowed for <error-page> to include a <servlet-name>
> > filter, that's what I would use. But it doesn't :(
> > 
> > > If I've understood what you're looking for correctly I've worked on
> > > similar projects in the past and what's worked well for me is
> > > leveraging MVC by using the RequestDispatcher to forward to relevant
> > > JSPs which happen to all be XML files with the contents populated
> > > either via JSP tags or EL.  This way you can catch the
> > > exceptions/error conditions in your servlet, set the appropriate
> > > exception information within the request context and the dispatch to
> > > the correct JSP XML page.
> > 
> > Of course. I was wondering about other exceptions or errors that maybe I
> > cannot control from that code.
> > 
> > Thanks,
> > - -chris
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.4.10 (MingW32)
> > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> > 
> > iEYEARECAAYFAk2mA10ACgkQ9CaO5/Lv0PAvMgCgqk4ZiH5b75jrl25Kq73Po3hq
> > qCIAniutff9LdBlxKTUya36QdWp9e+eL
> > =j2iW
> > -----END PGP SIGNATURE-----
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> > 
>  		 	   		  
 		 	   		  

RE: [OT] servlet-specific error pages

Posted by Martin Gainty <mg...@hotmail.com>.
in web.xml for your webapp
map a custom jsp for each returned HTTP status code e.g:

  <error-page>
    <error-code>401</error-code>
    <location>/401.jsp</location>
  </error-page>
  <error-page>
    <error-code>403</error-code>
    <location>/403.jsp</location>
  </error-page>
  <error-page>
    <error-code>404</error-code>
    <location>/404.jsp</location>
  </error-page>

Martin  
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




> From: randju@hotmail.com
> To: users@tomcat.apache.org
> Subject: RE: [OT] servlet-specific error pages
> Date: Wed, 13 Apr 2011 20:10:48 -0400
> 
> 
> Hi Chris,
> 
> > Of course. I was wondering about other exceptions or errors that maybe I
> > cannot control from that code.
> 
> Are you referring to internal exceptions within Tomcat's own code or simply unexpected exceptions within the servlet's implemented code?  If it's the later you could always just wrap your code with a try block that catches "Throwable" which will catch any possible exception thrown by Java and properly implemented library exceptions.  Perhaps not ideal but considering the available options it might not be too bad.
> 
> Technically speaking, catching Throwable isn't such a bad practice for end-user facing applications because you can at least redirect to a more elegant "Unexpected Exception has occurred" page rather than an error page showing a stack trace of a NullPointerException or some other unexpected errors due to programming mistakes as an example.
> 
> Regards,
> 
> Justin Randall
> 
> > Date: Wed, 13 Apr 2011 16:11:09 -0400
> > From: chris@christopherschultz.net
> > To: users@tomcat.apache.org
> > Subject: Re: [OT] servlet-specific error pages
> > 
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> > 
> > Justin,
> > 
> > On 4/13/2011 9:17 AM, Justin Randall wrote:
> > > Hi Chris,
> > > 
> > > I'm assuming the servlet is in control of generating all of the
> > > errors you are implying?
> > 
> > Yes and no:
> > 
> > > For example, if the servlet doesn't load properly and a 404 would be
> > > generated, the servlet would obviously not be in control of handling
> > > this exception and this would would have to make use of <error-page>
> > > directives in web.xml, specifically for <error-code> 404 which would
> > > redirect to a JSP that just so happens to be an XML file.
> > 
> > Right, but I want the default 404 error page to be in HTML.
> > 
> > Basically, I want two defaults.
> > 
> > If the servlet spec allowed for <error-page> to include a <servlet-name>
> > filter, that's what I would use. But it doesn't :(
> > 
> > > If I've understood what you're looking for correctly I've worked on
> > > similar projects in the past and what's worked well for me is
> > > leveraging MVC by using the RequestDispatcher to forward to relevant
> > > JSPs which happen to all be XML files with the contents populated
> > > either via JSP tags or EL.  This way you can catch the
> > > exceptions/error conditions in your servlet, set the appropriate
> > > exception information within the request context and the dispatch to
> > > the correct JSP XML page.
> > 
> > Of course. I was wondering about other exceptions or errors that maybe I
> > cannot control from that code.
> > 
> > Thanks,
> > - -chris
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.4.10 (MingW32)
> > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> > 
> > iEYEARECAAYFAk2mA10ACgkQ9CaO5/Lv0PAvMgCgqk4ZiH5b75jrl25Kq73Po3hq
> > qCIAniutff9LdBlxKTUya36QdWp9e+eL
> > =j2iW
> > -----END PGP SIGNATURE-----
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> > 
>  		 	   		  
 		 	   		  

Re: [OT] servlet-specific error pages

Posted by sebb <se...@gmail.com>.
On 14 April 2011 01:10, Justin Randall <ra...@hotmail.com> wrote:
>
> Hi Chris,
>
>> Of course. I was wondering about other exceptions or errors that maybe I
>> cannot control from that code.
>
> Are you referring to internal exceptions within Tomcat's own code or simply unexpected exceptions within the servlet's implemented code?  If it's the later you could always just wrap your code with a try block that catches "Throwable" which will catch any possible exception thrown by Java and properly implemented library exceptions.  Perhaps not ideal but considering the available options it might not be too bad.
>
> Technically speaking, catching Throwable isn't such a bad practice for end-user facing applications because you can at least redirect to a more elegant "Unexpected Exception has occurred" page rather than an error page showing a stack trace of a NullPointerException or some other unexpected errors due to programming mistakes as an example.

Some Throwables should never be caught - or if they are, must be rethrown.
For example, ThreadDeath and VirtualMachineError.

Should be safe to catch RuntimeException (includes NPE) and Exception.

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


RE: [OT] servlet-specific error pages

Posted by Justin Randall <ra...@hotmail.com>.
Hi Chris,

> Of course. I was wondering about other exceptions or errors that maybe I
> cannot control from that code.

Are you referring to internal exceptions within Tomcat's own code or simply unexpected exceptions within the servlet's implemented code?  If it's the later you could always just wrap your code with a try block that catches "Throwable" which will catch any possible exception thrown by Java and properly implemented library exceptions.  Perhaps not ideal but considering the available options it might not be too bad.

Technically speaking, catching Throwable isn't such a bad practice for end-user facing applications because you can at least redirect to a more elegant "Unexpected Exception has occurred" page rather than an error page showing a stack trace of a NullPointerException or some other unexpected errors due to programming mistakes as an example.

Regards,

Justin Randall

> Date: Wed, 13 Apr 2011 16:11:09 -0400
> From: chris@christopherschultz.net
> To: users@tomcat.apache.org
> Subject: Re: [OT] servlet-specific error pages
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Justin,
> 
> On 4/13/2011 9:17 AM, Justin Randall wrote:
> > Hi Chris,
> > 
> > I'm assuming the servlet is in control of generating all of the
> > errors you are implying?
> 
> Yes and no:
> 
> > For example, if the servlet doesn't load properly and a 404 would be
> > generated, the servlet would obviously not be in control of handling
> > this exception and this would would have to make use of <error-page>
> > directives in web.xml, specifically for <error-code> 404 which would
> > redirect to a JSP that just so happens to be an XML file.
> 
> Right, but I want the default 404 error page to be in HTML.
> 
> Basically, I want two defaults.
> 
> If the servlet spec allowed for <error-page> to include a <servlet-name>
> filter, that's what I would use. But it doesn't :(
> 
> > If I've understood what you're looking for correctly I've worked on
> > similar projects in the past and what's worked well for me is
> > leveraging MVC by using the RequestDispatcher to forward to relevant
> > JSPs which happen to all be XML files with the contents populated
> > either via JSP tags or EL.  This way you can catch the
> > exceptions/error conditions in your servlet, set the appropriate
> > exception information within the request context and the dispatch to
> > the correct JSP XML page.
> 
> Of course. I was wondering about other exceptions or errors that maybe I
> cannot control from that code.
> 
> Thanks,
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAk2mA10ACgkQ9CaO5/Lv0PAvMgCgqk4ZiH5b75jrl25Kq73Po3hq
> qCIAniutff9LdBlxKTUya36QdWp9e+eL
> =j2iW
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
 		 	   		  

Re: [OT] servlet-specific error pages

Posted by Bob Hall <rf...@yahoo.com>.
Chris,

--- On Wed, 4/13/11 at 1:11 PM, Christopher Schultz <ch...@christopherschultz.net> wrote:

> Basically, I want two defaults.
> 
> If the servlet spec allowed for <error-page> to
> include a <servlet-name>
> filter, that's what I would use. But it doesn't :(
> 

Would an Exception marker interface help to differentiate Servlet and other Exceptions?

A Servlet could conditionally throw Exceptions that implemented a given marker interface.

An <error-page> JSP could use instanceof to check for marker interface(s) and conditionally handle presentation of the Exceptions.

- Bob



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


Re: [OT] servlet-specific error pages

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Justin,

On 4/13/2011 9:17 AM, Justin Randall wrote:
> Hi Chris,
> 
> I'm assuming the servlet is in control of generating all of the
> errors you are implying?

Yes and no:

> For example, if the servlet doesn't load properly and a 404 would be
> generated, the servlet would obviously not be in control of handling
> this exception and this would would have to make use of <error-page>
> directives in web.xml, specifically for <error-code> 404 which would
> redirect to a JSP that just so happens to be an XML file.

Right, but I want the default 404 error page to be in HTML.

Basically, I want two defaults.

If the servlet spec allowed for <error-page> to include a <servlet-name>
filter, that's what I would use. But it doesn't :(

> If I've understood what you're looking for correctly I've worked on
> similar projects in the past and what's worked well for me is
> leveraging MVC by using the RequestDispatcher to forward to relevant
> JSPs which happen to all be XML files with the contents populated
> either via JSP tags or EL.  This way you can catch the
> exceptions/error conditions in your servlet, set the appropriate
> exception information within the request context and the dispatch to
> the correct JSP XML page.

Of course. I was wondering about other exceptions or errors that maybe I
cannot control from that code.

Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2mA10ACgkQ9CaO5/Lv0PAvMgCgqk4ZiH5b75jrl25Kq73Po3hq
qCIAniutff9LdBlxKTUya36QdWp9e+eL
=j2iW
-----END PGP SIGNATURE-----

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


RE: [OT] servlet-specific error pages

Posted by Justin Randall <ra...@hotmail.com>.
Hi Chris,

I'm assuming the servlet is in control of generating all of the errors you are implying?

For example, if the servlet doesn't load properly and a 404 would be generated, the servlet would obviously not be in control of handling this exception and this would would have to make use of <error-page> directives in web.xml, specifically for <error-code> 404 which would redirect to a JSP that just so happens to be an XML file.

If I've understood what you're looking for correctly I've worked on similar projects in the past and what's worked well for me is leveraging MVC by using the RequestDispatcher to forward to relevant JSPs which happen to all be XML files with the contents populated either via JSP tags or EL.  This way you can catch the exceptions/error conditions in your servlet, set the appropriate exception information within the request context and the dispatch to the correct JSP XML page.

For example:

errorfile.jsp:

=====
<%@ page trimDirectiveWhitespaces="true" %>
<%@ page contentType="text/xml; charset=UTF-8" %>
<%@ page session="false" %>
<%
    response.setHeader("Cache-Control","no-cache");
    response.setHeader("Pragma","no-cache");
    response.setDateHeader ("Expires", 0);
%>
<?xml version="1.0" encoding="utf-8"?>
<someXmlRoot>
    <errorCode>${requestScope.errorCode}</errorCode>
    <errorMessage>${requestScope.errorMessage}</errorMessage>
</someXmlRoot>
=====

In your serlvet you would redirect to the JSP as follows:

=====
RequestDispatcher dispatcher = req.getRequestDispatcher("/WEB-INF/path/to/errorfile.jsp");
req.setAttribute("errorCode", "500");
req.setAttribute("errorMessage", "My server had an oops!");
dispatcher.forward(req, rsp);
=====

Note the XML file doesn't have a schema associated with it but that's just for brevity of the example.

I hope this helps!

Justin Randall


> Date: Tue, 12 Apr 2011 16:38:25 -0400
> From: chris@christopherschultz.net
> To: users@tomcat.apache.org
> Subject: [OT] servlet-specific error pages
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> All,
> 
> I have a webapp where some of the servlets are expected to return XML
> all the time, even for error conditions. I'd like to be able to set an
> error page for those servlets so the response will be in XML instead of
> HTML like you'd get with the default Tomcat error page or an error page
> we might have configured for the rest of the site.
> 
> I didn't see anything in web.xml that would allow me to set an error
> page for a particular servlet.
> 
> Any good ideas?
> 
> Obviously, I can create a system-wide "error" resource that determines
> the resource that was being used and then dispatch to either an
> HTML-oriented or XML-oriented error page, but I was wondering if
> something like that already existed or if there was a better approach.
> 
> Thanks,
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAk2kuEEACgkQ9CaO5/Lv0PBpqACfVky6ZZvG/Rgpt4XK804jdbei
> JpEAnj/NF2td4NNHoBAbFBRAgsUDkC0v
> =xjBP
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
 		 	   		  

Re: [OT] servlet-specific error pages

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

János,

On 4/13/2011 11:37 AM, János Löbb wrote:
> I was thinking about this section in the FM 10.9.2:
> 
> <nyissz> Error-page declarations using the exception-type element in
> the deployment descriptor must be unique up to the class name of the
> exception-type. Similarly, error-page declarations using the
> status-code element must be unique in the deployment descriptor up to
> the status code. <nyassz>
> 
> Plus the the two paragraphs before it.  So if you are not finding
> anything useful in the deployment descriptor, then you can add your
> own to it and create a class that is matching the added
> exception-type.  There are probably many already ready made java
> classes in the open that you can just incorporate to emit the xml.

So... how do I convince the JRE to throw
MyXMLSpecificNullPointerException for those XML-related actions?

I suppose I could write a filter that I wrap around all my XML-based
servlets that catches things like RuntimeException and re-throws
something else.

That seems entirely stupid to me.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2mAssACgkQ9CaO5/Lv0PD18wCgvBQIOEdFk8pOLUXhhm1H4jm6
JgAAn1HfAnie6TFc2z/aF/MH23gNtehh
=KEIg
-----END PGP SIGNATURE-----

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


Re: [OT] servlet-specific error pages

Posted by János Löbb <ja...@yale.edu>.
Chris,

I was thinking about this section in the FM 10.9.2:

<nyissz>
Error-page declarations using the exception-type element in the deployment descriptor must be unique up to the class name of the exception-type. Similarly, error-page declarations using the status-code element must be unique in the deployment descriptor up to the status code.
<nyassz>

Plus the the two paragraphs before it.  So if you are not finding anything useful in the deployment descriptor, then you can add your own to it and create a class that is matching the added exception-type.  There are probably many already ready made java classes in the open that you can just incorporate to emit the xml.

János

On Apr 12, 2011, at 6:17 PM, Christopher Schultz wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> János,
> 
> On 4/12/2011 4:56 PM, János Löbb wrote:
>> Look the 10.9 Error Handling in the 3.0 specifications.  It is maya
>> to me but you might find what you are looking for.
> 
> Being somewhat familiar with the servlet specification, I was hoping for
> something more helpful than "RTFM". :(
> 
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAk2kz2oACgkQ9CaO5/Lv0PAuBgCfV6ZCaVybXg8lwOgYzIpr+hcA
> yvkAoKUR90RVh86CPyPvGkwtZmOyCpoH
> =H/dk
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org


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


Re: [OT] servlet-specific error pages

Posted by Francis GALIEGUE <fg...@one2team.com>.
On Wed, Apr 13, 2011 at 00:17, Christopher Schultz
<ch...@christopherschultz.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> János,
>
> On 4/12/2011 4:56 PM, János Löbb wrote:
>> Look the 10.9 Error Handling in the 3.0 specifications.  It is maya
>> to me but you might find what you are looking for.
>
> Being somewhat familiar with the servlet specification, I was hoping for
> something more helpful than "RTFM". :(
>

Hello,

You can always use .setResponse() and fill the page with whatever you
want. Tomcat will only use its pages or whatever is defined in
<error-page> if you use .sendError(), and you can
.setResponse(SC_ANYTHINGOTHERTHANOK).

-- 
Francis Galiegue
ONE2TEAM
Ingénieur système
Mob : +33 (0) 683 877 875
Tel : +33 (0) 178 945 552
fge@one2team.com
40 avenue Raymond Poincaré
75116 Paris

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


Re: [OT] servlet-specific error pages

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

János,

On 4/12/2011 4:56 PM, János Löbb wrote:
> Look the 10.9 Error Handling in the 3.0 specifications.  It is maya
> to me but you might find what you are looking for.

Being somewhat familiar with the servlet specification, I was hoping for
something more helpful than "RTFM". :(

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2kz2oACgkQ9CaO5/Lv0PAuBgCfV6ZCaVybXg8lwOgYzIpr+hcA
yvkAoKUR90RVh86CPyPvGkwtZmOyCpoH
=H/dk
-----END PGP SIGNATURE-----

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


Re: [OT] servlet-specific error pages

Posted by János Löbb <ja...@yale.edu>.
On Apr 12, 2011, at 4:38 PM, Christopher Schultz wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> All,
> 
> I have a webapp where some of the servlets are expected to return XML
> all the time, even for error conditions. I'd like to be able to set an
> error page for those servlets so the response will be in XML instead of
> HTML like you'd get with the default Tomcat error page or an error page
> we might have configured for the rest of the site.
> 
> I didn't see anything in web.xml that would allow me to set an error
> page for a particular servlet.
> 
> Any good ideas?
> 
> Obviously, I can create a system-wide "error" resource that determines
> the resource that was being used and then dispatch to either an
> HTML-oriented or XML-oriented error page, but I was wondering if
> something like that already existed or if there was a better approach.
> 
> Thanks,
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAk2kuEEACgkQ9CaO5/Lv0PBpqACfVky6ZZvG/Rgpt4XK804jdbei
> JpEAnj/NF2td4NNHoBAbFBRAgsUDkC0v
> =xjBP
> -----END PGP SIGNATURE-----
> 

Chris,

Look the 10.9 Error Handling in the 3.0 specifications.  It is maya to me but you might find what you are looking for.

János


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