jQuery in Action, 3rd edition
The moose likes JSP and the fly likes Text box with HTML tags security issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Text box with HTML tags security issue" Watch "Text box with HTML tags security issue" New topic

Text box with HTML tags security issue

Avi Gafa

Joined: Jul 24, 2008
Posts: 3
Hi All,
I have a text box(on a jsp page) which should enable a free txt input including an HTML tags.
Some background:
In my customer page, there is an empty <div> that shoud be filled dinamiclly by calling to my servlet.
my servlet should return a text that can be including an HTML tags and this text will be emmbeded in the div and will be formatted as a regular HTML.
in order to retrive this text, I'm giving my customer a text box where he can put his free text(again, including HTML tags) and I store it in the DB.
my problem is, how to give my customer the ability to put his free text with the HTML tags in the text box and in the DB and to avoid security issuse like SQL injection.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

SQL injection problems can be handled in the model using techniques as outline in the JDBC forum (using PerparedStatements, for example). Script and HTML injection can be prevented by using the <c:out> JSTL tag when displaying the user-entered values, as <c:out> will properly HTML-encode any markup characters.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link: http://aspose.com/file-tools
subject: Text box with HTML tags security issue
It's not a secret anymore!