Re: Index Pages, 404s and Redirects
Hi, I am trying to display custom 404.html (static html). I have this in my web.xml error-page error-code403/error-code location/error-pages/403.html/location /error-page error-page error-code404/error-code location/error-pages/404.html/location /error-page error-page error-code500/error-code location/error-pages/500.html/location /error-page error-page error-code503/error-code location/error-pages/503.html/location /error-page and when I type an address like http://localhost:8080/myWebApp/help I would expect a 404.html to render as help page does not exist in my web app. Is there anything else to configure in T 5.0.18? Regards, Borut 2009/3/12 Howard Lewis Ship hls...@gmail.com: Tapestry is distinguishing two cases: For page render requests, URL paths that look like actual pages, but do no match an actual page, are handed off to the servlet container. You'll see standard 404 behavior. For component event requests, if the page name is not an actual page you again get 404 behavior. Only if the page name is a known page name but there are other errors (references to components that do not exist) is this treated as a Tapestry error. On Thu, Mar 12, 2009 at 12:41 PM, Geoffrey Wiseman geoffrey.wise...@gmail.com wrote: On Thu, Mar 12, 2009 at 3:15 AM, Peter Stavrinides p.stavrini...@albourne.com wrote: - If you distinguish between requests that are handled within the application context, and outside of the context, i.e.: by the container, then you can devise a more effective solution to handle these errors... Probably - although in this case the way 'index' pages work is creating that issue for me. I could always live with the /start URL I suppose. ;) I don't know much about RequestFilter / Dispatcher in T5 yet; I'll look into those. - Geoffrey -- Geoffrey Wiseman http://www.geoffreywiseman.ca/ -- Howard M. Lewis Ship Creator Apache Tapestry and Apache HiveMind - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Index Pages, 404s and Redirects
Hi Geoffrey, - If you distinguish between requests that are handled within the application context, and outside of the context, i.e.: by the container, then you can devise a more effective solution to handle these errors... - For instance 404 errors cannot be handled in a page (as the page is not found), so you need to move this logic into a RequestFilter or a Dispatcher. - IMHO Tapestry error pages are best used for Runtime Exceptions that occur within the scope of the application, with Java Servlets you have the option to wire in a 404 or other error pages that override the containers defaults will minimal effort, there have been many posts on this in the list. - Tapestry also allows you to customize the handling of the RequestExceptionHandler (so you can easily create a pipeline of error filters) - Pages have a special handler onException(Throwable e) to catch all thrown exceptions in a page so you can deal with these as you please (I personally use this in a base page that all other pages inherit from) so I get great reuse, then I wire them to an exception reporting service. Cheers, Peter - Original Message - From: nillehammer tapestry.nilleham...@winfonet.eu To: Tapestry users users@tapestry.apache.org Sent: Thursday, 12 March, 2009 01:33:37 GMT +02:00 Athens, Beirut, Bucharest, Istanbul Subject: Re: Index Pages, 404s and Redirects Hi Geoffrey, afaik that can only be avoided by the page itsself handling the request. So you would have to set the 404-code in onActivate (HttpServletResponse.setStatus) and probably would want to use Tapestry's Delegate-Component (http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/Delegate.html) to show an error message. Regards, nillehammer Geoffrey Wiseman schrieb: I'd like to use an Index page at the root of my Tapestry application (mostly to get the / URL in links rather than /start), but I'd like to respond to some of those page requests with a 404. I've done this using the pattern described on the last a few times by adding an onActivate(EventContext), which I look at to decide if I want to return an instance of a PageNotFound page. This results in a redirect, which I believe is because this is an event handling-method. I like the redirect-after-post pattern, and most of the time, I'd probably like to keep that as a default. For this particular page, I don't want to use a redirect -- in part because I want the original request to 404, in keeping with the resource-oriented view of HTML. Also, if I make a request for /myNewPage before it's there, and I then implement it and refresh, I want the resulting request to be for /myNewPage not /pagenotfound, which it'll be after the redirect. So is it possible to avoid the redirect here without disabling redirect-after-post for the rest of Tapestry. To be honest, if I could use a start page and get a / link instead of /start that would also solve my problem for the time being -- although I like the ability to provide a custom 404 tapestry page that this will give me. - Geoffrey -- http://www.winfonet.eu - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Index Pages, 404s and Redirects
On Thu, Mar 12, 2009 at 3:15 AM, Peter Stavrinides p.stavrini...@albourne.com wrote: - If you distinguish between requests that are handled within the application context, and outside of the context, i.e.: by the container, then you can devise a more effective solution to handle these errors... Probably - although in this case the way 'index' pages work is creating that issue for me. I could always live with the /start URL I suppose. ;) I don't know much about RequestFilter / Dispatcher in T5 yet; I'll look into those. - Geoffrey -- Geoffrey Wiseman http://www.geoffreywiseman.ca/
Re: Index Pages, 404s and Redirects
Tapestry is distinguishing two cases: For page render requests, URL paths that look like actual pages, but do no match an actual page, are handed off to the servlet container. You'll see standard 404 behavior. For component event requests, if the page name is not an actual page you again get 404 behavior. Only if the page name is a known page name but there are other errors (references to components that do not exist) is this treated as a Tapestry error. On Thu, Mar 12, 2009 at 12:41 PM, Geoffrey Wiseman geoffrey.wise...@gmail.com wrote: On Thu, Mar 12, 2009 at 3:15 AM, Peter Stavrinides p.stavrini...@albourne.com wrote: - If you distinguish between requests that are handled within the application context, and outside of the context, i.e.: by the container, then you can devise a more effective solution to handle these errors... Probably - although in this case the way 'index' pages work is creating that issue for me. I could always live with the /start URL I suppose. ;) I don't know much about RequestFilter / Dispatcher in T5 yet; I'll look into those. - Geoffrey -- Geoffrey Wiseman http://www.geoffreywiseman.ca/ -- Howard M. Lewis Ship Creator Apache Tapestry and Apache HiveMind - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Index Pages, 404s and Redirects
On Wed, Mar 11, 2009 at 7:33 PM, nillehammer tapestry.nilleham...@winfonet.eu wrote: Tapestry's Delegate-Component ( http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/Delegate.html ) to show an error message. I guess I'm still processing this -- how would a delegate component be of help to me here? It's a little awkward to have each index template have a top-level conditional: - if this is a 'not found' then show an error - else show the actual page template I dunno how often I'd be repeating this pattern - perhaps very rarely. If it came up more than a couple times, I'd probably live with the /pagenotfound approach just to avoid the duplication. I suppose I could even use a layout to get around the duplication. Anyway -- ultimately, I think I'm probably fighting against the grain a little too hard and should probably just live with the /start URL and accept that Tapestry owns the URL structure more than I'd necessarily choose. ;) - Geoffrey -- Geoffrey Wiseman http://www.geoffreywiseman.ca/
Index Pages, 404s and Redirects
I'd like to use an Index page at the root of my Tapestry application (mostly to get the / URL in links rather than /start), but I'd like to respond to some of those page requests with a 404. I've done this using the pattern described on the last a few times by adding an onActivate(EventContext), which I look at to decide if I want to return an instance of a PageNotFound page. This results in a redirect, which I believe is because this is an event handling-method. I like the redirect-after-post pattern, and most of the time, I'd probably like to keep that as a default. For this particular page, I don't want to use a redirect -- in part because I want the original request to 404, in keeping with the resource-oriented view of HTML. Also, if I make a request for /myNewPage before it's there, and I then implement it and refresh, I want the resulting request to be for /myNewPage not /pagenotfound, which it'll be after the redirect. So is it possible to avoid the redirect here without disabling redirect-after-post for the rest of Tapestry. To be honest, if I could use a start page and get a / link instead of /start that would also solve my problem for the time being -- although I like the ability to provide a custom 404 tapestry page that this will give me. - Geoffrey -- Geoffrey Wiseman http://www.geoffreywiseman.ca/
Re: Index Pages, 404s and Redirects
Hi Geoffrey, afaik that can only be avoided by the page itsself handling the request. So you would have to set the 404-code in onActivate (HttpServletResponse.setStatus) and probably would want to use Tapestry's Delegate-Component (http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/Delegate.html) to show an error message. Regards, nillehammer Geoffrey Wiseman schrieb: I'd like to use an Index page at the root of my Tapestry application (mostly to get the / URL in links rather than /start), but I'd like to respond to some of those page requests with a 404. I've done this using the pattern described on the last a few times by adding an onActivate(EventContext), which I look at to decide if I want to return an instance of a PageNotFound page. This results in a redirect, which I believe is because this is an event handling-method. I like the redirect-after-post pattern, and most of the time, I'd probably like to keep that as a default. For this particular page, I don't want to use a redirect -- in part because I want the original request to 404, in keeping with the resource-oriented view of HTML. Also, if I make a request for /myNewPage before it's there, and I then implement it and refresh, I want the resulting request to be for /myNewPage not /pagenotfound, which it'll be after the redirect. So is it possible to avoid the redirect here without disabling redirect-after-post for the rest of Tapestry. To be honest, if I could use a start page and get a / link instead of /start that would also solve my problem for the time being -- although I like the ability to provide a custom 404 tapestry page that this will give me. - Geoffrey -- http://www.winfonet.eu - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org