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



Home Answers Viewqa Java-Beginners cookie creation without specifying the vaue
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


sowmya
cookie creation without specifying the vaue
1 Answer(s)      6 years and a month ago
Posted in : Java Beginners



Advertisement
View Answers

October 31, 2008 at 3:50 PM


Hi friend,


I have created cookie and store the cookie value of username.

String username = request.getParameter("username");


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class UseCookies extends HttpServlet {
public void doGet ( HttpServletRequest request,
HttpServletResponse response )throws ServletException, IOException {
PrintWriter out;
response.setContentType("text/html");
out = response.getWriter();

String username = request.getParameter("username");
Cookie cookie = new Cookie("username",username);
cookie.setMaxAge(100);
response.addCookie(cookie);

out.println("<HTML><HEAD><TITLE>");
out.println(" Use of cookie in servlet");
out.println("</TITLE></HEAD><BODY BGCOLOR='cyan'>");
out.println(" <b>This is a Cookie example</b>");
out.println("</BODY></HTML>");
out.close();
}
}

For any problem plz give in details and source code and visit to :

http://www.roseindia.net/servlets/use-cookie-servlet.shtml
http://www.roseindia.net/servlets/send-cookies-in-servlets.shtml

Thanks


Related Tutorials/Questions & Answers:
cookie creation without specifying the vaue - Java Beginners
cookie creation without specifying the vaue  how do we create cookies using java servlets by just specifying the name and not providing the value for it.because my colleague said once cookie is created value will be assigned
connect database without specifying dsn name in java
connect database without specifying dsn name in java  How can i connect the database with my application without specifying the dsn name by using jdbc & odbc..... i have saw this code on the web-site try
Advertisements
Drop constraint of table in oracle without specifying constraint name
Drop constraint of table in oracle without specifying constraint name  I create my table in oracle with check constraint but I forgot constraint name.Now I want to drop constraint of my table without specifying constraint name
without ;
without ;  can u give me an example of a program without
without ;
without ;  can u give me an example of a program without
Cookie in jsp
Cookie in jsp  Define Cookie in jsp ?   The cookie file is a file that resides on the client machine. It contains data passed from web... returns. The web site only has access to the part of the cookie file that represents
Persistent Cookie
Persistent Cookie  What Is a Persistent Cookie?   Hi friends, A persistent cookie is a cookie which is stored in a cookie file permanently... because users can open cookie files see the cookie values. Thanks
Clear cookie example
. It floats the alert box showing the successful creation of the cookie... Clear Cookie Example    .... The example below shows how to delete the cookie from the browser using
What Is a Persistent Cookie?
What Is a Persistent Cookie?  What Is a Persistent Cookie?. Explain
How to reset a cookie?
How to reset a cookie?  How to reset a cookie
set cookie in jsp
set cookie in jsp  How set cookie in jsp ?   Cookie... cookie to identify the user in the next time visit.Example : <% Cookie cookie = new Cookie("ClientName","Roseindia"); cookie.setMaxAge(3600
How to destroy a cookie?
How to destroy a cookie?  How to destroy a cookie
Setting Cookie
Setting Cookie  setcookie function is used for setting up a cookie. In the following example, if you use $_COOKIE command, you will view one cookie value, and if you see print_r ($_COOKIE), you will view all cookie value. We have
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
Cookie methods in jsp
Cookie methods in jsp   Define cookie methods in jsp ?    Cookie methods : clone() getComment() getDomain() getMaxAge() getName() getPath() getSecure() getValue() getSecure() getVersion
Write cookie and session to textfile?
Write cookie and session to textfile?  I want to store all data from user submisstion into a textfile, include session and cookie. Thanks
Removing existing cookie in jsp
Removing existing cookie in jsp  How remove existing cookie in jsp ?   If you want to remove an existing cookie, you can use the method setMaxAge() of that cookie object to set its timeout to zero.Example <%@page
Delete Cookie
the cookie through setting session.  In the given example, we have set the value of cookie after one month of generating and before one hour of system date.  For deleteing the cookies, you will have to set the cookie expire time ahead
Is session depend on cookie ???
Is session depend on cookie ???  Since I created one session & as we say that session store at server side that means if I clear browser cookie... the cookie then my user logged out that means there is something behind session
problem with cookie - Struts
problem with cookie  struts cookies response - Hii, I am a beginner in struts..Well, I try to add username and group(or whatever) to a cookie but not able to access the cookie value in the next page after submitting the form
cookie and session dependency
cookie and session dependency  Hi, I am currently working on a project in travel domain. Throughout the application, we have not used cookie for session tracking but the case when browser cookie is disabled, session value differs
Differences between session and cookie
Differences between session and cookie  What are the differences between session and cookie?   Session is stored in server but cookie.... But it is limited in cookie. Session can store objects and cookies can store only
cookie - Java Beginners
cookie  i want to display cookie name and value on web page how? ...- cookie_name = "dataCookie"; var YouEntered; function putCookie... = document.cookie.indexOf(cookie_name); } else { index = -1
How can we destroy the cookie?
How can we destroy the cookie?   How can we destroy the cookie
javascript cookie - Java Beginners
attribute of cookie in javascript. heres the code : document.cookie = 'cookie2=Second_cookie'; expires=Mon, 17-Aug-09 04:42:00 GMT; path="/"'; whats wrong... to set the cookie and expire the cookie: function getCookie(cookieName
cookie - JSP-Servlet
. I know it can be done through cookie but i dont knw how canx somebody post
Cookie Tag:
Cookie Tag:       bean:cookie Tag... cookie. This tag retrieve the value of the specified request cookie... attribute), and define  attribute of type Cookie or Cookie[] (depends
Creation of xml
Creation of xml  Hi, I need to fetch details from my database and to create a xml file containing all those datas...My database datas are in key value pair... AppID Label Value 12345 Applicant name XXXX 12345 Masterno
Creation of methods
Creation of methods  I have a only single class and its having only one method ie., main method only.... i need to develop another method that is to reduce my switching code package org.bankPackage.one; import java.util.Scanner
Specifying Security for Basic Authentication using @ServletSecurity
In this section, you will learn about how to specifying security for basic authentication using @ServletSecurity
Jsp login with Cookie - JSP-Servlet
. If the cookie is present the username and password field should be automatically populated with the values from the cookie.   Hi Friend, Please
 

 

 

DMCA.com