Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
gnishant
gnishantAccepted solution
Level 2
Oct 16, 2015 2:27 AM UTC

See if request processor can help you achieve this. 

Sample Snippet would be

 
  1. SlingRequestProcessor requestProcessor = sling.getService(SlingRequestProcessor.class);
  2. RequestResponseFactory requestResponseFactory = sling.getService(RequestResponseFactory.class);
  3. HttpServletRequest request = requestResponseFactory.createRequest("GET", "/content/geometrixx-media/en/mycustompage.html");
  4.  
  5. ByteArrayOutputStream out = new ByteArrayOutputStream();
  6.  
  7. HttpServletResponse response = requestResponseFactory.createResponse(out);
  8. requestProcessor.processRequest(request, response, resourceResolver);
  9.  
  10. html = new String(out.toByteArray(), "UTF-8");
  11.  

8 replies

smacdonald2008
Level 10
Oct 16, 2015 2:27 AM UTC

Please do not attach new questions on old threads. Start a new question. You will increase your chances of getting a response. 

Translate
Level 2
Oct 16, 2015 2:27 AM UTC

Hi Sham,

I am trying to send the html contents through mail.

Translate
Level 2
Oct 16, 2015 2:27 AM UTC

Hi,

I have similar requirement like pulling complete page details and adding same into email with same format (including images and RTE content). 

Could you please let me know how this can be done ?

Thanks,

Hari

Translate
Sham_HC
Level 10
Oct 16, 2015 2:27 AM UTC

What you planning to do with retrieved html content?  Send an email OR embed in other page OR store in local file etc..   Explain the exact use case.

Translate
Level 2
Oct 16, 2015 2:27 AM UTC

Hi,

I have a cq:Page i just need to get the HTML format of that page in a string.

Say /content/geometrixx/en.html I need to get the value of the html in a string.

I dont want to use" URL url = new URL(url for the page);" or any other methods which basically returns the html of the "url" sent.

Does cq provide any api's or methods which does the same.

Translate
Level 2
Oct 16, 2015 2:27 AM UTC

gnishant wrote...

See if request processor can help you achieve this. 

Sample Snippet would be

 
  1. SlingRequestProcessor requestProcessor = sling.getService(SlingRequestProcessor.class);
  2. RequestResponseFactory requestResponseFactory = sling.getService(RequestResponseFactory.class);
  3. HttpServletRequest request = requestResponseFactory.createRequest("GET", "/content/geometrixx-media/en/mycustompage.html");
  4.  
  5. ByteArrayOutputStream out = new ByteArrayOutputStream();
  6.  
  7. HttpServletResponse response = requestResponseFactory.createResponse(out);
  8. requestProcessor.processRequest(request, response, resourceResolver);
  9.  
  10. html = new String(out.toByteArray(), "UTF-8");
  11.  

 

Thnaks a lot for the snipet.

Translate
gnishant
gnishantAccepted solution
Level 2
Oct 16, 2015 2:27 AM UTC

See if request processor can help you achieve this. 

Sample Snippet would be

 
  1. SlingRequestProcessor requestProcessor = sling.getService(SlingRequestProcessor.class);
  2. RequestResponseFactory requestResponseFactory = sling.getService(RequestResponseFactory.class);
  3. HttpServletRequest request = requestResponseFactory.createRequest("GET", "/content/geometrixx-media/en/mycustompage.html");
  4.  
  5. ByteArrayOutputStream out = new ByteArrayOutputStream();
  6.  
  7. HttpServletResponse response = requestResponseFactory.createResponse(out);
  8. requestProcessor.processRequest(request, response, resourceResolver);
  9.  
  10. html = new String(out.toByteArray(), "UTF-8");
  11.  
Translate
Ojjis
Level 7
Oct 16, 2015 2:27 AM UTC

Hi,
can you explain more what you are trying to do here ?

/Johan

Translate