Obtain IP address from Contexts

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Obtain IP address from Contexts

bsanders1979
When a service is called, is it possible to obtain the remote address
from either the DispatchContext or the Context?

Reply | Threaded
Open this post in threaded view
|

Re: Obtain IP address from Contexts

Jacques Le Roux
Administrator
You have to use HttpServletRequest for that. So it depends if you have one in your context.
http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/ServletRequest.html#getRemoteAddr()

If the service is used in a widget screen context you should be able to get one.
http://docs.ofbiz.org/x/axE
From a job poller I guess not

Jacques

From: "Sanders, Brian" <[hidden email]>
When a service is called, is it possible to obtain the remote address
from either the DispatchContext or the Context?



Reply | Threaded
Open this post in threaded view
|

Re: Obtain IP address from Contexts

Kumaraswamy nandipati
Hi Sanders,

Its a basic concept. getting the ip address is depends upon the Request
object scope. By using request.getRemoteAddr() will give the request IP
address.


On Fri, Feb 27, 2009 at 10:33 PM, Jacques Le Roux <
[hidden email]> wrote:

> You have to use HttpServletRequest for that. So it depends if you have one
> in your context.
> http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/ServletRequest.html#getRemoteAddr()<http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/ServletRequest.html#getRemoteAddr%28%29>
>
> If the service is used in a widget screen context you should be able to get
> one. http://docs.ofbiz.org/x/axE
> From a job poller I guess not
>
> Jacques
>
> From: "Sanders, Brian" <[hidden email]>
>
> When a service is called, is it possible to obtain the remote address
> from either the DispatchContext or the Context?
>
>
>
>


--
Thanks,
Kumaraswamy.N
91-9866805250.
Reply | Threaded
Open this post in threaded view
|

RE: Obtain IP address from Contexts

bsanders1979
Thanks for the responses. I know how to obtain the IP address in, say,
the FTL template (already asked about that). I tried to find a request
object in the DispatchContext object to no avail. I was thinking that it
could be buried somewhere deeper and I'm really trying to figure out the
path to it if it is available in either the DispatchContext, or the
Context which is actually a Map.

-----Original Message-----
From: Kumaraswamy nandipati [mailto:[hidden email]]
Sent: Saturday, February 28, 2009 8:30 PM
To: [hidden email]; Jacques Le Roux
Subject: Re: Obtain IP address from Contexts

Hi Sanders,

Its a basic concept. getting the ip address is depends upon the Request
object scope. By using request.getRemoteAddr() will give the request IP
address.


On Fri, Feb 27, 2009 at 10:33 PM, Jacques Le Roux <
[hidden email]> wrote:

> You have to use HttpServletRequest for that. So it depends if you have
one
> in your context.
>
http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/ServletRe
quest.html#getRemoteAddr()<http://java.sun.com/products/servlet/2.2/java
doc/javax/servlet/ServletRequest.html#getRemoteAddr%28%29>
>
> If the service is used in a widget screen context you should be able
to get

> one. http://docs.ofbiz.org/x/axE
> From a job poller I guess not
>
> Jacques
>
> From: "Sanders, Brian" <[hidden email]>
>
> When a service is called, is it possible to obtain the remote address
> from either the DispatchContext or the Context?
>
>
>
>


--
Thanks,
Kumaraswamy.N
91-9866805250.