• 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

Decompress the HTTP Request body

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

Client is sending us the compressed format of request body message. How can I decompress it and read the file. If anyone has Servlet code for this please pass me.

Thanks,
sxp
 
Sheriff
Posts: 67745
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
I guess that would greatly depend upon what type of compression was used.
 
S Guru
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,

But I was trying to decompress(unzip) using the follwoing code. But it didnt even work out. I post the zipped xml file thought POST request.

final int BUFFER = 2048;
StringBuilder xmlData = new StringBuilder();
try{
ZipInputStream zis = new ZipInputStream(request.getInputStream());
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
System.out.println("Extracting: " + entry);
int count;
byte data[] = new byte[BUFFER];

while ((count = zis.read(data, 0, BUFFER)) != -1) {
xmlData.append(data);
}

}
}catch(Exception e)
{

}

The problem is, the code is not getting in to the while loop. I believe the ZipInputStream is not taking the request.getInputStream(). I tried to pass the zipped file like ,

FileInputStream fis = new FileInputStream(
"c:\\TEST\\unit_test2_zip.zip");
ZipInputStream zis = new ZipInputStream(
new BufferedInputStream(fis));

It was working good. Tried to put the same logic by request.getInputStream(). It failed. Should I need to do like identifying the compressed format and proceed? Any solution ?

Thanks,
SXP
 
S Guru
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I beleive I address the proper forum Java Forums/Servlet. I was asking about the HTTPServletRequest how to read the compressed request body. Its not a General java question. Its a Servlet question only
 
reply
    Bookmark Topic Watch Topic
  • New Topic