tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "bognár, attila" <attila.bog...@netalfa.com>
Subject Re: x-forwarded-for
Date Sun, 20 Apr 2003 08:16:30 GMT
so nobody should write a custom valve? and what about the casting in 
ErrorReportValve?

attila


Tim Funk írta:
> Never use any org.apache.catalina class directly. They may change 
> "without notice".
> 
> The accesslog valve might already do what you need with this:
> %{x-forwarded-for}i
> 
> Also some other fun tricks:
> %{xxx}i  xxx is the name of the incoming header
> %{xxx}c  xxx is the name of a specific cookie
> %{xxx}r  xxx is an attribute in the ServletRequest
> %{xxx}s  xxx is an attribute in the HttpSession
> 
> -Tim
> 
> bognár, attila wrote:
> 
>> hi,
>>
>> A question: why are 
>> org.apache.catalina.{RequestWrapper|HttpRequestWrapper} deprecated and 
>> not implemented?
>>
>>
>> I implemented a filter which works fine. But I want that 
>> AccessLogValve also uses the result of X-Forwarded-For extraction, so 
>> I made a Valve, which could be called before AccessLogValve.
>>
>> My valve is called RPAFValve and does not implement Lyfecycle
>>
>> When I start tomcat:
>>
>> ServerLifecycleListener: createMBeans: MBeanException
>> java.lang.Exception: ManagedBean is not found with RPAFValve
>>         at 
>> org.apache.catalina.mbeans.MBeanUtils.createMBean(MBeanUtils.java:782)
>>         at 
>> org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:644)

>>
>>         at 
>> org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:590)

>>
>>         at 
>> org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:783)

>>
>>         at 
>> org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:751)

>>
>>         at 
>> org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:339)

>>
>>         at 
>> org.apache.catalina.mbeans.ServerLifecycleListener.lifecycleEvent(ServerLifecycleListener.java:206)

>>
>>         at 
>> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:166)

>>
>>         at 
>> org.apache.catalina.core.StandardServer.start(StandardServer.java:2182)
>>         at org.apache.catalina.startup.Catalina.start(Catalina.java:512)
>>         at 
>> org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
>>         at 
>> org.apache.catalina.startup.Catalina.process(Catalina.java:180)
>>         at java.lang.reflect.Method.invoke(Native Method)
>>         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)
>>
>>
>> on a site I found a valve where they say that mbeans-descriptor.xml 
>> from catalina.jar should be updated. is there a possibility to avoid 
>> this?
>>
>> my valve:
>>
>> RPAF is an object that extracts the header and creates a wrapper, 
>> RPAFHttpRequest is an org.apache.Catalina.HttpRequest wrapper which 
>> gives back the HttpServletRequest given back by RPAF.
>>
>> public class RPAFValve extends org.apache.catalina.valves.ValveBase
>> {
>>     protected boolean active = true;
>>
>>     protected RPAF rpaf = new RPAF();
>>
>>     static
>>     {
>>         info = "com.netalfa.tomcat.valves.RPAFValve/0.1";
>>     }
>>
>>     public RPAFValve()
>>     {
>>     }
>>
>>     public void invoke(Request request, Response response, 
>> ValveContext valveContext)
>>         throws java.io.IOException, javax.servlet.ServletException
>>     {
>>         if (active)
>>         {
>>             HttpServletRequest req1 = 
>> (HttpServletRequest)request.getRequest();
>>             HttpServletRequest req2 = rpaf.rpafRequest(req1);
>>             if (req1 != req2)
>>                 request = new RPAFHttpRequest((HttpRequest)request, 
>> req2);
>>         }
>>         valveContext.invokeNext(request, response);
>>     }
>>
>>
>>     public void setActive (boolean active)
>>     {
>>         this.active = active;
>>     }
>>
>>     public boolean isActive ()
>>     {
>>         return active;
>>     }
>>
>>     public void setProxy (String proxy)
>>     {
>>         rpaf.setProxy(proxy);
>>     }
>>
>>     public String getProxy ()
>>     {
>>         return rpaf.getProxy();
>>     }
>> }
>>
>> thanks,
>>
>> attila
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message