This week's book giveaway is in the Security forum.
We're giving away four copies of Securing DevOps and have Julien Vehent on-line!
See this thread for details.
Win a copy of Securing DevOps this week in the Security forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Send binary and text data to servlet  RSS feed

 
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
 
Author and ninkuma
Marshal
Posts: 66488
160
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.
 
girl power ... turns out to be about a hundred watts. But they seriuosly don't like being connected to the grid. Tiny ad:
Thread Boost - a very different sort of advertising
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!