sling servlet | Community
Skip to main content
kevinl17371805
Level 2
Oct 24, 2018 9:06 PM UTC
Solved

sling servlet

Hello, I am in the process of learning about the servlet sling 
if you could please help me with a simple example of how to
save a name or any other data in a node of the crx using
the servlet sling I appreciate the collaboration

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
arunpatidar
arunpatidarAccepted solution
New Participant
Oct 25, 2018 6:06 AM UTC

Hi,

Below servlet upload an Assets in JCR, similarly you can add node by using JCR Node API.

// Store content

Session session = request.getResourceResolver().adaptTo(Session.class);

Node adobe = req.getResourceResolver().getResource("/parent/node/path").adaptTo(Node.class);

Node day = adobe.addNode("adobe");

day.setProperty("message", "Adobe Experience Manager is part of the Adobe Digital Marketing Suite!");

session.save();

aem63app-repo/UploadAssets.java at master · arunpatidar02/aem63app-repo · GitHub

Arun Patidar

2 replies

arunpatidar
arunpatidarAccepted solution
New Participant
Oct 25, 2018 6:06 AM UTC

Hi,

Below servlet upload an Assets in JCR, similarly you can add node by using JCR Node API.

// Store content

Session session = request.getResourceResolver().adaptTo(Session.class);

Node adobe = req.getResourceResolver().getResource("/parent/node/path").adaptTo(Node.class);

Node day = adobe.addNode("adobe");

day.setProperty("message", "Adobe Experience Manager is part of the Adobe Digital Marketing Suite!");

session.save();

aem63app-repo/UploadAssets.java at master · arunpatidar02/aem63app-repo · GitHub

Translate
Arun Patidar
Nirmal_Jose
Employee
Oct 25, 2018 3:00 AM UTC