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

 
 


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

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 Pages:
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
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
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
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
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
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
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
help me - JSP-Servlet
help me   how to open one compiled html file by clicking one button from jsp
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
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
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 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
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
session - JSP-Servlet
session  please send me an example code for session tracking using cookies,url rewriting,hidden form fields?   Hi friend... that the Web server can't easily remember previous transactions.In session tracking
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
setting the cookies in another domain - JSP-Servlet
setting the cookies in another domain  Hello, how can i set the cookies in another domain
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
Servlet Redirecting - JSP-Servlet
Servlet Redirecting  Hi I have made a main page with User name... happens, pls help me sort out the problem, thanks Cde is as: //Slogin.java...*; public class Slogin extends HttpServlet implements Servlet { public void
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
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
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
help me on jstl- <c:url> - JSP-Servlet
help me on jstl c:url  what is jstl in java
Cookies
issuing the servlet response. Use the code below to delete all cookies...Cookies  How do I disable a cookie ?   The storage of cookies is controlled by their maximum age property. A positive value means
java - JSP-Servlet
java  can u tell me why httpservlet is abstract class  Hi friend, Some points remember to HttpServlet is abstract class : 1)Its... be overridden. 3)It implements the Servlet interface conveniently. 4)It means
how to access element added via javascript dynamically using jsp code
how to access element added via javascript dynamically using jsp code  Urgent..Anyone please Assist how to access data from the elements added via... for servlet concept...wants using jsp only.. thnks
Problem with cookies
Problem with cookies  Hello All, i need jsp code for RememberMe module of login. i am facing problem with cookies. so please if any one could guide me please help and provide mme the exact code.   Please visit
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
cookie - JSP-Servlet
cookie  Hi i want a solution to remember password when the user enters his Username and check Remember Me checkbox. When next time the user enters his username the password will automatically get displayed in the password box
load and upload. - JSP-Servlet
load and upload.  dear sir, plz give me the sol for my problem.i m waiting for u r reply. why u not replying ..   Hi Friend, We haven't remember your problem. So please send it again. Thanks
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
JSP,Servlet - JSP-Servlet
JSP,Servlet  How can i pass a list of objects from jsp to an Action? Please help me to do
Cookie Handling - JSP-Servlet
Cookie Handling  Hi i am working on the Application in which i... on a per user setting (probably via a cookie). This would of course mean that when..."; //get the array of cookies. Cookie cookies [] = request.getCookies
servlet not working properly ...pls help me out....its really urgent
servlet not working properly ...pls help me out....its really urgent  ... servlet to radio buttons f jsp is correct or not <%@page language="java... as the user click submit button he will reach to updation.java servlet through
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  how can i display the values in jsp pages as list from servlet ? can you help me out plz ? thanks
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
Servlet - JSP - JSP-Servlet
Servlet - JSP  Here is my complete code. all my code is running with out any error. the for loop in servlet is running as many times as my checkboxes.... They are returning -1 and -1. please let me know how to resolve it. 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
JSP/Servlet to read and update Excel
JSP/Servlet to read and update Excel  Hi Team, My requirement is based upon my input(name) value via one jsp, the program(jsp/servlet) should fetch.... Please help me. If anyone come up with the source code it ll be much
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
Problem in Servlet - Servlet Interview Questions
class path etc.. empController is my main servlet program and I called in form.... then some exception ..Servlet Exception: empContrller is not a servlet pgm.... please give me the solution. Sincerely Prakash  please see
java - JSP-Servlet
computer environment variable and in that i set the class path JAVA_HOME=c:\jdk141_05 CATALINA_HOME=c:\Tomcat5.0 CLASSPATH=C:\Tomcat 5.0\common\lib\servlet..."); pw.println("dravidcaptain"); pw.close(); } }please tell me what
List of Computer Software
List of Computer Software  Hi, I am looking for the list of Computer programming languages. Provide me the list of Computer Software used these days... for different purposes. See the List of Computer software. Thanks

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.