if you want to get your data as request parameter, you should use "GET"
instead of "POST" and /or let the default contentType
"application/x-www-form-urlencoded" and create your json object as either

    var json = {name: "test"};  // and let jquery convert it to a query
string
or
    var json = "name=test";   // the desired query string

regards,
Stephan


2010/5/4 Rob <robertastanfi...@gmail.com>

> I'm running Google App Engine through IntelliJ Idea and am posting
> data to a Servlet using jQuery.ajax. I'm hitting the Servlet without
> issue and can return data in the response, however, the request
> parameters are always null; I cant seem to POST data. Where am I going
> wrong?
>
> var json = JSON2.stringify({name: "test"});
>
> $.ajax({
>            type: "POST",
>            url: service,
>            data: json,
>            contentType: "application/json; charset=utf-8",
>            dataType: "json",
>            async: async,
>            success: function(o) {
>                 o = $.serviceHelper.jsonSerialize(o);
>                   callback(o);
>            },
>            error: this.dataServiceError
>        });
>
>    protected void doPost(javax.servlet.http.HttpServletRequest
> request, javax.servlet.http.HttpServletResponse response) throws
> javax.servlet.ServletException, IOException {
>
>        PrintWriter out = response.getWriter();
>        response.setContentType("text/json");
>        String json = gson.toJson(request.getParameter("name"));
>        out.println(json);
>
>    }
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> google-appengine-j...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine-java+unsubscr...@googlegroups.com<google-appengine-java%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to