tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Lucia" <timlu...@yahoo.com>
Subject RE: Handling 404 thru web.xml
Date Wed, 10 May 2006 17:20:44 GMT
Workaround?  You speak as if it is broken, when it is behaving as it should.

If you look at the stack while inside the error page, you will see your
chain of filters on the stack.  They've already done the request side and
are now waiting for chain.doFilter(request, response) to return.

If you are looking to redirect all 404/not found pages to your default page,
then you can do that (using Struts) by marking portal.do as the default
mapping.  And, you can have a home/default action with a <forward
name="home" path="/portal.do" redirect="true"/>.  This action can be as
simple as 

<action path="/NotFound" type="org.apache.struts.actions.ForwardAction"
parameter="home"/>

And then, in your web.xml, use /NotFound as the target of your error page.

At any rate, setting the 'redirect="true"' attribute on the forward will
cause the struts controller to sendRedirect() instead of forward().

Tim

-----Original Message-----
From: MC Moisei [mailto:mcmoisei@hotmail.com] 
Sent: Wednesday, May 10, 2006 12:27 PM
To: users@tomcat.apache.org
Subject: RE: Handling 404 thru web.xml

Thanks Tim!

Yeah, that's pretty much what I figured out but is there a workaround for 
that ?

MC




>From: "Tim Lucia" <timlucia@yahoo.com>
>Reply-To: "Tomcat Users List" <users@tomcat.apache.org>
>To: "'Tomcat Users List'" <users@tomcat.apache.org>
>Subject: RE: Handling 404 thru web.xml
>Date: Wed, 10 May 2006 12:12:17 -0400
>
>A redirect would change the status code returned to the user agent.  It 
>does
>not go through the filters because it is forwarded, and as such is part of
>the same request, not a new request.
>
>
>Tim
>
>-----Original Message-----
>From: MC Moisei [mailto:mcmoisei@hotmail.com]
>Sent: Wednesday, May 10, 2006 11:59 AM
>To: users@tomcat.apache.org
>Subject: Handling 404 thru web.xml
>
>Hi,
>
>Do you know of any issue involving error handling in tomcat (5.5.9) ?
>
>Here's the deal. I defined in my web.xml the following entry
>
><error-page>
>      <error-code>404</error-code>
>     <location>/portal.do</location>
></error-page>
>
>When I call, say portal1.do, a page that doesn't exists I get a forward to
>the portal.do the thing with the forward is seems that it doesn't go thru
>the application filters again. And why this is not a redirect ? The browser
>address stays portal1.do instead of portal.do...
>
>Here how the stack trace looks when the portal1.do is called ( this is
>normal, check the second trace)
>
>
>Thread [http-8585-Processor24] (Suspended)
>	CustomServlet.service(ServletRequest, ServletResponse) line: 104
>	ApplicationFilterChain.internalDoFilter(ServletRequest,
>ServletResponse)
>line: 252
>	ApplicationFilterChain.doFilter(ServletRequest, ServletResponse)
>line: 173
>	FilterSecurityInterceptor.invoke(FilterInvocation) line: 84
>	SecurityEnforcementFilter.doFilter(ServletRequest, ServletResponse,
>FilterChain) line: 182
>	FilterToBeanProxy.doFilter(ServletRequest, ServletResponse,
>FilterChain)
>line: 125
>	ApplicationFilterChain.internalDoFilter(ServletRequest,
>ServletResponse)
>line: 202
>	ApplicationFilterChain.doFilter(ServletRequest, ServletResponse)
>line: 173
>
>CustomAuthenticationProcessingFilter(AbstractProcessingFilter).doFilter(Ser
v
>letRequest,
>ServletResponse, FilterChain) line: 305
>	FilterToBeanProxy.doFilter(ServletRequest, ServletResponse,
>FilterChain)
>line: 125
>	ApplicationFilterChain.internalDoFilter(ServletRequest,
>ServletResponse)
>line: 202
>	ApplicationFilterChain.doFilter(ServletRequest, ServletResponse)
>line: 173
>	HttpSessionContextIntegrationFilter.doFilter(ServletRequest,
>ServletResponse, FilterChain) line: 225
>	FilterToBeanProxy.doFilter(ServletRequest, ServletResponse,
>FilterChain)
>line: 125
>	ApplicationFilterChain.internalDoFilter(ServletRequest,
>ServletResponse)
>line: 202
>	ApplicationFilterChain.doFilter(ServletRequest, ServletResponse)
>line: 173
>	ContentReaderFilter.doFilter(ServletRequest, ServletResponse,
>FilterChain)
>line: 171
>	ApplicationFilterChain.internalDoFilter(ServletRequest,
>ServletResponse)
>line: 202
>	ApplicationFilterChain.doFilter(ServletRequest, ServletResponse)
>line: 173
>	RequestUtilsFilter.doFilter(ServletRequest, ServletResponse,
>FilterChain)
>line: 114
>	ApplicationFilterChain.internalDoFilter(ServletRequest,
>ServletResponse)
>line: 202
>	ApplicationFilterChain.doFilter(ServletRequest, ServletResponse)
>line: 173
>	StandardWrapperValve.invoke(Request, Response) line: 213
>	StandardContextValve.invoke(Request, Response) line: 178
>	StandardHostValve.invoke(Request, Response) line: 126
>	ErrorReportValve.invoke(Request, Response) line: 105
>	StandardEngineValve.invoke(Request, Response) line: 107
>	CoyoteAdapter.service(Request, Response) line: 148
>	Http11Processor.process(InputStream, OutputStream) line: 856
>
>Http11Protocol$Http11ConnectionHandler.processConnection(TcpConnection,
>Object[]) line: 744
>	PoolTcpEndpoint.processSocket(Socket, TcpConnection, Object[]) line:
>527
>	LeaderFollowerWorkerThread.runIt(Object[]) line: 80
>	ThreadPool$ControlRunnable.run() line: 684
>	ThreadWithAttributes(Thread).run() line: 595
>
>
>
>Here how the stack trace looks on the forward to /portal.do after 404 was
>intercepted
>
>
>
>Thread [http-8585-Processor24] (Suspended (breakpoint at line 74 in
>CustomServlet))
>	CustomServlet.service(ServletRequest, ServletResponse) line: 74
>	ApplicationFilterChain.internalDoFilter(ServletRequest,
>ServletResponse)
>line: 252
>	ApplicationFilterChain.doFilter(ServletRequest, ServletResponse)
>line: 173
>	ApplicationDispatcher.invoke(ServletRequest, ServletResponse) line:
>672
>	ApplicationDispatcher.processRequest(ServletRequest,
>ServletResponse) line:
>465
>	ApplicationDispatcher.doForward(ServletRequest, ServletResponse)
>line: 398
>	ApplicationDispatcher.forward(ServletRequest, ServletResponse) line:
>301
>	StandardHostValve.custom(Request, Response, ErrorPage) line: 362
>	StandardHostValve.status(Request, Response) line: 283
>	StandardHostValve.invoke(Request, Response) line: 136
>	ErrorReportValve.invoke(Request, Response) line: 105
>	StandardEngineValve.invoke(Request, Response) line: 107
>	CoyoteAdapter.service(Request, Response) line: 148
>	Http11Processor.process(InputStream, OutputStream) line: 856
>
>Http11Protocol$Http11ConnectionHandler.processConnection(TcpConnection,
>Object[]) line: 744
>	PoolTcpEndpoint.processSocket(Socket, TcpConnection, Object[]) line:
>527
>	LeaderFollowerWorkerThread.runIt(Object[]) line: 80
>	ThreadPool$ControlRunnable.run() line: 684
>	ThreadWithAttributes(Thread).run() line: 595
>
>
>Any idea will be greatly appreciated.
>
>MC
>
>Ps.
>On weblogic the error handling triggers a redirect and the above problem is
>not present.
>
>
>
>---------------------------------------------------------------------
>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
>



---------------------------------------------------------------------
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


Mime
View raw message