Rendering the Library Component in Custom JSP

Two ways we can render the library component in custom JSP,

1. Using WCM library component tag
2. Using Workspace render method

Using Library Component tag

After initializing workspace using init:workspace , you can use the below tag to render the library component

>wcm:libraryComponent name="Name of the component" >[Error Message]>/wcm:libraryComponent >

Using Workspace render method

String libComponentName="LibraryComponentName";
String libCompFinalStr="";
LibraryComponent libComp = null;
DocumentIdIterator docIds = wcmWorkspace.findByName(DocumentTypes.LibraryComponent,"LibraryComponentName");
if (docIds.hasNext()){
DocumentId did = (DocumentId);
newsLibComp = (LibraryComponent)wcmWorkspace.getById(did);
libCompFinalStr = wcmWorkspace.render(renderingContext, libComp);

output of the LibraryComponent will be in "libCompFinalStr" , you can display that string wherever you want


  1. jsp tag only works if your component is in the same library. Library option does not seem to work for tag.

    1. Based on the infocenter library option should work fine and below is the tld definition



      And it is working fine when I tested it like below from the JSP

      <wcm:libraryComponent name="test_img" library="anonymous">
      You do not have access to this item.

      probably you may need to raise PMR if it doesn't work as mentioned in info center .

  2. This comment has been removed by the author.

  3. Hi Siva,

    I have to three text element in a library. I need to fetch all three test element value at JSP. I need your help to do this.