• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Send binary and text data to servlet

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic