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 8731365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:13:15+00:00 2026-06-13T09:13:15+00:00

I am using Extjs 4 and Java Servlets in my app. I want to

  • 0

I am using Extjs 4 and Java Servlets in my app. I want to post some data to the server in json format.

The format of JSON should be like this:

{
    "credentials":[
    {
       "username":"george",
       "password":"xyz"
    }
    ]
}

I did this in extjs code:

buttons: [{
        text: 'Submit',
        handler: function() {               
            Ext.Ajax.request({
                url: '/Model/FormServlet',
                method: 'POST',
                jsonData : {
                    //Hardcoded values
                    username: "george", 
                    password: "xyz"
                },
                callback: function (options, success, response) {                       
                    alert(response.responseText);
                }
            });
        }           
    }]

1) I believe that I wont get the JSON format which I posted above. Please let me know how to get that format using jsonData.

2) How to retrieve this in servlet doPost method? Since I have not used params and have replaced it with jsonData hence request.getParameter is not going to work in the servlet doPost method.

Please let me know how to make this work.

Regards,

  • 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-06-13T09:13:22+00:00Added an answer on June 13, 2026 at 9:13 am

    1) You are OK

    2) This is a POST request; the data will not come in a parameter (e.g. not multipart/form-data) but will be the content of the HTTP request. In doPost, simply read everything in request.getInputStream() and transform it to String using the proper encoding or call request.getContent() directly if you have a proper ContentHandler registered.

    Something along the lines of

    byte[] ba = IOUtils.toByteArray( req.getInputStream(  ) );
    String charset = TypedContentUtils.extractCharset( req.getContentType(  ) );
    String json = new String( ba, charset );
    

    IOUtils is Apache Commons IO (writing your own is 10 lines with proper Exception handling); TypedContentUtils.extractCharset is a simple home grown method extracting the charset from the Content-Type or defaulting to utf-8.

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

Sidebar

Related Questions

I'm using extjs charts to display some data. In this data, the axis and
I am using ExtJS to load data to a grid, and I want to
I am using Extjs 4.1 I have a form with some textfields. I want
I'm using ExtJs 4. I have a panel that looks something like this: var
I'm using ExtJS 2.2.1 In my web app, I used to have a TreePanel
I am using ExtJS DataView for my image gallery. This is my way for
I have been using Selenium a lot lately (testing an ExtJs app) and while
I'm using ExtJS 3.0 and I would like to extend FormPanel or any solution
I'm using ExtJS to make a form that generates a report from the data
I am using ExtJS 3 here. I would like to populate a formpanel from

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.