You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Johnson <ch...@gmail.com> on 2005/05/26 16:55:47 UTC

Creating a standard page to handle Error 500

Hey all
 I recently added the following to my JSP pages to force them not to be 
cached:
 <% response.setHeader("Pragma","no-cache");%> 
<% response.setHeader("Cache-Control","no-store");%> 
<% response.setDateHeader("Expires",-1);%> 
 the result is that if the user hits "back" then "reload" they get an error 
500. How can I create a page that will handle any error 500 that comes up? 
Essentially, I just want to display a message that tells the user to 
re-login..
 thoughts?

-- 
-Dave
ChaChaNY@Gmail.com

Re: Creating a standard page to handle Error 500

Posted by Andrew Thorell <dr...@gmail.com>.
,mime-mapping*,welcome-file-list?,error-page*,taglib*,reso

That error is tell you that you placed the error-page tag in the wrong
section. The error tells you the correct order you need to put all the
tags in.

Andrew

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Creating a standard page to handle Error 500

Posted by Andrew Thorell <dr...@gmail.com>.
Perhaps the community can answer that question for you. I use the
error-page 500 as a catch all for undefined / unexpected errors. I'm
sure there's a way to do it, I just haven't done it before and can't
tell you off the top of my head. You can probably point the Error at
an action which can point to a tiles definition. I'm just getting
started with tiles, so I'm not sure... let me know how it turns out.

My first test would be something like the following: Point the Error
to an action which pulls all the parameters out of the request object
and see what's there. If nothing is there, you may want to modify your
code to catch all exceptions and put the stack trace in the session
scope as a bean and pass it that way, parse it in the action your
Error 500 page points to. But whether that works or if there is a
better was is speculation.

Hope this helped,

Andrew T

On 5/26/05, David Johnson <ch...@gmail.com> wrote:
> Can I point it at a tiles-definition? I have one called "page.error" 
>   
> Also, how to I display the details of the error in my error page?
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Creating a standard page to handle Error 500

Posted by Andrew Thorell <dr...@gmail.com>.
Web.xml

<error-page>
  <error-code> 500 </error-code>
  <location> /where/you/want/to/go </location>
</error-page>

you can do redirections inside your location page, or however you want
to set it up, point it at an action or whatever.

Andrew T

On 5/26/05, David Johnson <ch...@gmail.com> wrote:
> Hey all
>  I recently added the following to my JSP pages to force them not to be
> cached:
>  <% response.setHeader("Pragma","no-cache");%>
> <% response.setHeader("Cache-Control","no-store");%>
> <% response.setDateHeader("Expires",-1);%>
>  the result is that if the user hits "back" then "reload" they get an error
> 500. How can I create a page that will handle any error 500 that comes up?
> Essentially, I just want to display a message that tells the user to
> re-login..
>  thoughts?
> 
> --
> -Dave
> ChaChaNY@Gmail.com
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Creating a standard page to handle Error 500

Posted by Martin Gainty <mg...@hotmail.com>.
David
However you inherit from ActionServlet
If your new class BaseServlet inherits from ActionServlet I would put the 
code into BaseServlet
HTH,
Martin-
US
001-617-852-7822
----- Original Message ----- 
From: "David Johnson" <ch...@gmail.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>; "Martin Gainty" 
<mg...@hotmail.com>
Sent: Thursday, May 26, 2005 5:32 PM
Subject: Re: Creating a standard page to handle Error 500


also... I have a BaseAction all my actions are inherited from.... might I do
whatever you recommend I do... there? :D

On 5/26/05, David Johnson <ch...@gmail.com> wrote:
>
> Alright, I think I'm thick.
>  how would I do that? would I override doGet() and doPost()?
>  help!
>
>  On 5/26/05, Martin Gainty <mg...@hotmail.com> wrote:
> >
> > Andrew-
> > can intercept your ActionServlet's doGet or doPost method before process
> > method is invoked
> > If you want simple follow the instructions for supplying web.xmllocation
> > attribute for login jsp page
> > HTH,
> > ----- Original Message -----
> > From: "Andrew Thorell" < drew.thorell@gmail.com>
> > To: "Struts Users Mailing List" <us...@struts.apache.org>
> > Sent: Thursday, May 26, 2005 11:41 AM
> > Subject: Re: Creating a standard page to handle Error 500
> >
> >
> > Where does one find this to modify the doGet method? I've yet to deal
> > with actually modifiying the actual servlet...
> >
> > Andrew
> >
> > On 5/26/05, Martin Gainty <mgainty@hotmail.com > wrote:
> > > Inside the StrutsServlet's doGet method
> > >
> > > RequestDispatcher dispatcher = null;
> > >
> > > request.getRequestDispatcher(/err/SQL.jsp);
> > >
> > > try {
> > >
> > > // operation which causes 500
> > > }
> > > catch (Exception se) {
> > > //forwards to a login.jsp
> > > dispatcher.forward(request, response);
> > > }
> > >
> > > check out http://java.sun.com/j2ee/1.4/docs/api/index.html
> > > Regards,
> > > Martin-
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
> -- 
> -Dave
> ChaChaNY@Gmail.com




-- 
-Dave
ChaChaNY@Gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Creating a standard page to handle Error 500

Posted by David Johnson <ch...@gmail.com>.
also... I have a BaseAction all my actions are inherited from.... might I do 
whatever you recommend I do... there? :D

On 5/26/05, David Johnson <ch...@gmail.com> wrote: 
> 
> Alright, I think I'm thick.
>  how would I do that? would I override doGet() and doPost()?
>  help! 
> 
>  On 5/26/05, Martin Gainty <mg...@hotmail.com> wrote: 
> > 
> > Andrew-
> > can intercept your ActionServlet's doGet or doPost method before process
> > method is invoked
> > If you want simple follow the instructions for supplying web.xmllocation
> > attribute for login jsp page
> > HTH,
> > ----- Original Message -----
> > From: "Andrew Thorell" < drew.thorell@gmail.com>
> > To: "Struts Users Mailing List" <us...@struts.apache.org>
> > Sent: Thursday, May 26, 2005 11:41 AM
> > Subject: Re: Creating a standard page to handle Error 500 
> > 
> > 
> > Where does one find this to modify the doGet method? I've yet to deal
> > with actually modifiying the actual servlet...
> > 
> > Andrew
> > 
> > On 5/26/05, Martin Gainty <mgainty@hotmail.com > wrote:
> > > Inside the StrutsServlet's doGet method
> > >
> > > RequestDispatcher dispatcher = null;
> > >
> > > request.getRequestDispatcher(/err/SQL.jsp);
> > >
> > > try {
> > >
> > > // operation which causes 500 
> > > }
> > > catch (Exception se) {
> > > //forwards to a login.jsp
> > > dispatcher.forward(request, response);
> > > }
> > >
> > > check out http://java.sun.com/j2ee/1.4/docs/api/index.html 
> > > Regards,
> > > Martin-
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org 
> > For additional commands, e-mail: user-help@struts.apache.org
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> > 
> > 
> 
> 
> -- 
> -Dave
> ChaChaNY@Gmail.com 




-- 
-Dave
ChaChaNY@Gmail.com

Re: Creating a standard page to handle Error 500

Posted by David Johnson <ch...@gmail.com>.
Alright, I think I'm thick.
 how would I do that? would I override doGet() and doPost()?
 help! 

 On 5/26/05, Martin Gainty <mg...@hotmail.com> wrote: 
> 
> Andrew-
> can intercept your ActionServlet's doGet or doPost method before process
> method is invoked
> If you want simple follow the instructions for supplying web.xml location
> attribute for login jsp page
> HTH,
> ----- Original Message -----
> From: "Andrew Thorell" <dr...@gmail.com>
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Sent: Thursday, May 26, 2005 11:41 AM
> Subject: Re: Creating a standard page to handle Error 500
> 
> 
> Where does one find this to modify the doGet method? I've yet to deal
> with actually modifiying the actual servlet...
> 
> Andrew
> 
> On 5/26/05, Martin Gainty <mg...@hotmail.com> wrote:
> > Inside the StrutsServlet's doGet method
> >
> > RequestDispatcher dispatcher = null;
> >
> > request.getRequestDispatcher(/err/SQL.jsp);
> >
> > try {
> >
> > // operation which causes 500
> > }
> > catch (Exception se) {
> > //forwards to a login.jsp
> > dispatcher.forward(request, response);
> > }
> >
> > check out http://java.sun.com/j2ee/1.4/docs/api/index.html
> > Regards,
> > Martin-
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


-- 
-Dave
ChaChaNY@Gmail.com

Re: Creating a standard page to handle Error 500

Posted by Martin Gainty <mg...@hotmail.com>.
Andrew-
can intercept your ActionServlet's doGet or doPost method before process 
method is invoked
If you want simple follow the instructions for supplying web.xml location 
attribute for login jsp page
HTH,
----- Original Message ----- 
From: "Andrew Thorell" <dr...@gmail.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Thursday, May 26, 2005 11:41 AM
Subject: Re: Creating a standard page to handle Error 500


Where does one find this to modify the doGet method? I've yet to deal
with actually modifiying the actual servlet...

Andrew

On 5/26/05, Martin Gainty <mg...@hotmail.com> wrote:
> Inside the StrutsServlet's doGet method
>
> RequestDispatcher dispatcher = null;
>
> request.getRequestDispatcher(/err/SQL.jsp);
>
> try {
>
>  //  operation which causes 500
> }
> catch (Exception se) {
> //forwards to a login.jsp
>  dispatcher.forward(request, response);
> }
>
> check out http://java.sun.com/j2ee/1.4/docs/api/index.html
> Regards,
> Martin-

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Creating a standard page to handle Error 500

Posted by David Johnson <ch...@gmail.com>.
I'd like to avoid modifying the struts code if I can....

On 5/26/05, Andrew Thorell <dr...@gmail.com> wrote: 
> 
> Where does one find this to modify the doGet method? I've yet to deal
> with actually modifiying the actual servlet...
> 
> Andrew
> 
> On 5/26/05, Martin Gainty <mg...@hotmail.com> wrote:
> > Inside the StrutsServlet's doGet method
> >
> > RequestDispatcher dispatcher = null;
> >
> > request.getRequestDispatcher(/err/SQL.jsp);
> >
> > try {
> >
> > // operation which causes 500
> > }
> > catch (Exception se) {
> > //forwards to a login.jsp
> > dispatcher.forward(request, response);
> > }
> >
> > check out http://java.sun.com/j2ee/1.4/docs/api/index.html
> > Regards,
> > Martin-
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


-- 
-Dave
ChaChaNY@Gmail.com

Re: Creating a standard page to handle Error 500

Posted by Andrew Thorell <dr...@gmail.com>.
Where does one find this to modify the doGet method? I've yet to deal
with actually modifiying the actual servlet...

Andrew

On 5/26/05, Martin Gainty <mg...@hotmail.com> wrote:
> Inside the StrutsServlet's doGet method
> 
> RequestDispatcher dispatcher = null;
> 
> request.getRequestDispatcher(/err/SQL.jsp);
> 
> try {
> 
>  //  operation which causes 500
> }
> catch (Exception se) {
> //forwards to a login.jsp
>  dispatcher.forward(request, response);
> }
> 
> check out http://java.sun.com/j2ee/1.4/docs/api/index.html
> Regards,
> Martin-

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Creating a standard page to handle Error 500

Posted by Martin Gainty <mg...@hotmail.com>.
Inside the StrutsServlet's doGet method

RequestDispatcher dispatcher = null;

request.getRequestDispatcher(/err/SQL.jsp);

try {

 //  operation which causes 500
}
catch (Exception se) {
//forwards to a login.jsp
 dispatcher.forward(request, response);
}

check out http://java.sun.com/j2ee/1.4/docs/api/index.html
Regards,
Martin-
----- Original Message ----- 
From: "David Johnson" <ch...@gmail.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Thursday, May 26, 2005 10:55 AM
Subject: Creating a standard page to handle Error 500


Hey all
 I recently added the following to my JSP pages to force them not to be
cached:
 <% response.setHeader("Pragma","no-cache");%>
<% response.setHeader("Cache-Control","no-store");%>
<% response.setDateHeader("Expires",-1);%>
 the result is that if the user hits "back" then "reload" they get an error
500. How can I create a page that will handle any error 500 that comes up?
Essentially, I just want to display a message that tells the user to
re-login..
 thoughts?

-- 
-Dave
ChaChaNY@Gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org