Reputation: 11
I would like to share a code snippet..
if (!key.contains("#")) {
val = mp.get(key) + "";
val = val.replaceAll("^[a-zA-Z]*$",
"a href=\"example.jsp?channel="+ val+"&date="+ date + "\">val "<"a>");
this code replaces some name which is stored in a hashmap with a link while displaying the content in a table form,now the problem what i am facing is that while replacing the name with the link, it prints "val" but what i really want is that it should print the name and when i click on that then some other jsp file should open..
I am stuck here as i want to display my actual name as a link rather displaying val as a link.
Upvotes: 1
Views: 5762
Reputation: 23373
I am not sure why you replace the full string with the link tag. The fact that you see the string "val" is because you place it as text inside the tag. Changing both of these yield the following assignment:
val = "<a href=\"example.jsp?channel=" + val + "&date=" + date + "\">" + val + "</a>";
which might do what you are aiming for.
Upvotes: 1