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:
javax.servlet
servlet-api
2.5
provided
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 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
> 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