Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display HTML code without letting browser render it. 1

Status
Not open for further replies.

as400pro

Programmer
Jan 16, 2003
57
US
I currently maintain a database of links and programming tips with a VB program I wrote. I keep the main database at my office and merge in data I build at other locations.

I decided to try to learn JSP and Servlets so I am in the process of creating applications to maintain my database via the web so I no longer have to merge data, I can just update via the web whenever I want.

So far, so good. The new Java programs update, delete, and add records to my database. The problem is I store links as
<A HREF="thisisalink.html">clickme</A>
in the database field, if I go to update that record via the web, I don't see the actual HTML code, I see a link waiting to be clicked.
How can I get the JSP to display the actual HTML code, not render it? My searching has only revealed deprecated HTML tags.

I suppose if I have to I could create an additional field and start storing the web address and the description in separate fields and build the href code as I write out the webpage that will display the links. Of course I would have to write an app to break out all my current links into the new fields.


T. Bishop
 
If you save the HTML by replacing all less-than signs ( < ) with &lt;, that should do it for you.

Here's an example:

Code:
[b]&lt;[/b]a href="[URL unfurl="true"]http://www.google.com>Google[/URL][b]&lt;[/b]/a>

'hope that helps!

--Dave
 
Oops. 'forgot my close-quotes:

Code:
[b]&lt;[/b]a href="[URL unfurl="true"]http://www.google.com">Google[/URL][b]&lt;[/b]/a>

'still works as mentioned.

Good luck!

--Dave
 
I would still paste the link as normal into my "Link" field on my entry screen but let the servlet convert the <'s to &lt; as I write out the record to my database table.

And as I read the database file and write my html pages I would convert the &lt; to < so the web page will render correctly when viewed by visitors.

I will have to write a one time app to convert my current data, convert all <'s with &lt;.




T. Bishop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top