We fixed the problem, we had different servlet from the one we showed
here (for rpivacy issues) and we try this one and worked!.
We believe the problem is that in the serverlet we made several
prints, ex:
HttpServletResponse response;
HttpServletRequest request;
response.setContentType("application/x-javascript; charset=utf-8");
PrintWriter out = response.getWriter();
out.print(request.getParameter("callback") + "({\"value\":\"");
out.print("<ul>");
out.print("<li>one</li>");
out.print("<li>two</li>");
out.print("<li>three</li>");
out.print("</ul>");
out.print("\"})");
out.flush();
out.close();
So we change it to make only one print() and build the string first.
Thanks.

On 15 jul, 11:44, gil <gilalbe...@gmail.com> wrote:
> Hi,
> i'm trying to make a jsonp servlet but it gives me an error on the
> response. I'm missing something? maybe on the java servlet?
> Servelet:
> HttpServletResponse response;
> HttpServletRequest request;
> response.setContentType("application/x-javascript; charset=utf-8");
> PrintWriter out = response.getWriter();
> out.print(request.getParameter("callback") + "({\"value\":\"test
> \"})");
> out.flush();
> out.close();
> Jquery:
> $.getJSON("http://www.myothersite.com/?
> moreinfo=value&format=jsonp&callback=?",
>     function(data){
>         alert("success");
>     });
> I make the call for the example on tha API and it worked:
> $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?
> tags=cat&tagmode=any&format=json&jsoncallback=?",
>     function(data){
>         alert("success");
>     });
> Also, the response of Java Servelet is working but I don't know if
> it's valid.
> Respone of my Server:
> HTTP/1.1 200 OK
> Server: Apache-Coyote/1.1
> Content-Type: application/x-javascript;charset=utf-8
> Transfer-Encoding: chunked
> Date: Wed, 15 Jul 2009 17:01:39 GMT
> 15c
> jsonp1247677616733({"value":"test"})
> 0
> Response for the flickr server:
> HTTP/1.1 200 OK
> Date: Wed, 15 Jul 2009 17:09:37 GMT
> P3P: policyref="http://p3p.yahoo.com/w3c/p3p.xml";, CP="CAO DSP COR
> CUR
> ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi
> PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"
> Expires: Mon, 26 Jul 1997 05:00:00 GMT
> Last-Modified: Wed, 15 Jul 2009 17:04:41 GMT
> Cache-Control: no-store, no-cache, must-revalidate
> Cache-Control: post-check=0, pre-check=0
> Pragma: no-cache
> Vary: Accept-Encoding
> Content-Encoding: gzip
> Content-Length: 3898
> Connection: close
> Content-Type: application/x-javascript; charset=utf-8

Reply via email to