954,574 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Form data

I have a Form input field in my JSP:

<input name="nickname"  type="text" value="<%= NameClass.getInfo() %>" />

How do I make sure this data is escaped correctly to be able to show quotes and apostrophes. I tried slash in front(name=\"nickname\") and it didnt work.

I dont have JSF,Struts, JSTL, StringEscapeUtils (from Apache commons) due to restrictions on my Tomcat 4.1.27 container.

Is there something I can use or please advise best way to handle this?

chicago1985
Light Poster
36 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
 

I have a Form input field in my JSP:

<input name="nickname"  type="text" value="<%= NameClass.getInfo() %>" />

How do I make sure this data is escaped correctly to be able to show quotes and apostrophes. I tried slash in front(name=\"nickname\") and it didnt work.

I dont have JSF,Struts, JSTL, StringEscapeUtils (from Apache commons) due to restrictions on my Tomcat 4.1.27 container.

Is there something I can use or please advise best way to handle this?

What do you mean escape correctly?
Plus you don't display the 'nickname'. That is the name of the element. Like the variable name of a JTextField in swing.
The real value is the 'value' attribute and you display whatever the NameClass.getInfo() returns.
You use the 'nickname' when you submit the form:

String nicknameValue = request.getParameter("nickname")

It will have whatever the field has. And when the page loads the initial value that will be displayed is the NameClass.getInfo().

If you want apostrophes at the field then (I think this is correct but try it anyway) have the NameClass.getInfo() return this:
"a value"
and do this:

And for better responses try the jsp forum.

javaAddict
Nearly a Senior Poster
Team Colleague
3,329 posts since Dec 2007
Reputation Points: 1,014
Solved Threads: 448
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You