943,775 Members | Top Members by Rank

Ad:
  • JSP Discussion Thread
  • Unsolved
  • Views: 1015
  • JSP RSS
Sep 29th, 2008
0

Form data

Expand Post »
I have a Form input field in my JSP:
JSP Syntax (Toggle Plain Text)
  1. <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?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
chicago1985 is offline Offline
36 posts
since Nov 2007
Sep 30th, 2008
0

Re: Form data

I have a Form input field in my JSP:
JSP Syntax (Toggle Plain Text)
  1. <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:
<input name="nickname" type="text" value='<%= NameClass.getInfo() %>' />

And for better responses try the jsp forum.
Sponsor
Featured Poster
Reputation Points: 1014
Solved Threads: 446
Nearly a Senior Poster
javaAddict is offline Offline
3,258 posts
since Dec 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JSP Forum Timeline: retrieving values from jsp page
Next Thread in JSP Forum Timeline: help me





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC