You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Stefan Becker <zo...@gmx.de> on 2008/11/27 16:43:11 UTC
getting ip address from URIRequestTargetUrlCodingStrategy
hi,
in my webapp i want to serve files from the filesystem to the user. so i coded something like this:
mount(new URIRequestTargetUrlCodingStrategy("/files") {
@Override
public IRequestTarget decode(RequestParameters requestParameters) {
final String fileId = getURI(requestParameters);
... read some info from database and build a fileInfo object ...
/* Get file for this instance */
return new ResourceStreamRequestTarget(new AnonFileResourceStream(fileInfo));
}
});
(AnonFileResourceStream extends AbstractResourceStream)
all requests to "/files" use the remaining part of the request to ask the database where the real file is located and stream it to the client.
the problem is that i need to know from which ip address the request was made. i need the WebRequest object for this request to get some http headers.
is this possible or is there another way to get hold of this information?
thanx alot
stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: getting ip address from URIRequestTargetUrlCodingStrategy
Posted by Stefan Becker <zo...@gmx.de>.
great!
i didn't think it was THAT easy.
i spend a whole day to find an answer to this, but was looking at the wrong places.
thank you
-------- Original-Nachricht --------
> Datum: Thu, 27 Nov 2008 11:06:31 -0500
> Von: Michael O\'Cleirigh <mi...@rivulet.ca>
> An: users@wicket.apache.org
> Betreff: Re: getting ip address from URIRequestTargetUrlCodingStrategy
> Hi Stefan,
>
> You can get the IP address that sent the request like this:
>
> WebRequest wr = (WebRequest) RequestCycle.get().getRequest();
>
> String originatingIPAddress = wr.getHttpServletRequest().getRemoteHost();
>
> You can probably place it directly in the decode(...) method of your url
> coding strategy.
>
> Regards,
>
> Mike
>
> > in my webapp i want to serve files from the filesystem to the user. so i
> coded something like this:
> >
> > mount(new URIRequestTargetUrlCodingStrategy("/files") {
> > @Override
> > public IRequestTarget decode(RequestParameters
> requestParameters) {
> >
> > final String fileId = getURI(requestParameters);
> >
> > ... read some info from database and build a fileInfo object ...
> >
> > /* Get file for this instance */
> > return new ResourceStreamRequestTarget(new
> AnonFileResourceStream(fileInfo));
> > }
> > });
> >
> > (AnonFileResourceStream extends AbstractResourceStream)
> >
> > all requests to "/files" use the remaining part of the request to ask
> the database where the real file is located and stream it to the client.
> > the problem is that i need to know from which ip address the request was
> made. i need the WebRequest object for this request to get some http
> headers.
> > is this possible or is there another way to get hold of this
> information?
> >
> >
> > thanx alot
> > stefan
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: getting ip address from URIRequestTargetUrlCodingStrategy
Posted by Michael O'Cleirigh <mi...@rivulet.ca>.
Hi Stefan,
You can get the IP address that sent the request like this:
WebRequest wr = (WebRequest) RequestCycle.get().getRequest();
String originatingIPAddress = wr.getHttpServletRequest().getRemoteHost();
You can probably place it directly in the decode(...) method of your url
coding strategy.
Regards,
Mike
> in my webapp i want to serve files from the filesystem to the user. so i coded something like this:
>
> mount(new URIRequestTargetUrlCodingStrategy("/files") {
> @Override
> public IRequestTarget decode(RequestParameters requestParameters) {
>
> final String fileId = getURI(requestParameters);
>
> ... read some info from database and build a fileInfo object ...
>
> /* Get file for this instance */
> return new ResourceStreamRequestTarget(new AnonFileResourceStream(fileInfo));
> }
> });
>
> (AnonFileResourceStream extends AbstractResourceStream)
>
> all requests to "/files" use the remaining part of the request to ask the database where the real file is located and stream it to the client.
> the problem is that i need to know from which ip address the request was made. i need the WebRequest object for this request to get some http headers.
> is this possible or is there another way to get hold of this information?
>
>
> thanx alot
> stefan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org