Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6995057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:58:21+00:00 2026-05-27T19:58:21+00:00

I have a REST webservice using multipart/formdata parameters on Glassfish 3.0.1. Due to slow

  • 0

I have a REST webservice using multipart/formdata parameters on Glassfish 3.0.1. Due to slow performance I have upgraded the server to 3.1. I am using Jersey and for that I have the appropriate web.xml in my Webservice project:

    <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>RestWSGS</display-name>
  <servlet>
    <servlet-name>Jersey REST Service</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
    <init-param>
      <param-name>com.sun.jersey.config.property.packages</param-name>
      <param-value>ws</param-value>
    </init-param>
    <init-param>
      <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
      <param-value>true</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Jersey REST Service</servlet-name>
    <url-pattern>/jersey/*</url-pattern>
  </servlet-mapping>
</web-app>

I have made ajax requests to the webservice . The html code is :

var formdata = new FormData();
        formdata.append("connecturi","jdbc:mysql://localhost/schema1");
        formdata.append("username","root");
        formdata.append("password","metamagics");

        $.ajax(
        {
            url: 'http://comp1:8080/RestWSGS/jersey/GetSchemaTable',
            async: false,
            data: formdata,
            type: 'POST',
            cache: false,
            dataType: 'text', 
            contentType: "multipart/form-data",
            processData: false,
            success: function(data)
            {
                 dbtb = data;
            }
        });

The request has worked flawlessly before and after upgrading the web server the response I get is 400 – Bad Request.
I haven’t made any code changes after upgrading except changing @FormParam to @FormDataParam (Since I got a deprecated error after upgrading to glassfish 3.1 which uses jdk 7).

In case anyone has any idea why this is happening please let me know.
Thanks in advance!

EDIT:
Using @FormParam instead allows the request through flawlessly. So Some link between jersey and the FormData object I am creating for the request breaks when the @FormParam changes to @FormDataParam. Is there a workaround for this ???

I enabled logging and trace in jersey. This is my output:

INFO: 6 * Server in-bound request
6 > POST http://comp1:8080/RestWSGS/jersey/GetJson
6 > host: comp1:8080
6 > user-agent: Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20100101 Firefox/8.0
6 > accept: application/json, text/javascript, */*
6 > accept-language: en-us
6 > accept-encoding: gzip, deflate
6 > accept-charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
6 > connection: keep-alive
6 > content-type: multipart/form-data
6 > x-requested-with: XMLHttpRequest
6 > referer: http://comp1:8080/GUIForGS/gridsense/fileSelection.html
6 > content-length: 621
6 > pragma: no-cache
6 > cache-control: no-cache
6 > 
-----------------------------187161971819895
Content-Disposition: form-data; name="purpose"
new
-----------------------------187161971819895
Content-Disposition: form-data; name="filename"
BoilerHeater_BQPRJun09.xls
-----------------------------187161971819895
Content-Disposition: form-data; name="username"
abcd#7 11 2011 12 24 23
-----------------------------187161971819895
Content-Disposition: form-data; name="password"
abcd#7 11 2011 12 24 23
-----------------------------187161971819895
Content-Disposition: form-data; name="company"
Third
-----------------------------187161971819895--

INFO: 6 * Server out-bound response
6 < 400
6 < X-Jersey-Trace-000: accept root resource classes: "/GetJson"
6 < X-Jersey-Trace-001: match path "/GetJson" -> "/application\.wadl(/.*)?", "/WriteIntoFiles(/.*)?", "/GetSchemaTable(/.*)?", "/ExcelHtmlTable(/.*)?", "/UploadFiles(/.*)?", "/UpdateDB(/.*)?", "/GetTable(/.*)?", "/GetJson(/.*)?"
6 < X-Jersey-Trace-002: accept right hand path java.util.regex.Matcher[pattern=/GetJson(/.*)? region=0,8 lastmatch=/GetJson]: "/GetJson" -> "/GetJson" : ""
6 < X-Jersey-Trace-003: accept resource: "GetJson" -> @Path("/GetJson") ws.GetJson@18a76d6
6 < X-Jersey-Trace-004: match path "" -> ""
6 < X-Jersey-Trace-005: accept resource methods: "GetJson", POST -> ws.GetJson@18a76d6
6 < X-Jersey-Trace-006: matched resource method: public spreadsheet.Exceldatalist ws.GetJson.getJson(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String)
6 < X-Jersey-Trace-007: matched message body reader: class com.sun.jersey.multipart.FormDataMultiPart, "multipart/form-data" -> com.sun.jersey.multipart.impl.MultiPartReaderServerSide@a74cfe
6 < X-Jersey-Trace-008: mapped exception to response: javax.ws.rs.WebApplicationException@19b218 -> 400 (Bad Request)
6 < 

There is no exception, no way to find out what is wrong. How should I go about this?? If Glassfish 3.1 includes jersey multipart jar, what is the reason the multipart request does not work?

Please help me with this

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:58:21+00:00Added an answer on May 27, 2026 at 7:58 pm

    I have found a solution for this which might not be elegant but serves my purpose.

    I have changed the @comsumes mediatype to form url encoded. Created a form tag in the client html and posted it to the web service. Ajax call has dataType as application//x-www-form-urlencoded. Now the @formParam gets proper values from the client.

    Before this I had tried out many variations :- changed @FormParam to @FormDataParam then added the FormContentDisposition part but to no avail! found no solution at the jersey forum neither here. So had to move on with this solution.
    Please update with proper solution in case anyone finds it.

    Kavita

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Anyone have idea how to pass value from iPhone application to the REST-Webservice using
I have a REST webservice that I need to consume in C#. I need
I have to map a REST Webservice URL like http://server:8080/application/service/customer/v1 to createCustomer method in
I have a C# webservice on a Windows Server that I am interfacing with
I have a list of objects that I return using webservice. And I try
I have successfully implemented rest webservice using apache wink. I am using ant to
I have a REST web service that currently exposes this URL: http://server/data/media where users
I am building a REST Webservice with the help of Jersey on Glassfish. Now
I have a web service class that the rest of the framework depends on
Im building a REST webservice and have of course done some research but are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.