Hi all.
Kindly let me know 2-3 use cases for writing AEM Servlets.
Why could these needs be not fulfilled using normal Java code?
Appreciate all your responses.
Thanks,
Rama.
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Few questions for you, when you review you might be able to answer your query
- If a Form is submitted from UI, what would you call on backend to process that Info? UI doesn't know Java Code and Java Programs cannot be accessed from UI
Hint: A servlet provides a URL which UI can hit and pass the information to.
In the end Servlet is Java Code, just it provides a URL what UI can submit information to
- You have a Dynamic component on page, like Search. You have 100 matching results, but UI only shows 5 at a time. When you want visit next 10 results, entire page should not be refreshed. How would this page 2 be rendered? From where will it get Info? How would backend know that page 2 info is needed now?
Hint: When you select Page 2, an HTTP call is made to a GET servlet. Informing the servlet that page-2 is requested. It gathers that info and gives it back to UI.
Again, Servlet is JAVA CODE, but via Servlet specific annotations, it provides a URL what that UI can interact with
Adobe Experience Manager (AEM) Servlets are Java classes that extend the SlingSafeMethodsServlet
or SlingAllMethodsServlet
classes and are used to handle HTTP requests and responses in an AEM application. While you can perform many tasks using normal Java code, AEM Servlets provide a specific set of functionalities that are tailored to the AEM environment. Here are two to three use cases where AEM Servlets are commonly used:
Handling Form Submissions and User Input:
RESTful API Endpoints:
Dynamic Content Aggregation:
In summary, AEM Servlets are specifically designed to address the needs of AEM applications, providing a convenient way to handle HTTP requests and interact with AEM's content repository and services.
Thanks Aanchal for this elaborate response. This is very useful stuff.
Now my query is why Servlets for these use cases?
How will it help when compared with a normal Java method? (I am not even aware what to compare Servlets with).
Coding? Performance? etc?
Thanks a lot.
Rama.
Few questions for you, when you review you might be able to answer your query
- If a Form is submitted from UI, what would you call on backend to process that Info? UI doesn't know Java Code and Java Programs cannot be accessed from UI
Hint: A servlet provides a URL which UI can hit and pass the information to.
In the end Servlet is Java Code, just it provides a URL what UI can submit information to
- You have a Dynamic component on page, like Search. You have 100 matching results, but UI only shows 5 at a time. When you want visit next 10 results, entire page should not be refreshed. How would this page 2 be rendered? From where will it get Info? How would backend know that page 2 info is needed now?
Hint: When you select Page 2, an HTTP call is made to a GET servlet. Informing the servlet that page-2 is requested. It gathers that info and gives it back to UI.
Again, Servlet is JAVA CODE, but via Servlet specific annotations, it provides a URL what that UI can interact with
I think you need to understand the basis of JavaEE vs JavaSE, I recommend reading this article to learn more: https://docs.oracle.com/javaee/6/firstcup/doc/gkhoy.html.
In short, A Java servlet is a Java programming language class that is used to extend the capabilities of servers(webservers) that host applications accessed by means of a request-response programming model. Servlets are typically used to process or store data, handle user requests, or generate dynamic content for a web application. This remains true for AEM, where a Sling Servlet is an extension of a regular Java servlet and runs over the OSGI framework through a servlet engine.
You can read more here:
https://javaee.github.io/tutorial/overview001.html
https://www.digitalocean.com/community/tutorials/java-web-application-tutorial-for-beginners
https://www.javatpoint.com/servlet-tutorial
https://sling.apache.org/documentation/the-sling-engine/servlets.html
Views
Replies
Total Likes
Hi,
Generally,, when we bring a concept forward, we explain the pains of existing system and cover how the new concept overcomes that.
Here for AEM Servlets, is there any such thing to compare with?
May be a Java OSGI Method. I know that a Java Method could create HTML and return. Servlets also create HTML and return.
Thanks,
Rama.
Views
Replies
Total Likes
Firstly, there is no specific entity called an 'AEM servlet.' AEM utilizes a stack of technologies that leverages the 'servlet engine' through the Sling framework. The accurate term to use would be 'Sling Servlet,' as it extends the functionality of a regular 'Servlet.' Understanding the broader concept of a "servlet" will provide insight into what a Sling Servlet does. It seems you may be inquiring about the basics of Java servlets and their distinctions from standard Java classes. This topic extends a bit beyond the scope of this forum. I recommend exploring the links I shared to gain a better understanding of what a Java servlet is and when/why it is useful.
Hope this helps
Views
Replies
Total Likes
Views
Likes
Replies