You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Chris Davies <c....@gmail.com> on 2007/01/17 16:48:15 UTC

Page Visitor IP Address/Port

Hi,

How is it possible to get the IP address and port of a visitor to a
Page?  I've been trying to figure this out for quite a while now (so I
can insert useful information into log messages), but to no avail.

The closest (crummy) solution I've found is to use a deprecated
function to access the HttpServletRequest and then retrieve the remote
address/port from there.  Obviously this isn't a real solution at all
though!  What's the -correct- way to do this in Tapestry 4.0?


Cheers,

Chris

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


Re: Page Visitor IP Address/Port

Posted by James Carman <ja...@carmanconsulting.com>.
You can also include tapestry-autowire.jar into your application and
have Tap automatically inject it by doing (no annotations necessary):

public abstract HttpServletRequest getServletRequest();

Also, the port is available on the request.  Try getServerPort().


On 1/17/07, Lukas Ruetz <lu...@gmx.at> wrote:
> Hi!
>
> in case you are working with java5+ you can inject the service
> into your page by adding:
>
> @InjectObject("service:tapestry.globals.HttpServletRequest")
> public abstract HttpServletRequest getServletRequest();
>
> you can retrieve the IP-address by:
> String IP = getServletRequest().getRemoteAddr();
>
> I don't know how to get the port. (And also this IP-address
> may only be the one of a proxy/firewall.)
>
> hth,
> lukas
>
>
> Am Mittwoch, 17. Januar 2007 16:48 schrieb Chris Davies:
> > Hi,
> >
> > How is it possible to get the IP address and port of a visitor to a
> > Page?  I've been trying to figure this out for quite a while now (so I
> > can insert useful information into log messages), but to no avail.
> >
> > The closest (crummy) solution I've found is to use a deprecated
> > function to access the HttpServletRequest and then retrieve the remote
> > address/port from there.  Obviously this isn't a real solution at all
> > though!  What's the -correct- way to do this in Tapestry 4.0?
> >
> >
> > Cheers,
> >
> > Chris
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

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


Re: Page Visitor IP Address/Port

Posted by Lukas Ruetz <lu...@gmx.at>.
Hi!

in case you are working with java5+ you can inject the service
into your page by adding:

@InjectObject("service:tapestry.globals.HttpServletRequest")
public abstract HttpServletRequest getServletRequest();

you can retrieve the IP-address by:
String IP = getServletRequest().getRemoteAddr();

I don't know how to get the port. (And also this IP-address
may only be the one of a proxy/firewall.)

hth,
lukas


Am Mittwoch, 17. Januar 2007 16:48 schrieb Chris Davies:
> Hi,
>
> How is it possible to get the IP address and port of a visitor to a
> Page?  I've been trying to figure this out for quite a while now (so I
> can insert useful information into log messages), but to no avail.
>
> The closest (crummy) solution I've found is to use a deprecated
> function to access the HttpServletRequest and then retrieve the remote
> address/port from there.  Obviously this isn't a real solution at all
> though!  What's the -correct- way to do this in Tapestry 4.0?
>
>
> Cheers,
>
> Chris

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


Re: Page Visitor IP Address/Port

Posted by Shing Hing Man <ma...@yahoo.com>.
In Tap4, you can inject HttpServletRequest into a
service or page.
There is some note at the following.

http://lombok.demon.co.uk/tapestry4Demo/Inject.html

Shing



--- Chris Davies <c....@gmail.com> wrote:

> Hi,
> 
> How is it possible to get the IP address and port of
> a visitor to a
> Page?  I've been trying to figure this out for quite
> a while now (so I
> can insert useful information into log messages),
> but to no avail.
> 
> The closest (crummy) solution I've found is to use a
> deprecated
> function to access the HttpServletRequest and then
> retrieve the remote
> address/port from there.  Obviously this isn't a
> real solution at all
> though!  What's the -correct- way to do this in
> Tapestry 4.0?
> 
> 
> Cheers,
> 
> Chris
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail:
> users-help@tapestry.apache.org
> 
> 


Home page :
  http://uk.geocities.com/matmsh/index.html


	
	
		
___________________________________________________________ 
New Yahoo! Mail is the ultimate force in competitive emailing. Find out more at the Yahoo! Mail Championships. Plus: play games and win prizes. 
http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk 

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