[Geoserver-devel] Problems on method="POST"

Hi
I am using Geoserver 1.3 RC4 and Tomcat 5. I created a project with a html file and place a getMap instruction like this:

test.html

Than, I receive this message from TOMCAT/GEOSERVER:

[Fatal Error] :1:1: Content is not allowed in prolog.
org.vfny.geoserver.wms.WmsException: line 1 column 1 – Content is not allowed in prolog.
at org.vfny.geoserver.wms.requests.GetMapXmlReader.read(GetMapXmlReader.java :117)
at org.vfny.geoserver.wms.servlets.GetMap.doPost(GetMap.java:60)

So, if I change method=“POST” to method=“GET” in the FORM tag, it’s works… But i want to use HTTP-POST because using long requests with long text on html… What I’m doing wrong ???

thanks in advance

Alberto Kunze wrote:

Hi
I am using Geoserver 1.3 RC4 and Tomcat 5. I created a project with a
html file and place a getMap instruction like this:

Hi Alberto

I implemented the GetMap post for RC6 reading the changelog.
http://sourceforge.net/project/shownotes.php?release_id=379453&group_id=25086

I know there was an error in my first implementation of this, so I am
unsure if a fully working postable GetMap was in rc6 or 7. If you keep
to the latest builds you will be fine.

The newest geoserver expects the request to be url encoded in UTF-8, if
nothing else set in the http header. It is set in a filter, and the
default encoding can be changed in web.xml if needed.
The filter was added in the start of january, so the GeoServer
1.3.0-PR1 should have this included. Before that the geoserver expected
the request to be url encoded in the encoding specified on the machine
it runs on.

To override the encoding with a http header you should use:

Content-Type: application/x-www-form-urlencoded; charset=iso-8859-2

If charset is set tomcat will pick it up, and the geoserver will not set
it's default UTF-8 encoding on the request.

By the way:

You should not manually encode the value in the form.
It will be double url encoded then, when the browser submits.
I tried your form in my browser (changed to get) and got this:
http://127.0.0.1:8080/geoserver/wms/GetMap?bbox=-130%2C24%2C-66%2C50&styles=population&Format=image%252Fpng&request=GetMap&layers=states&width=550&height=250&srs=EPSG%253A4326

See the Format=image%252Fpng The % is encoded as %25.
The browser should handle this, no need to manually add it.

Hope this helps
Magne

<html>
  <head>
    <title>test.html</title>
  </head>
  <body>
   <FORM method="POST" action= "
http://127.0.0.1:8080/geoserver/wms/GetMap&quot;&gt;
     <INPUT type='text' name='bbox' value='-130,24,-66,50'>
     <INPUT type='text' name='styles' value='population'>
     <INPUT type='text' name='Format' value='image%2Fpng'>
     <INPUT type='text' name='request' value='GetMap'>
     <INPUT type='text' name='layers' value='states'>
     <INPUT type='text' name='width' value='550'>
     <INPUT type='text' name='height' value='250'>
     <INPUT type='text' name='srs' value='EPSG%3A4326'>
     <INPUT type='submit' value='Load Map'>
   </FORM>
  </body>
</html>

Than, I receive this message from TOMCAT/GEOSERVER:

[Fatal Error] :1:1: Content is not allowed in prolog.
org.vfny.geoserver.wms.WmsException: line 1 column 1 -- Content is not
allowed in prolog.
at
org.vfny.geoserver.wms.requests.GetMapXmlReader.read(GetMapXmlReader.java
:117)
at org.vfny.geoserver.wms.servlets.GetMap.doPost(GetMap.java:60)
......
......

So, if I change method="POST" to method="GET" in the FORM tag, it's
works.... But i want to use HTTP-POST because using long requests with
long text on html.... What I'm doing wrong ???

thanks in advance