This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Extracting Content from HTTP Post?

 
Sachin Dere
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
thanks,
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is the sun.misc.BASE64Encoder but it's undocumented and Sun recommends against using any classes in the sun.* package.
http://java.sun.com/products/jdk/faq/faq-sun-packages.html

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:
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletRequest.html #getInputStream()
 
Gowrishankar Mudaliar
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
thanks for the reply. will work on it and will let u know
cheers,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic