PLEASE HELP ME IN UNDERSTANDING COOKIES.ALSO HTTPSESSION INTERFACE FUNDAS.
Stop The World I Want To Get Off.
Mark Simms
Ranch Hand
Joined: Jul 20, 2000
Posts: 36
posted
0
Heck - there's a good example provided with Tomcat: Just remember, cookies are nothing more than small files stored on the user's hard drive that have a certain expiration date. You can store up to 4k of string data in any cookie. If you encode your data properly, you can remember all sorts of things....userid, password, preferences, etc. Always remember, the user can delete their cookies at any time or turn them off at the browser....therefore it is always good practice to check for this condition first..... Tomcat and other apps use a single cookie to track the sessionid of the user and the cookie name is the same as the session id.
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<html>"); out.println("<body bgcolor=\"white\">"); out.println("<head>"); String title = rb.getString("cookies.title"); out.println("<title>" + title + "</title>"); out.println("</head>"); out.println("<body>"); // relative links // XXX // making these absolute till we work out the // addition of a PathInfo issue