wood burning stoves 2.0*
The moose likes Servlets and the fly likes HTTP POST - URL Encoding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "HTTP POST - URL Encoding" Watch "HTTP POST - URL Encoding" New topic
Author

HTTP POST - URL Encoding

SAM KUMAR
Greenhorn

Joined: Jan 02, 2002
Posts: 25
Hi,
I read somewhere that for HTTP POST method, we don't have to do URL encoding because Browser (or ?) will do the automatic encoding before sending the form data. Is it true? Whether all browsers supports this feature.
Thanks in advance.
SK
dibs dibley
Greenhorn

Joined: Aug 31, 2003
Posts: 13
Hi,
I'm not sure it is the same for all of them but..
My browser's handling of form encoding is seriously crap.When you submit the form data,it is automatically defaulted to iso-8859-1.
So when I collect the submitted form data in my jsp/servlet I have to do this...
String temp=mybean.getDns1();
temp=new String (mybean.getBytes("ISO-8859-1"),"shift_jis");
Hope this helps!
Jason Davies
Greenhorn

Joined: Sep 18, 2003
Posts: 14
I'm not sure exactly what you're asking, but "application/x-www-form-urlencoded" is the default encoding for all forms. See here: http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.2.1
All you need to do in the servlet is retrieve the parameters using HttpServletRequest.getParameter(), for POST or GET requests.
If you want to upload files, then you need to use a different encoding for the form. Without more detail in the question I can't say much more!
--Jase


<a href="http://www.netspade.com/" target="_blank" rel="nofollow">http://www.netspade.com/</a> - Web programming articles and tutorials.
SAM KUMAR
Greenhorn

Joined: Jan 02, 2002
Posts: 25
Hi,
In the form, I am having encoded hidden parameter:
<FORM name="testfrm" method="POST">
<input type="hidden" name="hiddenParam" value="test%40host.com">
When my servlet receives the POST request, getParamter still returns the encoded value only instead of decoded value.
String value = request.getParameter("hiddenParam");
I am still getting value as "test%40@host.com" instead of "test@host.com"
Thanks in advance.
Sam
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
You're using URL encoding (the percentage stuff) where you should be using HTML entity "&#64;".


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: HTTP POST - URL Encoding
 
Similar Threads
MP3 Encoding, chiunk wise
encoding and decoding in java
request.getParameter() problem
jsp pageEncoding attribute
URL encoding