Re: Throwing a 404?
You can use the HttpServletResponse.sendError() method to send any kind of return code you want (including 404). Dave From: Adam Sherman [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts User [EMAIL PROTECTED] Subject: Throwing a 404? Date: Wed, 02 Oct 2002 14:54:58 -0400 I'm building an Action to handle generic requests for pages that are defined as tiles. Basically, I want all requests for *.html to hit this action, which will figure out the definition name and call it. If the page doesn't exists, how can I throw a 404? Thanks, A. -- Adam Sherman Software Developer Teach and Travel Inc. +1.613.241.3103 -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] _ Join the worlds largest e-mail service with MSN Hotmail. http://www.hotmail.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Throwing a 404?
David Graham wrote: You can use the HttpServletResponse.sendError() method to send any kind of return code you want (including 404). Yes, I just found that in the API docs. Is this the Right Way to do it? Or should I be somehow wrapping the error in an Exception, or forwarding to a View component? I'm also looking for some Best Practices advice. Thanks, A. -- Adam Sherman Software Developer Teach and Travel Inc. +1.613.241.3103 -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Throwing a 404?
I've configured my container to display a page called 404.jsp whenever a page in my app is not found. You could either use the sendError method which will probably display an ugly 404 page or you could forward to your custom 404 page. Dave From: Adam Sherman [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: Re: Throwing a 404? Date: Wed, 02 Oct 2002 15:07:09 -0400 David Graham wrote: You can use the HttpServletResponse.sendError() method to send any kind of return code you want (including 404). Yes, I just found that in the API docs. Is this the Right Way to do it? Or should I be somehow wrapping the error in an Exception, or forwarding to a View component? I'm also looking for some Best Practices advice. Thanks, A. -- Adam Sherman Software Developer Teach and Travel Inc. +1.613.241.3103 -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] _ Join the worlds largest e-mail service with MSN Hotmail. http://www.hotmail.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Throwing a 404?
David Graham wrote: I've configured my container to display a page called 404.jsp whenever a page in my app is not found. You could either use the sendError method which will probably display an ugly 404 page or you could forward to your custom 404 page. That would probably do it. After doing sendError(404), where would I forward to? Or will the request now contain a 404, but I still need to show a page? Thanks for your help, A. -- Adam Sherman Software Developer Teach and Travel Inc. +1.613.241.3103 -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Throwing a 404?
I believe after you call that method you can't forward to anything. You might try it though. The user will see some 404 message. If you want the 404 page to look like your app you should forward to your custom 404 page and forget about the sendError. Dave From: Adam Sherman [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: Re: Throwing a 404? Date: Wed, 02 Oct 2002 15:14:29 -0400 David Graham wrote: I've configured my container to display a page called 404.jsp whenever a page in my app is not found. You could either use the sendError method which will probably display an ugly 404 page or you could forward to your custom 404 page. That would probably do it. After doing sendError(404), where would I forward to? Or will the request now contain a 404, but I still need to show a page? Thanks for your help, A. -- Adam Sherman Software Developer Teach and Travel Inc. +1.613.241.3103 -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Throwing a 404?
David Graham wrote: I believe after you call that method you can't forward to anything. You might try it though. The user will see some 404 message. If you want the 404 page to look like your app you should forward to your custom 404 page and forget about the sendError. Wouldn't this cause the browser to not recognize the 404? This would undoubtedly be a Bad Thing for spiders, etc. Can I forward to a custom error page, and have the page set the appropriate header? Thanks, A. P.S. Please excuse my newbieness. (-: -- Adam Sherman Software Developer Teach and Travel Inc. +1.613.241.3103 -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Throwing a 404?
Just my two cents: Use HttpServletRequest:sendError rather than redirecting to a special page, and have your webserver configuration redirect the user to a pretty page if that's necessary. Rationale: In every website that I've put up, someone somewhere has eventually wanted to see a count of the number of the various errors that our webserver has served up (usually at least the counts for 404 and 500.) If you magically redirect to a new page in the action, it can be really hard to track how many times that occurs. It's much cleaner to have them actually appear in the logs. -Peter On Wed, 2002-10-02 at 15:07, Adam Sherman wrote: David Graham wrote: You can use the HttpServletResponse.sendError() method to send any kind of return code you want (including 404). Yes, I just found that in the API docs. Is this the Right Way to do it? Or should I be somehow wrapping the error in an Exception, or forwarding to a View component? I'm also looking for some Best Practices advice. Thanks, A. -- Adam Sherman Software Developer Teach and Travel Inc. +1.613.241.3103 -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Throwing a 404?
Adam Sherman wrote: Wouldn't this cause the browser to not recognize the 404? This would undoubtedly be a Bad Thing for spiders, etc. And Peter Hamlen brings up a good point, what about the logs? A. -- Adam Sherman Software Developer Teach and Travel Inc. +1.613.241.3103 -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Throwing a 404?
No, when you call the sendError method a valid 404 response is sent back to the browser. Try it out :-). Dave From: Adam Sherman [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: Re: Throwing a 404? Date: Wed, 02 Oct 2002 15:27:38 -0400 David Graham wrote: I believe after you call that method you can't forward to anything. You might try it though. The user will see some 404 message. If you want the 404 page to look like your app you should forward to your custom 404 page and forget about the sendError. Wouldn't this cause the browser to not recognize the 404? This would undoubtedly be a Bad Thing for spiders, etc. Can I forward to a custom error page, and have the page set the appropriate header? Thanks, A. P.S. Please excuse my newbieness. (-: -- Adam Sherman Software Developer Teach and Travel Inc. +1.613.241.3103 -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] _ Join the worlds largest e-mail service with MSN Hotmail. http://www.hotmail.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]