gudii9
asked on
session tracking
Hi,
I was reading about session tracking and cookie example here.
http://www.javatpoint.com/session-tracking-in-servlets
http://www.javatpoint.com/cookies-in-servlet
What is use of session tracking which method is preferable for session tracking aong the 4 methods.
What is difference between persistent and non persisten cookie.
I was thinkingin if user closes browse he automatically logs out. In that case there will all persistent cookies right?
How Gmail uses it. How to test it using my gmail account.
To which browser does it add IE or mozilla browser?. Or does it add to all browsers. How to know that
To delete a cookie do i need to do all above 3 steps like deleting value, changing max age to 0 sec and then adding cookie to response?
What author meant by
If servlets residing in different web servers can i still access cookie object as demonstrated in above example in the link.
when i ran this example
I got index.html. I entered name as 'xyz'
i went to servlet1 page which said
'Welcome xyz' with go button.
when i click go button instead of going to servlet2 (with hello xyz)
i got error as below. how to fix this error
HTTP Status 405 - HTTP method GET is not supported by this URL
type Status report
message HTTP method GET is not supported by this URL
description The specified HTTP method is not allowed for the requested resource.
Apache Tomcat/7.0.42
please advise
Any links resources ideas highly appreciated. Thanks in advance
I was reading about session tracking and cookie example here.
http://www.javatpoint.com/session-tracking-in-servlets
http://www.javatpoint.com/cookies-in-servlet
What is use of session tracking which method is preferable for session tracking aong the 4 methods.
There are 2 types of cookies in servlets.
Non-persistent cookie
Persistent cookie
Non-persistent cookie
It is valid for single session only. It is removed each time when user closes the browser.
Persistent cookie
It is valid for multiple session . It is not removed each time when user closes the browser. It is removed only if user logout or signout.
What is difference between persistent and non persisten cookie.
I was thinkingin if user closes browse he automatically logs out. In that case there will all persistent cookies right?
Note: Gmail uses cookie technique for login. If you disable the cookie, gmail won't work
How Gmail uses it. How to test it using my gmail account.
Cookies are maintained at client sideEven though they are maintained at client side is it not server adding cookie to to browser using response as explained below
Introduction to Servlet
What is Servlet Servlet Terminology Servlet API Servlet Interface GenericServlet HttpServlet Servlet Life Cycle Servlet Example How servlet works? War File welcome-file-list Load on startup
Servlet with IDE
servlet in Eclipse servlet in Myeclipse servlet in Netbeans
ServletRequest
Servlet Collaboration
RequestDispacher sendRedirect
ServletConfig
ServletContext
Attribute in Servlet
Session Tracking
Session Techniques 1) Cookies in Servlet Cookies: Login & Logout 2) Hidden Form Field 3) URL Rewriting 4) HttpSession Session: Login & Logout
Event and Listener
Servlet Filter
What is Filter Authentication Filter FilterConfig Useful examples
Servlet Miscellaneous
ServletInputStream ServletOutputStream Annotation Servlet SingleThreadModel SSI
Development
Registration Example Fetching records Improving Performance Uploading file Downloading file Servlet Sending Email Write data to PDF Login Example Writing Image
Servlet Quiz
Servlet Quiz(Part-1) Servlet Quiz(Part-2) Servlet Quiz(Part-3)
space
next>> <<prev
Cookies in Servlet
A cookie is a small piece of information that is persisted between the multiple client requests.
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.
How Cookie works
By default, each request is considered as a new request. In cookies technique, we add cookie with response from the servlet. So cookie is stored in the cache of the browser.
To which browser does it add IE or mozilla browser?. Or does it add to all browsers. How to know that
How to delete Cookie?
Let's see the simple code to delete cookie. It is mainly used to logout or signout the user.
Cookie ck=new Cookie("user","");//deleting value of cookie
ck.setMaxAge(0);//changingthe maximum age to 0 seconds
response.addCookie(ck);//adding cookie in the response
To delete a cookie do i need to do all above 3 steps like deleting value, changing max age to 0 sec and then adding cookie to response?
Simple example of Servlet Cookies
In this example, we are storing the name of the user in the cookie object and accessing it in another servlet. As we know well that session corresponds to the particular user. So if you access it from too many browsers with different values, you will get the different value.
What author meant by
. So if you access it from too many browsers with different values, you will get the different value.
If servlets residing in different web servers can i still access cookie object as demonstrated in above example in the link.
when i ran this example
I got index.html. I entered name as 'xyz'
i went to servlet1 page which said
'Welcome xyz' with go button.
when i click go button instead of going to servlet2 (with hello xyz)
i got error as below. how to fix this error
HTTP Status 405 - HTTP method GET is not supported by this URL
type Status report
message HTTP method GET is not supported by this URL
description The specified HTTP method is not allowed for the requested resource.
Apache Tomcat/7.0.42
please advise
Any links resources ideas highly appreciated. Thanks in advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.