swati
swati

Reputation: 1

displaying special characters in hyperlink text

I have used HTML in my Java class and in one case I have used <a href="...">username</a>. Username is a variable that gets values dynamically. In one case its value is 'rg@bg' but here instead of the name I'm getting the URL to which it is directed in my jsp. How do I ensure that the value of username comes on the display page as it is. I have tried "@"+username. Didn't work

Upvotes: 0

Views: 1136

Answers (2)

Daniel
Daniel

Reputation: 28084

You don't have greasemonkey installed which automatically converts email patterns into links?

Upvotes: 1

aioobe
aioobe

Reputation: 421020

I'm not sure I understand your problem, but here is a guess.

I suspect you do the actual print wrong. If the variable is called username and "username" is printed instead of the content of username it seems you need to do something like

print("<a href=\"...\">" + username + "</a>");

instead of

print("<a href=\"...\">username</a>");

In jsp you could also simply write

<a href="..."><%= username %></a>

If the problem concerns treatment of html-entities you may find the following interesting:

http://www.rgagnon.com/javadetails/java-0306.html

Upvotes: 0

Related Questions