HTTP POST request turns into HTTP OPTIONS

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

HTTP POST request turns into HTTP OPTIONS

kolaloka
Hi All,

I have a strange problem. I use Jetty 6.1.8 bundled with Geoserver 1.7.7 and wrote a small experimental servlet independent of Geoserver (actually, it is removed now to let Jetty start quickly). The servlet looks like

package hu.flexisys.servlet.csakegy;
import java.io.*;
import java.util.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Post extends HttpServlet {
    public void doPost(
        HttpServletRequest request,
        HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html");
        response.setBufferSize(8192);
        PrintWriter out = response.getWriter();
        String username = request.getParameter("dbuser");
        out.println("{\"gyoker\":\""+username+" itt lenne a datum\"}");
        out.close();
    }
    public String getServletInfo() {
        return "Ez a servlet kiirja az user parametert";
    }
}

The request is generated from Javascript using Ext.JS. Originally it called the telekbetolt.php which worked fine but the customer wants servlets:

        Ext.Ajax.request({
            url: 'http://att-it.homelinux.net:22880/csakegy/post',
            method: 'POST', //first this was missing, but doesn't help
            //url: 'telekbetolt.php',
            success: function(response) {
//code for processing response, never gets called
            },
            failure: function(response) {
//this is called
            },
            headers: {
                'telekbetolt_header': 'something'
            },
            params: {
                dbuser: 'dpk_' + ApplicationConfig.cityParam
            }
        });

The response is status=0 statusText='communication failure' and Jetty request log contains
188.36.196.63 -  -  [06/Jan/2010:20:31:28 +0000] "OPTIONS /csakegy/post HTTP/1.1" 200 0 "-" "Mozilla/5.0 (X11; U; Linux x86_64; hu-HU; rv:1.9.1.6) Gecko/20091215 Ubuntu/9.10 (karmic) Firefox/3.5.6"

If I write incorrect URL in the request like 'wrongservlet' instead of 'post', the situation is the same, so Jetty seems not getting into my servlet. However, the servlet seems to be present, because calling its URL from a web browser results in
HTTP ERROR: 405
HTTP method GET is not supported by this URL

What can be the problem?
Thank you in advance, best regards: Bal√°zs