Help coderanch get a
new server
by contributing to the fundraiser
  • 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

HTTP POST - URL Encoding

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're using URL encoding (the percentage stuff) where you should be using HTML entity "&#64;".
 
Hey cool! They got a blimp! But I have a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic