J2EE in AEM — Interview Questions and Answers
What is the role of J2EE in AEM?
AEM is built on top of J2EE. It uses many J2EE concepts like Servlets, JSP (or HTL), Filters, OSGi, and REST APIs for backend development.
Basically, AEM runs inside an application server (like a J2EE web app) and follows the same request-response model.
What J2EE technologies are used inside AEM?
- Servlets – handle requests and responses
- JSP / HTL – for rendering front-end content
- Filters – for request pre-processing
- JDBC / ORM – when integrating with databases
- Web Services (REST / SOAP) – for external integration
How does AEM use Servlets?
AEM uses Sling Servlets (built on J2EE’s HttpServlet) to handle requests.
Developers create custom servlets using SlingAllMethodsServlet and register them with OSGi annotations like: "sling.servlet.paths=/bin/example"
What is the difference between a normal Java Servlet and an AEM Sling Servlet?
Normal Servlet
- Uses @WebServlet
- URL Mapped Manually
- Run in Java webapp
AEM Sling Servlet
- Registered as an OSGi component
- URL handled by Sling using resource type or path
- Runs inside AEM (Sling framework)
What is a Filter in J2EE and how is it used in AEM?
- A Filter in J2EE intercepts requests before they reach the servlet.
- In AEM, a Sling Filter (using @Component with sling.filter.scope) can be used for:
- Authentication
- Logging
- Request validation
- Custom headers
What is the role of JSP or HTL in AEM?
JSP and HTL are J2EE view technologies used to render content.
- Older AEM versions use JSP.
- New versions use HTL (Sightly), which is safer and cleaner.
How are OSGi services related to J2EE?
OSGi is an evolution of modular J2EE.
Instead of deploying a single WAR, AEM breaks logic into smaller bundles (JARs) that can be started or stopped individually.
Each OSGi bundle is like a small J2EE module.
What is MVC, and how does AEM follow it?
- Model (Java classes / Sling Models) — holds data and logic
- View (HTL / JSP) — displays content
- Controller (Servlets / Sling framework) — handles requests
- AEM follows MVC through Sling and HTL.
What is Dependency Injection (DI) and how is it used in AEM?
DI is a J2EE concept where an object’s dependencies are automatically provided.
In AEM, it’s done using: @Reference. @Inject
What are common design patterns used in AEM (from J2EE)?
- Singleton – For OSGi services
- Factory – For creating OSGi configurations
- MVC – For page structure
- DAO – For data access layers
How does Dispatcher relate to J2EE concepts?
Dispatcher is similar to a J2EE caching proxy.
It handles load balancing and static content caching, just like a web server sitting in front of a J2EE app