jsphrefdisplaytag

Display tag URL breaks while trying to pass it as property in object


I am working with a simple JSP Servlet application that uses Display tag for rendering information about some objects. One of the attributes of these objects is an HTTP URL which needs to be rendered as a link on the front end. These attributes come from a database. I just fetched the links using JDBC and set them as a String attribute in the object. Now when I try to render this URL on the screen in the list, it breaks down. Please see the example to understand what I mean by "breaks down"

Code in Java setter

public void setUrlcount(String urlcount) {
    String a = "<a:href=\"" + urlcount + "\">" + urlcount + "</a>";
    this.urlcount = a;
}

Code in display tag for rendering

<display:column title="URLs" property = "urlcount"
   sortable="true" headerClass="sortable" />

Output on the JSP

<a:href="http: www.cfmedia.vfmleonardo.com="" 
imagerepo="" 4="" 0="" 53="" 948="" 663=""
 lounge_a.jpg"="">

http://www.cfmedia.vfmleonardo.com/imageRepo/4/0/53/948/663/Lounge_A.jpg
</a:href="http:>

Expected output:

<a:href="http://www.cfmedia.vfmleonardo.com/imageRepo/4/0/53/948/663/Lounge_A.jpg">http://www.cfmedia.vfmleonardo.com/imageRepo/4/0/53/948/663/Lounge_A.jpg</a>

Solution

  • Your (a:href) tag is wrong and I think your JAVA code should be like this:

       String a = "<a href='" + urlcount + "'>" + urlcount + "</a>";