Issue with TagManager in Publish for anonymous users

Sh1ju 13-11-2018

Hi,

I just wrote a Servlet to display Tag Title .Its working in Author ,but getting Null pointer exception in Publish (only for anonymous users) .Can you please check the issue ?

protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {

ResourceResolver resourceRes =request.getResourceResolver();

Tag tag = null;

String tagID="some tag ID";

TagManager tagManager = resourceRes.adaptTo(TagManager.class);

PrintWriter out=response.getWriter();

try {

tag=tagManager.resolve(tagID);

if(null!=tag)

{

out.println("Tag Title....."+tag.getTitle());

}

else

{

out.println("Tag Title.....is NULL");

}

}

catch(Exception e)

{

out.println("Exception : "+e.getMessage());

}

}

Accepted Solutions (0)

Answers (0)