Remember me on this computer (via cookies) in jsp servlet

Remember me on this computer (via cookies) in jsp servlet

Remember me on this computer (via cookies) in jsp servlet

View Answers

October 25, 2010 at 7:27 PM

Hi,

Here is the detail of using cookies to identify the user.

In Servlet or JSP you can set the cookies for a user and then add it to the response object.

Here is the code of setting the cookies:

<%@ page language="java" import="java.util.*"%>
<%
// Generate this key And save In database And Set as cookies
String userIdendificationKey="dxkdyneimd@5786*54904";


Date now = new Date();
String timestamp = now.toString();
Cookie cookie = new Cookie ("userIdendificationKey",userIdendificationKey);
//Set the required cookies age
cookie.setMaxAge(365 * 24 * 60 * 60);
//Then add the cookies
response.addCookie(cookie);
%>

You can read the cookies and idenfity the user. Here is the sample code:

<%
String userIdendificationKey = "";
Cookie cookies [] = request.getCookies ();
Cookie myCookie = null;
if (cookies != null)
{
 for (int i = 0; i < cookies.length; i++) 
    {
    if (cookies [i].getName().equals ("userIdendificationKey"))
    {
        userIdendificationKey = cookies[i];
        break;
    }
   }
}
//Then use the userIdendificationKey And Get the user name from database 
//To identify the user
//Do whatever you want after identifying the user
%>

Let me know in the same post if you have any query.

Thanks


January 17, 2011 at 1:15 PM

hi,

Then what will happen if the customer deletes the cookies from browser menu ???

My requirement is to set the cookie in clients machine and retrieves whenever it needs for the application..









Related Tutorials/Questions & Answers:
Remember me on this computer (via cookies) in jsp servlet
Remember me on this computer (via cookies) in jsp servlet  Remember me on this computer (via cookies) in jsp servlet   Hi, Here is the detail of using cookies to identify the user.ADS_TO_REPLACE_1 In Servlet or JSP
Remember Me
Remember Me  How to Create a PHP AutoLogin ('Remember Me') Feature using Cookies????   Hi Friend, Please visit the following links: http.../tutorial/php/php-cookies.html http://www.roseindia.net/php/cookies
Advertisements
help me - JSP-Servlet
help me   how to open one compiled html file by clicking one button from jsp
servlet cookies - JSP-Servlet
servlet cookies  helo sir i need a servlet program which create a cookie and add userid's and passwords and read the userid and password from... in the webinf.xml and access them in the servlet by using the getInitParameters() method
cookies - JSP-Servlet
this problem. please help me I'm waiting for your valuable reply thanks in advance <% Cookie[] cookies = request.getCookies(); if (cookies == null) cookies = new Cookie[0]; String name
Please answer me - JSP-Servlet
servlet or jsp codes that I can use to insert and retrieve image from MSSQL 2000 NOT MySQL. Please assist me and for other questions I've asked before
plz help me!!!!!!!! - JSP-Servlet
plz help me!!!!!!!!  i`ve set the environment varaibles for tomcat as well as jdk.. but i`m not understanding where i`ve to save my servlet..i.e.... there are compilation errors.. plz do help me.   make sure that you did
Plz Plz reply Me - JSP-Servlet
the image.. I request you to remember the code which you have provided for me..., Read for more information. http://www.roseindia.net/jsp/pop-window.shtml
ModuleNotFoundError: No module named 'django-remember_me'
ModuleNotFoundError: No module named 'django-remember_me'  Hi, My... named 'django-remember_me' How to remove the ModuleNotFoundError: No module named 'django-remember_me' error? Thanks   Hi, In your
how to send email please give me details with code in jsp,servlet
how to send email please give me details with code in jsp,servlet  how to send email please give me details with code in jsp,servlet
how to maintain cookies throughout the website - JSP-Servlet
how to maintain cookies throughout the website  Hi to All, We... reply me as soon as possible. Thanks, Lakshminarayana  Hi friend, Read for more information. http://www.roseindia.net/jsp
how to maintain cookies throughout the website - JSP-Servlet
how to maintain cookies throughout the website  Hi to All, We... reply me as soon as possible. Thanks, Lakshminarayana  Hi friend... for loop retrieve at all the pages. Cookie cookies [] = request.getCookies
help me on jstl- <c:url> - JSP-Servlet
help me on jstl c:url  what is jstl in java
setting the cookies in another domain - JSP-Servlet
setting the cookies in another domain  Hello, how can i set the cookies in another domain
Plz reply me sir Its urgent - JSP-Servlet
Plz reply me sir Its urgent  Respected Sir/madam, I am R.Ragavendran..Actuaaly,I request you to remember the code which you have provided for me using radio buttons.. You have used the following syntax for checking whether
JSP-Servlet - JSP-Servlet
JSP-Servlet   how to pass the value or parameter from jsp page to servlet and view the passed value
JSP-Servlet - JSP-Servlet
JSP-Servlet   how to pass the value or parameter from jsp page to servlet and view the passed value
JSP-Servlet - JSP-Servlet
JSP-Servlet   how to pass the value or parameter from jsp page to servlet and view the passed value
i want code of signing off from a account how its done in jsp and servlet by using either cookies or session
i want code of signing off from a account how its done in jsp and servlet by using either cookies or session   sig
servlet/jsp - JSP-Servlet
servlet/jsp  Thanks for ur feedback! But this program shows... package.org.apache.commons.fileupload does not exists please help me its urgent... this problem you remember few points. 1.Download the jar "commons-fileupload-1.2
servlet and jsp - JSP-Servlet
servlet and jsp  can any one give me jsp-servlet related project-its urgent- 1-chat application 2-bug tracking system 3-online shopping 4-online...://www.roseindia.net/jsp/bank.shtml Thanks
Computer - JSP-Interview Questions
the image button through my servlet with out using the anchor tag kindly give solution... ForwardServlet extends HttpServlet{ private static final String forwardTo = "/jsp/ResultServlets"; private static final String includeIn = "/jsp/ResultServlets
Jsp-Servlet
Jsp-Servlet  how can i display the values in jsp pages as list from servlet ? can you help me out plz ? thanks
servlet/jsp - JSP-Servlet
servlet/jsp  hi, get me the source code to upload all file formats in servlet/jsp plaese help me as soon as possible its urgent!!! by saravanan.k  Hi friend, Code to help in solving the problem
Help me to create a sharing text just like facebook using jsp servlet and oracle
Help me to create a sharing text just like facebook using jsp servlet... some thing into public! so please help me to do this project. And one more thing is that i want to pass a value to servlet without refreshing the whole jsp
session realtime usage program simple jsp program or servlet ,which understands me importance of session
session realtime usage program simple jsp program or servlet ,which understands me importance of session  I knew importance of session theoritically like client state storage scope.,but jsp or servlet realtime simple session
Servlet - JSP - JSP-Servlet
Servlet - JSP  i used arraylist in servlet as shown ArrayList...",total); when I code this like in my jsp <%ArrayList<Integer> data= new... typecast or anything else. I'm sure mu k[i] have some value. please let me know
i want code of signing off from a account how its done in jsp and servlet by using either cookies or session
i want code of signing off from a account how its done in jsp and servlet by using either cookies or session   sig   Hi Friend, Please visit the following link:ADS_TO_REPLACE_1 http://roseindia.net/jsp/bank.shtml
jsp/servlet - JSP-Servlet
jsp/servlet  How to create and save the excel file on given location using jsp/servlet?  hi Geetanjali, Read for more information, http://www.roseindia.net/jsp/poi/excelPOI.shtml Thanks
JSP-Servlet - JSP-Servlet
JSP-Servlet   how to pass the value or parameter from jsp page to servlet and view the passed value.   Hi Friend, Please visit the following links: http://www.roseindia.net/tutorial/servlet/passParameters.html
JSP,Servlet - JSP-Servlet
JSP,Servlet  How can i pass a list of objects from jsp to an Action? Please help me to do
Distribute Servlet or JSP on network - JSP-Servlet
Distribute Servlet or JSP on network  Sir Even after successfully deploying a servlet or JSP program on J2EE web server I am not been able..." For any more problem on Servlet and Jsp visit to : http://www.roseindia.net
jsp servlet
jsp servlet  i dont know how to write a code to Create a JSP... button, send the request to a servlet .Once the servlet receives the request, it need to create a thread. so please help me in writing this code
jsp servlet
jsp servlet  i dont know how to write a code to Create a JSP... button, send the request to a servlet .Once the servlet receives the request, it need to create a thread. so please help me in writing this code
Jsp ,Servlet Problem - JSP-Servlet
Jsp ,Servlet Problem  hi, m new to jsp n Servlet. i really find ur tricks very effective.Last time u had helped me to connect my java program with oracle. it worked wonders. now i m starting jsp n servlet learning.. pls
JSP-Servlet
JSP-Servlet  Hi have created a JSP page and I need to print it when the user clicks on the print button. I have put a print button on the JSP page. Can somebody plz help me out with the Servlet page coding
jsp and servlet
jsp and servlet  what is the difference between jsp and servlet ? what is the advantages and disadvantages of jsp and servlet
servlet and jsp
servlet and jsp  how to connect an jsp and an servlet without connecting to database
JSP - JSP-Servlet
JSP  HI! Every body............. Please send me any simple code for chatting using JSP and servlet... Advance wishes... Happy Pongal
JSP - JSP-Servlet
JSP & Servlet Example Code  Need example of JSP & Servlet
About jsp and Servlet - JSP-Servlet
About jsp and Servlet  Servlets are directly using java technologies. It is used in HTTP,FTP..etc, But Jsp only used in HTTP. Servlets are running fastly... Then why we moved from Servlet to JSP.. Pl Tell me the reasons
jsp code - JSP-Servlet
jsp code  Can anyone help me in writing jsp/servlet code to retrieve files and display in the browser from a given directory.  Hi Friend, Try the following code: Thanks
servlet - JSP-Servlet
and JSP Examples. Servlet and JSP Examples...servlet  hiii.....!!! pls help me answering this.... what can be the xml code which will describe a servlet and mapps an instance
Servlet - JSP-Servlet
Servlet and Java Code  Example and source code in Servlet and JSP
JSP - JSP-Servlet
in JSP. I have a small doubt. Is it possible to write a database connection without creating DSN in control panel. If Possible tell me how. Thanks in advance....  Hi friend, Steps to be remember for solving the problem
jsp servlet
code to Create a JSP with one text field to enter the URL and a submit button  i dont know how to write a code to Create a JSP with one text field... the request to a servlet .Once the servlet receives the request, it need to create
jsp servlet
how to write a code to Create a JSP with one text field to enter the URL  i dont know how to write a code to Create a JSP with one text field... to a servlet .Once the servlet receives the request, it need to create a thread
servlet and jsp - JSP-Servlet
servlet and jsp  Hello folks, I am very new JDBC. I am doing a project on java messaging service on the part of the project we are using JDBC. In my...   write in the jsp form action="path of servlet" and wirite
JSP & Servlet - JSP-Servlet
help me with coding ? i'm just a beginner with JSP and sServlets...JSP & Servlet  In the process of login validation. i'm entering the username correct and pass wrong. when using response.sendRedirect() a new req
JSP & Servlet - JSP-Servlet
is wrong ? can any one help me with coding ? i'm just a beginner with JSP...JSP & Servlet  Its an IBM Question In the process of login validation. i'm entering the username correct and pass wrong. when using

Ads