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 [EMAIL PROTECTED]
Re: Creating a standard page to handle Error 500
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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Creating a standard page to handle Error 500
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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Creating a standard page to handle Error 500
,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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Creating a standard page to handle Error 500
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 [EMAIL PROTECTED] To: Struts Users Mailing List user@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 [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Creating a standard page to handle Error 500
I'd like to avoid modifying the struts code if I can On 5/26/05, Andrew Thorell [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- -Dave [EMAIL PROTECTED]
Re: Creating a standard page to handle Error 500
Alright, I think I'm thick. how would I do that? would I override doGet() and doPost()? help! On 5/26/05, Martin Gainty [EMAIL PROTECTED] 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 [EMAIL PROTECTED] To: Struts Users Mailing List user@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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- -Dave [EMAIL PROTECTED]
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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] To: Struts Users Mailing List user@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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- -Dave [EMAIL PROTECTED] -- -Dave [EMAIL PROTECTED]
Re: Creating a standard page to handle Error 500
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 [EMAIL PROTECTED] To: Struts Users Mailing List user@struts.apache.org; Martin Gainty [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] To: Struts Users Mailing List user@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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- -Dave [EMAIL PROTECTED] -- -Dave [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]