Wednesday, April 22, 2015

JSP and Servlet

1. Server configuration
2. Create web dynamic project in eclipse
3. create html file in WebContent folder.
4. Tomcat takes care of initialization of servlet, tomcat create response and request object per access. Servlet object get reused, every time a new thread created by tomcat per access.
5. HTTP protocol is stateless protocol
    HTTP protocol doesnt remember parameters.
6. Session object give by tomcat to save the data value during the execution of data
7. to get session object

HTTPSession session = request.getSession();
session.setAttribute("savedusername", value);
session.getAttribute("savedusername");

session object is per user/machine/browser
object available across request
every request object has a handle to the session object

8. Context Object:
more than session object
across entire application
shared across servlets and user
ServletContext context= request.getServletContext();
context.setAttribute("savedusername", value);
context.getAttribute("savedusername");

No comments:

Post a Comment