• Post Reply Bookmark Topic Watch Topic
  • New Topic

not getting proper value of # and & etc.  RSS feed

 
Manish Malhotra
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Can u please solve this problem urgently.
Im getting '#' and '&' values from the test field from a JSP in the servlet but it is getting as their html representation as
for # = #
and for & = &
I think it could be solved using the character encoding. Is it correct or not ? And even if it is correct I dont know how to do this.
Please give me the solution.
form code is--->>
<form autocomplete="off" name="thisForm" method="post"
>
and tag is -->
<input class="Xinput" type="text" name="keyword" size="25" maxlength="50" />
regards,
Manish Malhotra
 
Steve Leach
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know about character encoding, but why don't you just convert the codes back into the appropriate characters for your server character set.
I would have htmlEncode() and htmlDecode() functions for this. When getting data from the user you pass it through htmlDecode(), and when displaying data back to the user you pass it through htmlEncode().
 
Vankipuram Padmanaban
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi manish,
What are you using to get the JSP-Field-Value into the servlet??
Are you using 'Request.getParameter(JSP-Field-name)??
 
Lisa D'Aniello
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure exactly what your question/problem is, but here's a link that gives codes for special characters:
http://hotwired.lycos.com/webmonkey/reference/special_characters/
Also, I find it strange that encoding would be a problem since you're not passing the values through a url (although I don't generally work with servlets and I am new to jsp). Can you post more code?
Hope this helps,
Lisa M.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!