Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTTP POST - URL Encoding

 
SAM KUMAR
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
SAM KUMAR
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're using URL encoding (the percentage stuff) where you should be using HTML entity "&#64;".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic