views:

43

answers:

2

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

A: 

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

aioobe
no i am not getting it as username. i m getting d url it has to be directed to. it works fine for all other names
swati
+1  A: 

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

Daniel