1

I am attempting to send data encoded in JSON from a Java SE application to a Java EE web application through an HTTP Post request using Apache HttpClient. The framework being used for the Java EE web application is JavaFaces and the server is GlassFish. The web application will receive the http post request, parse the json, and send that data to a JavaDB (Derby) database. My understanding is that a servlet on the Java EE end can be created that receives the http post request when it is sent, parses the JSON, and sends that data to the table in the database.

Can anyone please show me what such a servlet would look like or refer me to an example of a servlet that does what I am trying to do?

Daron
  • 329
  • 1
  • 4
  • 24

1 Answers1

0

According to my understanding this is a simple task. First you have to get data from POST. If you send JSON string with header "data", you can access it in doPost method by request.getParameter("data"). Refer here for that.Then parse that string and get data out. Refer here for that. Finally what you have to do is persist that data in your DB. I'm sure you will be able to find enough tutorials on how to do that with your database.

Community
  • 1
  • 1
paarandika
  • 1,238
  • 12
  • 21