Escape input

F

francan00

I have a Form input field in my JSP:
--------------------------------------------------------------------------------
<input 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?
 
W

Wojtek

I have a Form input field in my JSP:
--------------------------------------------------------------------------------
<input 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?

NameClass.getInfo() will need to escape the characters as it passes
back a value. Single quotes don't matter, but double quotes can be
"escaped" by using $quot;

BTW, is NameClass.getInfo() static?
 
F

francan00

(e-mail address removed) wrote :





NameClass.getInfo() will need to escape the characters as it passes
back a value. Single quotes don't matter, but double quotes can be
"escaped" by using $quot;

BTW, is NameClass.getInfo() static?

Thanks Wojtek,

Yes NameClass.getInfo is a Class variable (static).
I solved issue by creating Utility Class to escape quotes, apostrophes
and html start and end tags.
 
D

Daniel Pitts

I have a Form input field in my JSP:
--------------------------------------------------------------------------------
<input 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?
You will either need to upgrade your container to a modern one, add the
Apache commons library, or write your own method that escapes the data.

Using JSTL is by far the simplest approach.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top