0
votes

I am new to jsp. I am taking user input(name) in a textfields. This input is saved in xml file. I am using name attribute as a parameter and sending this parameter to another jsp file so that user can add child nodes to the given parameter.

Everything is working perfect except for & + %. I am converting parameter to httpparam so & value is %26 + value is %2B and % value is %25. / value is %2F all others are working fine. I am having no trouble with other special characters but as I include & + % it is giving me empty value and not null in other jsp hidden fields.and thats why I am not getting any value from String name = request.getParameter("name");this statement. Even my URL looks like jsp?name=%25 for % parameter. and ...jsp?name=%26 for & parameter and ...jsp?name=%2B for + as a parameter My xml file has ISO-8859-1 encoding problem2) if I send parameter as (which is name given by user) its also empty and not null but alone < or > or >< or <> are working fine and I can not restrict entering special characters as it is requirement

could any one help me Thanks in advance.

1
Welcome to Stackoverflow. Please pay more attention on formatting your question, separating code sections, grammar, etc. to make it more readable and easier for others to answer. - Neeku
?param1=%2B&param2=%2B You don't want to encode the & between parameters, only the ampersand inside a parameter value. Is that the question? - developerwjk

1 Answers

0
votes

Ordinarily web browsers automatically perform URL encoding on form fields, however you can perform encoding and decoding yourself using the appropriate classes. You might want to check out:

http://docs.oracle.com/javase/7/docs/api/java/net/URLEncoder.html

and

http://docs.oracle.com/javase/7/docs/api/java/net/URLDecoder.html