Expand my Community achievements bar.

SOLVED

How to export a json feed of a whole page using servlets

Avatar

Level 5

I need to export a json feed of my whole news page using servlets how can i export the JSON Feed Kindly give some solutions

@arunpatidar @SantoshSai  @DEBAL_DAS @Fanindra_Surat @lukasz-m @Pulkit_Jain_ 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @Nandheswara ,

Did you tried with one of the OOTB functionality? eg. http://localhost:4502/editor.html/content/we-retail/language-masters/en/men.model.tidy.json

ReferenceObtaining Page Information in JSON Format

If that doesn't suits your requirement , I would suggest to use Sling Model Exporter rather than servlet.

Exporting page content as JSON using Sling Model Exporter you can get below advantages

  • No need to write servlet to export data as JSON format
  • You can use same code which is written using Sling Model to render content and to export as JSON format

Sling model exporter is very useful when you want to publish your data to third party system’s or consuming within the site using ajax request if you have sling models and wants to serialize them,  by providing simple @Exporter annotations to the existing sling models you can convert your model to CaaS based URL.

Here is the github code: SampleSlingModelExporter.Java from Adobe-Consulting-Services

Reference: No Servlets Required: Exporting Data with Sling Models 

 

However, If you still want's to achieve it through Servlet - @arunpatidar has done POC on it, please refer: https://github.com/arunpatidar02/aem63app-repo/tree/master/java/page/json

 

Hope that helps!

Regards,

Santosh

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hi @Nandheswara ,

Did you tried with one of the OOTB functionality? eg. http://localhost:4502/editor.html/content/we-retail/language-masters/en/men.model.tidy.json

ReferenceObtaining Page Information in JSON Format

If that doesn't suits your requirement , I would suggest to use Sling Model Exporter rather than servlet.

Exporting page content as JSON using Sling Model Exporter you can get below advantages

  • No need to write servlet to export data as JSON format
  • You can use same code which is written using Sling Model to render content and to export as JSON format

Sling model exporter is very useful when you want to publish your data to third party system’s or consuming within the site using ajax request if you have sling models and wants to serialize them,  by providing simple @Exporter annotations to the existing sling models you can convert your model to CaaS based URL.

Here is the github code: SampleSlingModelExporter.Java from Adobe-Consulting-Services

Reference: No Servlets Required: Exporting Data with Sling Models 

 

However, If you still want's to achieve it through Servlet - @arunpatidar has done POC on it, please refer: https://github.com/arunpatidar02/aem63app-repo/tree/master/java/page/json

 

Hope that helps!

Regards,

Santosh