Pavel Bucek-2 wrote
>
> Right.
>
> 1) are you sure you are sending "multipart/form-data"? Can you dump your
> request (with wireshark / something similar) and share it?
>
>>>> I am sending multipart/form-data. Using Firebug I can see the following
>>>> post:
> Request headers -
> Host localhost:8080
> User-Agent Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20100101 Firefox/8.0
> Accept */*
> Accept-Language en-us
> Accept-Encoding gzip, deflate
> Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
> Connection keep-alive
> Content-Type multipart/form-data
> Referer http://comp1:8080/GUIForGS/gridsense/fileSelection.html
> Content-Length 290
> Origin http://comp1:8080
>
> post -
> -----------------------------23281168279961
> Content-Disposition: form-data; name="username"
> abcd#15 11 2011 12 3 10
> -----------------------------23281168279961
> Content-Disposition: form-data; name="wbk"
> Direct mapping CCD to XLS.xls
> -----------------------------23281168279961--
>>>>
> 2) see @FormParam javadoc:
> http://jersey.java.net/nonav/apidocs/latest/jersey/javax/ws/rs/FormParam.html.
> I've found simple sample using this funcionality:
> http://www.mkyong.com/webservices/jax-rs/jax-rs-formparam-example/
>
>>>> @FormParam works fine with glassfish 3.0. As I have already posted
>>>> Glassfish 3.1 gives an exception for @FormParam and
>>>> multipart/form-data, due to which I had to use @FormDataParam.
>
>
> 3) @FormDataParam is used for handling multipart queries, see mutlipart
> spec: http://www.ietf.org/rfc/rfc2388.txt. You'll need to have
> jersey-multipart module present on your classpath (you most likely do if
> you are using glassfish). You can check our sample - multipart-webapp
> [1] (linking version 1.4; it should be present in
> jersey-docs-and-samples glassfish IPS package, so you might already have
> that installed), please note test classes, they show how to call these
> REST resources from java (using jersey client).
>
> I asked for server log, because there should be logged some exception /
> explanation declaring *why* was that request considered bad. I would
> start there..
>>>>> I have gone through the example stated here. I was missing the second
>>>>> parameter for all @FormDataParam having type
>>>>> FormDataContentDisposition. I tried adding that as well so that If I
>>>>> have 3 sent values I am accepting 6 parameters in the Rest WS. This
>>>>> did not work...
>
>>>> I am using ajax calls from html page not a java client. I have already
>>>> posted the creation of the formData object and setting in the ajax()
>>>> method of jquery.
>
> Pavel
>
> [1]
> http://search.maven.org/#artifactdetails%7Ccom.sun.jersey.samples%7Cmultipart-webapp%7C1.4%7Cwar
>
> On 12/8/11 5:18 AM, kavita wrote:
>> eh? Glassfish 3.1 can run on jdk 1.6, not sure about 1.7 but I guess it
>> should run.. anyway, that sentence doesn't make much sense. @FormParam
>> is present in JAX-RS 1.x API so you don't need to replace it with
>> anything, it is just there and it should work.
>>>> Actually I have upgraded to java 7. I was using 1.6 update 7 which
>>>> needed
>>>> to be at least update 22. If i use @FormParam with jdk 1.7 it gives the
>>>> error that @FormParam cannot be used for multipart/formdata.
>>>> Nevertheless
>>>> I will download the 22 update and use it with glassfish 3.1. Still I
>>>> dont
>>>> know what must be used for sending the request in case someone uses
>>>> @FormDataParam!!!
>>
>> can you please look into server log (and let us know what you found
>> there)? And is it possible for you to share service code as well?
>>>> Sure this is the signature of the method:
>> @POST
>> @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
>> @Consumes(MediaType.MULTIPART_FORM_DATA)
>> public Exceldatalist getJson(@FormParam("purpose") String purpose,
>> @FormDataParam("filename") String wbkname,
>> @FormDataParam("username") String username,
>> @FormDataParam("password") String pwd,
>> @FormDataParam("company") String company)
>> {
>> System.out.println("Purpose: "+purpose);
>> System.out.println("wbkname: "+wbkname);
>> System.out.println("username: "+username);
>> System.out.println("pwd: "+pwd);
>> System.out.println("company: "+company);
>> .
>> .
>> .
>> .
>> .
>> }
>>
>> I've already said that the multipart jars loading which used to come on
>> server.log whenever deploying such web services, does not come now with
>> glassfish 3.1. But I can see the jars in the buildpath. jersey multipart
>> 1.4
>> is on the buildpath.
>>
>> I am getting a bad request resonse. I have given the log trace already.
>> Please help me with this...
>> Kavita
>>
>>
>> --
>> View this message in context:
>> http://jersey.576304.n2.nabble.com/FormDataParam-gives-Bad-Request-tp7065882p7073213.html
>> Sent from the Jersey mailing list archive at Nabble.com.
>>
>
--
View this message in context: http://jersey.576304.n2.nabble.com/FormDataParam-gives-Bad-Request-tp7065882p7096271.html
Sent from the Jersey mailing list archive at Nabble.com.