<%@ include file="/libs/foundation/global.jsp" %><%
%><%@ page contentType="text/html; charset=utf-8" import="
java.net.*,
java.io.*,
org.apache.sling.jcr.api.SlingRepository,
javax.jcr.Session"
%>
<%
/***
MUST ACTIVATE ALL PAGE IN ORDER TO DISPATCH WHOLE SITE
***/
try{
String path = "/content/test_search/";
final Session adminSession = currentNode.getSession();
Node pageNode = (Node)adminSession.getItem(path);
NodeIterator pageNodes = pageNode.getNodes();
while (pageNodes.hasNext()){
Node node = (Node) pageNodes.next();
getChild(node, out);
if (node.hasProperty("jcr:primaryType")){
String s = node.getProperty("jcr:primaryType").getString();
if (s.equals("cq:Page"))
{
out.println("http://127.0.0.1:8010" + node.getPath() + ".html<br />");
URL hp = new URL("http://127.0.0.1:8010" + node.getPath() + ".html");
URLConnection hpCon = hp.openConnection();
InputStream input = hpCon.getInputStream();
}
}
}
}
catch(Exception e){
out.println(e.toString());
}
%>
<%!
public void getChild(Node node, JspWriter out){
try{
NodeIterator pages = node.getNodes();
while (pages.hasNext()){
Node node2 = (Node) pages.next();
out.println(node2.getPath() + "<br />");
if (node2.hasProperty("jcr:primaryType")){
String s = node2.getProperty("jcr:primaryType").getString();
if (s.equals("cq:Page"))
{
//out.println("http://127.0.0.1:8010" + node2.getPath() + ".html<br />");
URL hp = new URL("http://127.0.0.1:8010" + node2.getPath() + ".html");
URLConnection hpCon = hp.openConnection();
InputStream input = hpCon.getInputStream();
}
}
getChild(node2, out);
}
}
catch(Exception e){
try{
out.println(e.toString());
}
catch(Exception ex){}
}
}
%>
2013年11月19日 星期二
2013年10月3日 星期四
jsp/java - session get item (with absolute path) (JSP)
import org.apache.sling.jcr.api.SlingRepository
import javax.jcr.Session
final SlingRepository repository = sling.getService(SlingRepository.class);
final Session adminSession = repository.loginAdministrative(null);
Node pageNode = (Node)adminSession.getItem(currentPage.getPath());
OR
final Session session = currentNode.getSession();
javascript - make http get request
var url = CQ.HTTP.externalize(path + CQ.Sling.SELECTOR_INFINITY + CQ.HTTP.EXTENSION_JSON, true);
var response = CQ.HTTP.get(url);var data = CQ.HTTP.eval(response);
var response = CQ.HTTP.get(url);var data = CQ.HTTP.eval(response);
訂閱:
文章 (Atom)