Where should I create my Sling Servlets? | Community
Skip to main content
Level 2
Mar 29, 2019 8:31 PM UTC
Solved

Where should I create my Sling Servlets?

Hi. I have the following doubt I do not know which is the correct folder where I should create my java Servlets and Sling Servlets. I'm a little confused. I'd appreciate your help.

At the moment I have been creating the servlets here:

Link: https://i.imgur.com/L6VyOSK.png

This is a screenshot of my CRX:

Link: https://i.imgur.com/C6iRvf9.png

And this is my <build> tag in D:\myproject\core\pom.xml

Link: https://i.imgur.com/8E0LbiR.png

- What I do is place myself in "D:\my-project\core" and execute "mvn clean install" in the console

- I upload the .zip created in "D:\my-project\core\target" to AEM through the link http://localhost:4502/system/console/bundles

Greetings!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
smacdonald2008
smacdonald2008Accepted solution
Level 10
Apr 1, 2019 3:43 PM UTC

Correct - you create a Sling Servlet in Eclipse here  -- under the <packageName>.core.servlets:

Then you deploy your project and the Sling Servlet is deployed as part of the OSGi bundle.

Hope this helps.

5 replies

j2rojasrAuthor
Level 2
Apr 1, 2019 3:54 PM UTC

Thanks so much!

Translate
smacdonald2008
smacdonald2008Accepted solution
Level 10
Apr 1, 2019 3:43 PM UTC

Correct - you create a Sling Servlet in Eclipse here  -- under the <packageName>.core.servlets:

Then you deploy your project and the Sling Servlet is deployed as part of the OSGi bundle.

Hope this helps.

Translate
j2rojasrAuthor
Level 2
Apr 1, 2019 3:31 PM UTC

Hello smacdonald2008, thank you very much for your response.

If I understand correctly, then it is correct to create Java service/Sling Servlets in that folder called /core/servlets of my project.

Translate
smacdonald2008
Level 10
Mar 29, 2019 10:49 PM UTC

See this AEM Dev guide for best Dev practices!

Getting Started with AEM Sites - WKND Tutorial

Translate
smacdonald2008
Level 10
Mar 29, 2019 10:46 PM UTC

Never create Java service/Sling Servlets in CRXDE lite. That is an outdated practice. Always code your Servlets in your Maven generated projects.

Translate