File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Extracting Content from HTTP Post? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Extracting Content from HTTP Post?" Watch "Extracting Content from HTTP Post?" New topic

Extracting Content from HTTP Post?

Sachin Dere
Ranch Hand

Joined: Jan 14, 2003
Posts: 80
Hi Guys,
I need to extract COntent ex gif,mid files from HTTP Post.The content is in the body of HTTP Post which is being posted to my servlet by the Telco. How do i get this content in physical format? ex read the content and store it in cat.gif and cat.mid etc?
I need to use Base64 encoding
Please help me if anyone knows how to do it
really appreciate it
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

There is the sun.misc.BASE64Encoder but it's undocumented and Sun recommends against using any classes in the sun.* package.

Googling on 'sun.misc.BASE64Encoder' will yield both alternatives and, in some cases, the actual code to roll your own.

As for getting the post to begin with, look at the getInputStream method of the ServletRequest interface: #getInputStream()

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Gowrishankar Mudaliar
Ranch Hand

Joined: Oct 20, 2001
Posts: 39
You can read the binary contents of your file without base64 by setting the mime type in the form as multipart/form-data and read the contents in the servlets.

This is how file-uploads and email attachments work in web-based applications. I am not sure if they are precisely applicable to your requirements.
Sachin Dere
Ranch Hand

Joined: Jan 14, 2003
Posts: 80
Hi guys,
thanks for the reply. will work on it and will let u know
I agree. Here's the link:
subject: Extracting Content from HTTP Post?
It's not a secret anymore!