Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Remember me on this computer (via cookies) in jsp servlet

Have Programming Question? Ask it here!
 
 
 


Anuj Kumar
Remember me on this computer (via cookies) in jsp servlet
2 Answer(s)      3 years and 9 months ago
Posted in : Java Beginners


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


Advertisement
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. In Servlet or JSP you can set
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
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
help me - JSP-Servlet
help me   how to open one compiled html file by clicking one button from jsp
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
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
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
setting the cookies in another domain - JSP-Servlet
setting the cookies in another domain  Hello, how can i set the cookies in another domain
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
help me on jstl- <c:url> - JSP-Servlet
help me on jstl c:url  what is jstl in java
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
Dialling from computer with other phone via modem card
Dialling from computer with other phone via modem card  Hello... a phone number through a modem connected in the computer. During research I ended up... scratch. It would be helpful if anyone pass me some reference links, tutorials
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
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
Cookies in JSP
depend on them. Second, as the author of JSP/servlet that use cookies, you...Cookies in JSP In this section, we will discuss about handling cookies in JSP... let you customize the look of the main page. They use cookies to remember what
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: http://roseindia.net/jsp/bank.shtml Thanks
Reading cookies in jsp
Reading cookies in jsp   How read cookies in jsp ?   Creates a cookie, a small amount of information sent by a servlet to a Web browser... uniquely identify a client, so cookies are commonly used for session management
Cookies in Servlet
Cookies in Servlet Cookies are text files that are sent by Servlet to the Web... computer. Cookies are used to track various informations. Whenever a browser...(javax.servlet.http.Cookie) method is used by servlet to send cookies to the browser
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
Reading excel via JSP
Reading excel via JSP   The problem is while reading cells values... CareerStart gopinath December can you help me in that and tell me how to ignore...;%=CareerStart%>></td> anyone please help me to resolve that space issue
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
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
help me to do it in jsp
to insert and update the topics via admin page. pls help me to do...help me to do it in jsp  if we click on a topic it should direct to another page in separate window i need to create a part of the web page which
Remember Me Login Application In JSF
:view> <html> <head> <title>Remember Me Login...<jsp:forward page="login.jsf" /> Here is the code...(this);" /> <h:outputLabel for="remember">Remember
Please help me to create this coding for pizza order application using a handheld computer.....
Please help me to create this coding for pizza order application using a handheld computer.....  You work as a programmer for IT-Tech a small... computer. You have been asked to develop a system, which runs on a PC. The software
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
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
please give me solution how to display next page after 20 records ? - JSP-Servlet
please give me solution how to display next page after 20 records ?  Java Servlet Paging control example  here i have attached one example code. function validate() { for(j=0;j<30;j
Jsp-Servlet
Jsp-Servlet  how can i display the values in jsp pages as list from servlet ? can you help me out plz ? thanks
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
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
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
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  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
servlet and jsp
servlet and jsp  how to connect an jsp and an servlet without connecting to database
jsp and servlet
jsp and servlet  what is the difference between jsp and servlet ? what is the advantages and disadvantages of jsp and servlet
JSP,Servlet - JSP-Servlet
JSP,Servlet  How can i pass a list of objects from jsp to an Action? Please help me to do
Servlet - JSP-Servlet
Servlet and Java Code  Example and source code in Servlet and JSP
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 - JSP-Servlet
JSP & Servlet Example Code  Need example of JSP & Servlet
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
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
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
 

 

 

DMCA.com