• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to read "&" symbol as a value in request.getParameter method  RSS feed

 
alsoumahi alBatal
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi experts , I have some input user fields where the user sometimes writes "&" in field form , so if I want to read it in request.getParameter , it will read up to "&" characters then stop , which is not complete , let say user has input such as "Drawing & Writing" , it will show in servlet if I print it only "Drawing "
so how to solve that !!!

thanks alot
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where are the values coming from from? They should be urlencoded when they are sent so that you don't have these problems and don't have to use request.getQueryString()
 
Michael Gomez
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
& is used to seperate query string parameters: somepage?par1=abc&par2=def
If you don't URL encode the & in your strings then it will be misinterpreted
 
alsoumahi alBatal
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so to encode the page itself I have to put
<%@page pageEncoding="UTF-8" %>
if I want page by page , but if you want the encoding to be default one for all my page in the server , I have to adjust server.xml in tomcat to be like follow



thanks alot
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Page encoding has nothing at all to so with this issue.

The form values will be automatically encoded for transfer. How are you obtaining the form values in the servlet?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!