Adobe CQ - fetch HTML content from .jsp node

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 04:19:36

问题


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 without creating content node?

something like:

http://localhost:4502/apps/project-name/components/my-component/one.HTML

the .html content is needed for further rendering.


回答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



回答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.




回答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.



来源:https://stackoverflow.com/questions/19912078/adobe-cq-fetch-html-content-from-jsp-node

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!