The Tapestry-related answer is that Tapestry provides an injectable
service, Request [1],  that is a "shadow" of the current thread's
HTTPServletRequest [2]:

import org.apache.tapestry5.services.Request;
@Inject
Request request;
public String getRemoteHost() {
    return request.getRemoteHost();
}
public int getLocalPort() {
    return request.getLocalPort();
}

but since Request only has a subset of the properties that
HTTPServletRequest offers, for many purposes you'll need to directly
access HTTPServletRequest directly, which you can also inject:

import javax.servlet.http.HttpServletRequest;
@Inject
private HttpServletRequest httpServletRequest;
public String getRemoteAddr() {
    return httpServletRequest.getRemoteAddr();
}

Be sure the servlet API is on your classpath. If using Maven, for example:

<!-- Provided by the servlet container, but sometimes referenced in
the application code. -->
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.5</version>
    <scope>provided</scope>
</dependency>

Also note that if you have a separate web server (e.g. Apache HTTP)
in front of your app server, it may or may not be configured to pass
the correct client information to the app.

[1] 
http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/Request.html
[2] 
http://docs.oracle.com/javaee/5/api/javax/servlet/http/HttpServletRequest.html

On Sat, Mar 16, 2013 at 5:32 PM, Ivan Khalopik <ikhalo...@gmail.com> wrote:
> It is not a tapestry question.
>
> http://docs.oracle.com/javaee/5/api/javax/servlet/ServletRequest.html
>
> On Sat, Mar 16, 2013 at 11:42 PM, nhhockeyplayer nashua
> <nhhockeypla...@hotmail.com> wrote:
>> Folks,
>>
>> I want to track my users. Is there a way to get host:port and ip ?
>>
>> Best regards
>> and thanks... KEN
>
>
>
> --
> BR
> Ivan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to