The valve intercepts the request before it gets to any web applications so the
settings in conf/web.xml or in an applications individual WEB-INF/web.xml will
not get used.

You have a couple of options:
- Write you own valve (copy, paste, add a few lines and you should be done)
- Write a servlet filter (a bit more work but portable and you can apply it at
the web app level)

Mark 

> -----Original Message-----
> From: Robert Baruch [mailto:[EMAIL PROTECTED] 
> Sent: Monday, October 24, 2005 6:09 PM
> To: users@tomcat.apache.org
> Subject: 4.1.31: RemoteAddrValve and custom 403 page
> 
> Hi all,
> 
> I have a default install of 4.1.31 on Windows. I have two problems.
> 
> First problem is, I want to have a custom 403 Forbidden page and a  
> 404 Page Not Found. So, in conf/web.xml, I added this after the  
> welcome-file-list block:
> 
> <error-page>
>    <error-code>403</error-code>
>    <location>/file_not_found.jsp</location>
> </error-page>
> 
> <error-page>
>    <error-code>404</error-code>
>    <location>/file_not_found.jsp</location>
> </error-page>
> 
> 
> I have also put file_not_found.jsp into webbaps/ROOT. It just looks  
> like this:
> 
> <% response.setStatus(200); %>
> <html>
> <body>
> There was a problem with your request, please try again
> </body>
> </html>
> 
> 
> Before anyone gets excited, my company's security policy requires  
> that error pages be sent using a 200 status code. Don't even get me  
> started :(
> 
> 
> Anyway, it works great if I try to access a page which 
> doesn't exist,  
> I get my custom page.
> 
> Now, I need to restrict Tomcat to respond only to requests that come  
> internally from the same machine. Thus, in server.xml I put this  
> inside the standalone engine config:
> 
> (existing)<Engine name="Standalone" defaultHost="localhost" debug="0">
> (existing)
> (added)    <Valve  
> className="org.apache.catalina.valves.RemoteAddrValve"  
> allow="127.0.0.1"/>
> 
> 
> Problem #1: Tomcat properly rejects any access from outside the  
> machine, but Tomcat is only sending a blank page with a 403 
> status. I  
> would have expected my error-page block to intercept 403's and turn  
> them into whatever I wanted.
> 
> Problem #2: How can I get it so that any 30x, 40x, or 50x error that  
> I chose will result in my custom error page, regardless of where  
> those errors come from?
> 
> Thanks,
> 
> --Rob
> 
> 
> 
> ---------------------------------------------------------------------
> 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]

Reply via email to