Skip to content Skip to sidebar Skip to footer

Adobe Cq - Fetch Html Content From .jsp Node

Have .jsp file under /components path looks like: http://localhost:4502/apps/project-name/components/my-component/one.jsp Is it possible get HTML content of this one.jsp by url wi

Solution 1:

As far as i know, you cannot get the html content from the JSP directly by providing the path to the jsp file. It displays the content in the JSP as is without compiling.

One possible way is to create an nt:unstructured node with the sling:resourceType property set to the path of the jsp (something like below)

test: {
    sling:resourceType: "/apps/geometrixx/components/title/one.jsp",
    jcr:primaryType: "nt:unstructured"
}

And you can provide the path to the test node to get the html rendered by the jsp.

/apps/geometrixx/components/title/test

Solution 2:

Your question is a bit vague but as far as i get it, you want to retrieve the html for the whole page which can be done by reading the input stream from a URL using java.net.URL utility.

May be you can also place an iframe inside your other jsp to get the contents.

Solution 3:

You could always use a traditional .html file instead of a .jsp, but (perhaps obviously) you will lose all the server side capabilities afforded by JSP.

It is also worth noting that anonymous access is typically denied to /apps for security reasons, so this .html file would not be reachable on a publish instance with OOTB permissions.

Post a Comment for "Adobe Cq - Fetch Html Content From .jsp Node"