Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Escape input

Reply
Thread Tools

Escape input

 
 
francan00@yahoo.com
Guest
Posts: n/a
 
      09-30-2008
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?
 
Reply With Quote
 
 
 
 
Wojtek
Guest
Posts: n/a
 
      09-30-2008
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote :
> 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?

--
Wojtek


 
Reply With Quote
 
 
 
 
francan00@yahoo.com
Guest
Posts: n/a
 
      09-30-2008
On Sep 30, 9:38*am, Wojtek <(E-Mail Removed)> wrote:
> (E-Mail Removed) wrote :
>
> > *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?
>
> --
> Wojtek


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.
 
Reply With Quote
 
Daniel Pitts
Guest
Posts: n/a
 
      10-04-2008
(E-Mail Removed) wrote:
> 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.

--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Input value and escape francan00@yahoo.com Java 0 09-30-2008 12:24 AM
How to read strings cantaining escape character from a file and useit as escape sequences? slomo Python 5 12-02-2007 11:39 AM
CGI.escape accepts only ISO-8859-1 input? Martin Ruby 2 06-27-2007 03:50 PM
Which is faster in ASIC: 2-input AND gate or a 2-input multiplexer Weng Tianxiang VHDL 12 08-11-2005 10:50 AM
How do I escape form input values, C style? Ivan Marsh Javascript 3 04-13-2005 11:48 PM



Advertisments