1. What is a container? Servlets don’t have a main method , they are under the control of another java application ,Container. Tomcat is an example of a container. When web server gets a request for a servlet (not a static html) page it hands the request not to the servlet but to the container Life without Container Networking : Create a socket connection with the server and create a listener for the socket Threading : Create a thread manager Security : Implement security Filtering things like logging JSP support Memory management Life with it Communications Support : Container knows the protocol b/w itself and web server Lifecycle management : life and death of servlets.loading,instantiating,initializing,invoking methods and making it eligible for garbage collection Multithreading support : creates a new thread for every servlet request.Synchronization has still to be taken care of. Declarative Security : security is configured in xml dd, don’t have to hardcode it. JSP support : translates jsp to servlets
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1. What is a container?Servlets don’t have a main method , they are under the control of another java application ,Container.Tomcat is an example of a container.When web server gets a request for a servlet (not a static html) page it hands the request not to the servlet but to the container
Life without Container
Networking : Create a socket connection with the server and create a listener for the socket
Threading : Create a thread manager
Security : Implement security
Filtering things like logging
JSP support
Memory management
Life with it
Communications Support : Container knows the protocol b/w itself and web server
Lifecycle management : life and death of servlets.loading,instantiating,initializing,invoking methods and making it eligible for garbage collectionMultithreading support : creates a new thread for every servlet request.Synchronization has still to be taken care of.Declarative Security : security is configured in xml dd, don’t have to hardcode it.JSP support : translates jsp to servlets
2. How the container handles a request
3. How should the container map servlets to URL’s
4. Servlet has 3 namesa. Client knoiwn URL Nameb. Deployer known internal namec. Actual file name
5. DD gives a declarative mechanism for customizing your web application without touching application code.
6. U can use DD to customize other aspects of your web app a. Security rolesb. Error pagesc. Tag libraries
d. Initial configuration informatione. And if full J2EE sever,you can even declare that you’ll be accessing specific EJB’s
Advantages of DD
Touching source code
Fine tuning App
Adapt to different resources
Dynamic security
Lets Non-programmers deploy
Gag : dilbertian job
7. Seperation of concerns : MVC
With the business logic in a standalone java class,it can be reused,hence it shud not be in the servlet
Never assume business logic will be always accessed from the web
Spec always changes
8. Task and responsibilities
9. J2EE containerIt’s a super spec, it includes other specifications
a. Servlets 2.4b. JSP2.0c. EJB 2.1
10. Web Container(Servlets and JSP) is for web components and EJB container is for business components.
11. A fully complaint J2EE container must have a web container and an EJB container along with other things likeJNDI and JMS implementation
12. Tomcat container does have the ability to act as basic HTTP server.
13. But for HTTP server capability tomcat is not as robust as Apache web server14. Common J2EE server’s : BEA –weblogc,JBoss AS,IBM-Websphere