Please enable JavaScript.
Coggle requires JavaScript to display documents.
SERVLET - Coggle Diagram
SERVLET
Session Tracking
-
- Http protocol is a stateless so we need to maintain state using session tracking techniques.
- Each time user requests to the server, server treats the request as the new request. So we need to maintain the state of an user to recognize to particular user.
-
-
HTTP Session
To use Java servlet API, first create a session object using getSession method in HttpServletRequest
-
HttpSession class provides the method for reading & storing data to the session and for manipulating the session
-
Method
getSession( createNew)
-
createNew - if true, create new HttpSession object if does not exist
-
-
-
-
Cookie Method
public String getName() : Returns the name of the cookie. The name cannot be changed after creation.
-
-
-
URL Rewritting
-
-
When the user clicks the hyperlink, the parameter name/value pairs will be passed to the server.
From a Servlet, we can use getParameter() method to obtain a parameter value.
Cookies
How Cookie works??
-
-
If the request is sent by the user, cookie is added with request by default.
Cookie can have expired dates set, after which the cookies will not be sent to the server.
- Small test files that stores sets of name=value pairs on the disk in the client's computer
A cookie has a name, a single value, and optional attributes such as a comment, path and domain qualifiers, a maximum age, and a version number.
Hidden Values
-
We can track session by passing data from servlet to the client as hidden value in a dynamically generated HTML form
-
Cookie Constructor
Cookie(String name, String value) : constructs a cookie with a specified name and value.
-
-
-