title: How to access XSSAPI from custom jsp Java class?
body: <p>I am creating a custom tag library using <a href="http://www.cqblueprints.com/xwiki/bin/view/Blue+Prints/Writing+A+JSP+Custom+Tag+Library" rel="nofollow">http://www.cqblueprints.com/xwiki/bin/view/Blue+Prints/Writing+A+JSP+Custom+Tag+Library</a> to produce XSS-proof links from my custom components. I have taken this to a tag since I will need to do other bits of work and to avoid writing scriptlets on the JSP files (I have posted the code at the end).</p>
  
  <p>I wanted to use the XSSAPI from my Java class, but looking at the <a href="http://dev.day.com/docs/en/cq/current/javadoc/com/adobe/granite/xss/XSSAPI.html" rel="nofollow">javadoc for XSSAPI</a> I see that it's an interface; when using it in a JSP file it's an object that is initialized invoking <code>&lt;cq:defineObjects/&gt;</code>.</p>
  
  <p>Does anyone have any ideas on how to do this? There is a method in the XSSAPI class called <code>getRequestSpecificAPI(slingRequest)</code> but it's not static, and I have run out of ideas right now.</p>
  
  <pre class="lang-java prettyprint-override"><code>@JspTag
  public class FixInternalLinkTag extends CqSimpleTagSupport {
  
      private String pathToPage;
  
      @Override
      public void doTag() throws JspException, IOException {    
  
          XSSAPI xssAPI; // ToDo how to get a reference to this?
          urlPointingToPage = xssAPI.getValidHref(urlPointingToPage);
  
          getJspWriter().write(urlPointingToPage);
      }
  
      public String getPathToPage() {
          return pathToPage;
      }
  
      @JspTagAttribute(required = true, rtexprvalue = true)
      public void setPathToPage(String pathToPage) {
          this.pathToPage = pathToPage;
      } 
  }
  </code></pre>