tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Elli Albek" <e...@sustainlane.com>
Subject RE: Cannot set remote address in valve (Tomcat 5.5)
Date Fri, 02 Oct 2009 08:41:46 GMT
Yes, the remoteAddress member is protected. So you can only access it if you
put your class in the same package.

I thought of doing it like a filter (wrapping) but it does not look like a
workable solution in this case.

1. The request class is final (which basically ends the discussion :)
2. This class is not a simple placeholder for values or a wrapper. It is a
heavy object that is recycled at the end of the request processing and
contains a lot of code. I don't have any intention to get into Tomcat
internal resource management and object recycling code. It seems pretty
complicated. I don't think you can just replace a server object as you can
do with a servlet request wrapper that is basically a proxy.

E

-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net] 
Sent: Thursday, October 01, 2009 8:43 AM
To: Tomcat Users List
Subject: Re: Cannot set remote address in valve (Tomcat 5.5)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Elli,

On 9/27/2009 12:19 AM, Elli Albek wrote:
>     public void setRemoteAddr(String remoteAddr) {
>         // Not used
>     }
> 
> The variable is protected so I cannot access it directly from my code.

What variable? The remoteAddress member?

> Is there any way to implement this Valve?

Wrap the request object in a subclass that you write. This will allow
you to either

a) Override the setRemoteAddress method to return whatever you want
b) Explicitly set the remoteAddress member to whatever you want

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrEzh0ACgkQ9CaO5/Lv0PAmqwCeJpvyj0k9Ze+QKLkyRNqfpvzp
nccAniLAI/gdF65qw9EF6HLsXqcSgacP
=S2JM
-----END PGP SIGNATURE-----

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