Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Retrieve the HTML contents of a cq:Page

Avatar

Avatar
Validate 1
Level 2
Punith_Shetty
Level 2

Likes

8 likes

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 2
Punith_Shetty
Level 2

Likes

8 likes

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
View profile
Punith_Shetty
Level 2

15-10-2015

Hi,

Is there any way to retrieve the HTML contents of a cq:Page without using external jars/bundles.???

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 5
Level 2
gnishant
Level 2

Likes

5 likes

Total Posts

4 posts

Correct Reply

2 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Affirm 1
View profile

Avatar
Boost 5
Level 2
gnishant
Level 2

Likes

5 likes

Total Posts

4 posts

Correct Reply

2 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Affirm 1
View profile
gnishant
Level 2

15-10-2015

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.  

Answers (7)

Answers (7)

Avatar

Avatar
Validate 1
Level 2
Punith_Shetty
Level 2

Likes

8 likes

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 2
Punith_Shetty
Level 2

Likes

8 likes

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
View profile
Punith_Shetty
Level 2

15-10-2015

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.

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

15-10-2015

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

Avatar

Avatar
Validate 1
Level 2
Punith_Shetty
Level 2

Likes

8 likes

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 2
Punith_Shetty
Level 2

Likes

8 likes

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
View profile
Punith_Shetty
Level 2

15-10-2015

Hi Sham,

I am trying to send the html contents through mail.

Avatar

Avatar
Validate 10
Level 2
harikumar_marya
Level 2

Like

1 like

Total Posts

30 posts

Correct Reply

0 solutions
Top badges earned
Validate 10
Validate 1
Boost 1
View profile

Avatar
Validate 10
Level 2
harikumar_marya
Level 2

Like

1 like

Total Posts

30 posts

Correct Reply

0 solutions
Top badges earned
Validate 10
Validate 1
Boost 1
View profile
harikumar_marya
Level 2

15-10-2015

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

Avatar

Avatar
Boost 50
Level 10
Sham_HC
Level 10

Likes

160 likes

Total Posts

2,114 posts

Correct Reply

1,204 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 25
Boost 100
View profile

Avatar
Boost 50
Level 10
Sham_HC
Level 10

Likes

160 likes

Total Posts

2,114 posts

Correct Reply

1,204 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 25
Boost 100
View profile
Sham_HC
Level 10

15-10-2015

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.

Avatar

Avatar
Validate 1
Level 2
Punith_Shetty
Level 2

Likes

8 likes

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 2
Punith_Shetty
Level 2

Likes

8 likes

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
View profile
Punith_Shetty
Level 2

15-10-2015

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.

Avatar

Avatar
Boost 50
Level 6
Ojjis
Level 6

Likes

76 likes

Total Posts

198 posts

Correct Reply

95 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 25
Boost 10
View profile

Avatar
Boost 50
Level 6
Ojjis
Level 6

Likes

76 likes

Total Posts

198 posts

Correct Reply

95 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 25
Boost 10
View profile
Ojjis
Level 6

15-10-2015

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

/Johan