aspose file tools*
The moose likes Servlets and the fly likes problem displaying contents containing HTML tags as it is in a JSP page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "problem displaying contents containing HTML tags as it is in a JSP page" Watch "problem displaying contents containing HTML tags as it is in a JSP page" New topic
Author

problem displaying contents containing HTML tags as it is in a JSP page

ravi janap
Ranch Hand

Joined: Nov 04, 2000
Posts: 389
Given below is the JSP code
<TD><SELECT name="dropdown" onchange="put()" size="3" >

<%if ( resultset != null ) {

while ( resultset.next() ) {

m_id = resultset.getString("CURR_EVENT_ID");
m_startDate = resultset.getDate("CURR_EVENT_START_TIMESTAMP");
m_endDate = resultset.getDate("CURR_EVENT_END_TIMESTAMP");
m_title = resultset.getString("CURR_EVENT_TITLE");
m_desc = resultset.getString("CURR_EVENT_DESCRIPTION");
m_flag = resultset.getString("CURR_EVENT_FLAG");
m_featured = resultset.getString("CURR_EVENT_FEATURED");

// taking "|" as a separator
str = m_startDate+"|"+m_endDate+"|"+m_title+"|"+m_desc+"|"+m_flag+"|"+m_featured+"|";
%>
<option value = "<%= str %>" > <%= m_id %>

<%
}

resultset.close();
resultset = null;

}

%>
</SELECT></TD>
The problem is the contents of title contains <B> , </B> , <A> , <P>
Now when I try to display these in the list box
there are unpredictable results since the angular tags like '<' ans '>' is being taken as end of the tag itself for eg <input type="text" value="<B>Hello World</B>" > , How do I escape the html tags while I display them in the list box ?
For your reference, I am giving below the contents of m_title and m_desc
SQL rjanapareddy@MJSTRND> SELECT CURR_EVENT_TITLE FROM MJST_CURRENT_EVENTS WHERE CURR_EVENT_ID='2';

CURR_EVENT_TITLE
--------------------------------------------------------------------------------
<B>RADIO:</B><BR><a target="_blank" href="http://majestic.ea.com/home/view.jsp?l
ink=http://www.coasttocoastam.com">Coast to Coast A.M.</A>, hosted by Mike Siege
l

SQL rjanapareddy@MJSTRND> SELECT CURR_EVENT_DESCRIPTION FROM MJST_CURRENT_EVENTS WHERE CURR_EVENT_ID='2';

CURR_EVENT_DESCRIPTION
--------------------------------------------------------------------------------
10:00 PM-2:00 AM Pacific.<P> Guest: Scott Corales. Corrales is the Editor of INE
XPLICATA, and Director of Institute of Hispanic Ufology. The Institute was organ
ized in 1999 to serve as a clearinghouse for UFO and paranormal information orig
inating from Central America, the Caribbean, South America and Spain.


SCJP, SCJD, SCWCD, SCBCD, SCEA
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Ravindra,
PLease refer to this discussion. We have to escape < with < and > with &rt; Of course I made a silly mistake in the sample code. Please refer to Frank's corrected version.
regds
maha anna
http://www.javaranch.com/ubb/Forum7/HTML/001131.html
[This message has been edited by maha anna (edited April 17, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem displaying contents containing HTML tags as it is in a JSP page