views:

1062

answers:

3

Due to browser restrictions I need to use a proxy to make an openlayers map work.

The OpenLayers.ProxyHost javascript object handles the generation of a URL like:

http://webhost:8080/app/proxy/?url=http://WFS_server/options/...

Some of the requests will be GET's and others will be POST's.

I've written a Servlet Filter that will recieve the request and then use the commons HttpClient to dispatch it to the host specified by the 'url' parameter.

Everything works for GET but I am having difficulties getting the 'url' parameter value for POST's.

According to the javadoc I see in eclipse it should be request.getRequestURI() but this is only returning the value of the post minus the url parameter value (i.e. http://webhost:8080/app/proxy/)

In fact the only way I can get the data is to call the request.toString() method and parse out the url.

I'm deploying into a Jetty 6.1.11 server so I'm wondering if this might be a Jetty bug or if I'm missing something on where to get this detail?

+1  A: 

That's because the getRequestURI is giving you exactly what you asked for -- the URI.

In your post, the url parameter is NOT part of the URI. Ergo, QED, etc.

So, simply put, you need to write a routine the build the URL your self. The request isn't going to help you here.

Will Hartung
+2  A: 

If the url parameter is sent in the POST body you can use:

request.getParameter( "url" );
mtpettyp
I forgot to mention that this approach will work for both POST and GET requests
mtpettyp
+1  A: 

For POST you will need to use something similar to below to get the individual parameters.

Map params = request.getParamterMap();
String value = (String) params.get("url");
Taylor Leese