• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 guess I've been abducted by space aliens. So unprofessional. They tried to probe me with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic