Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Send binary and text data to servlet

 
Ansh Kay
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to send binary and text data to servlet. Use case is that client selects a zip file and sends it to the servlet. Along with the zip, some information like username etc. is also send in text form.

To simulate this request, I have created the attached postman request.


How should I handle this request in the servlet. Till now, I only had json coming in the request, so my request processing looked like this


org.json.simple.JSONObject requestBody = (JSONObject) UtilitiesJSON.parseJSON(Util.readText(request.getReader()), true);

Now, that I have both text and binary, how can I process it on the server side? Once I get the zip in the servlet, I need to save it, which should not be a problem once I get a handle on the zip.



RequestServlet.PNG
[Thumbnail for RequestServlet.PNG]
Postman servlet request
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65338
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your servlet will need to handle a multi-part request. Search this forum for previous discussions of multi-part forms.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic