cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Prinston <t...@yahoo.com.tw>
Subject Re: Problem: When invoke HttpServletRequet.getRemoteAddr(), it return the old client IP...
Date Fri, 25 Jan 2008 09:58:52 GMT

Hi Willem:

Your question point the wrong thing I made!
I declared both the WebServiceContext and the MessageContext objects as
global variables.
But the MessageContext object must not be a global variable, it should be a
local variable in method.
A MessageContext object is attached to each request message from client.

I had made a really stupid thing!

Thank you for your opinions. :)


Prinston


willem.jiang wrote:
> 
> Hi
> 
> Cam you show me how can you get the ctx object ?
> If the ctx that you use is get from WebServiceContext which has a thread 
> local variable , it is injected to CXF for getting the message context.
> I don't know if this can relate to the issue that you met.
> 
> 
> Willem.
> 
> Prinston wrote:
>> Dears:
>>
>> I put some code into a web method to get client IP.
>>
>> ex:
>> public boolean recordIP() {
>> 	try {
>> 		debugInfo.append(" ").append(
>> 		((HttpServletRequest) ctx
>> 		.get(AbstractHTTPDestination.HTTP_REQUEST))
>> 		.getRemoteAddr());
>> 		return true;
>> 	} catch (Exception e) {
>> 		return false;
>> 	}
>> }
>>
>> When the first client from IP1 call this method, it record the IP1
>> address.
>> No problem.
>> But then the second client from IP2 call this method, it "SOMETIMES"
>> still
>> record the IP1 address (the old one).
>> This situation might occur in some condition (ex: after browsing some
>> other
>> jsp page in other web ap in the same web instance). I am not sure what
>> condition may cause this problem exactly.
>>
>> Has anyone got this problem before? Thanks!
>>
>> My AP configuration: Apache 2.2.24+Tomcat5.5.20(using AJP13
>> connector)+CXF2.0.1
>>   
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem%3A-When-invoke-HttpServletRequet.getRemoteAddr%28%29%2C-it-return-the-old-client-IP...-tp15082583p15084603.html
Sent from the cxf-user mailing list archive at Nabble.com.


Mime
View raw message