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.shtmlhttp://www.roseindia.net/servlets/send-cookies-in-servlets.shtmlThanks
Related Tutorials/Questions & Answers:
Advertisements
without ;without ; can u give me an example of a program
without without ;without ; can u give me an example of a program
without Creation of xmlCreation 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 methodsCreation 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
Clear cookie example Cookie' button. It floats the
alert box showing the successful
creation...
Clear
Cookie Example
.... The example below shows how to delete the
cookie from the browser using
creation of installer - Java Magazinecreation of installer plz tell me how can be create installer for any developed application in java? visit the following url izpack.org..
it will helps u
exe file creation - JDBCexe file
creation hi
i have done a project in java swings.project name is format migrator.means db migrator. now my aim is create EXE FILE for my project.
pls do consider
without scannerwithout scanner a company need a system to store the data about the employees , the number of employees is dynamic , you need to store the following attributes : name , age , salary and note that we need to solve it using array
Cookie in jspCookie 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 CookiePersistent 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
XSD Creation. - WebSevicesXSD
Creation. When I try to generate xsd from java object. It is generating XSD file
finely. But the problem is it isgenerating XSD file elements in
alphabetical order.
can u please sujest me how can we do that one. I tried
creation of a form - JSP-Servletcreation of a form how to create a question paper using JSP code Hi Friend,
We have taken radiobuttons in our application, you can take textarea, textfield etc.
Create a table ans(ques,op1,op2,op3,op4,op5,ans
creation of database - SQLcreation of database hi,
where to and how to execute SQL queries?
Hi nanju
mysql>CREATE DATABASE search;
mysql> SHOW DATABASES;
mysql> USE search
mysql>create table Emp (fname VARCHAR(20
Random Creation of passwordRandom
Creation of password Dear Sir
I have created a form with some details in it.When clicking on the submit button it gives me a password .....Details and the password is saved in the database....The password has
xml file creation in javaxml file
creation in java how to create xml file in java so that input should not be given from keyboard. and that file should be stored.
Please visit the following links:
http://www.roseindia.net/tutorial/java/xml
Session creation and trackingSession
creation and tracking 1.Implement the information persistence across servlet
destroy or servlet container start/stop.
Write a servlet such that when it is stopped
(either by container shutdown or servlet stop
bean creation exceptionbean
creation exception hi i am getting exception while running simple spring ioc program
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class
set cookie in jspset
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
xml creation in javaxml
creation in java HI,
I need a java program to create an xml file...
therez a tutorial in your site to create an xml file at
http://www.roseindia.net/xml/dom/CreatXMLFile.shtmlADS_TO_REPLACE_1
but this isn't creating
Chatbox creation problemChatbox
creation problem i have one chat box in my web site and i assigned fixed position to that div.that is workin in mozill but it is not working in ie . thank you`print
("<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
PDF creation in JAVA - JSP-ServletPDF
creation in JAVA HI!
Good morning....
I want to create pdf file and i want to write something into pdf file....before
creation. Upto
creation i have done but how to write data into pdf. File Writer is not working
Setting CookieSetting 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
cache creation in java - Java Beginnerscache
creation in java Hi All,
I am planing to create cache in my web application. please send me the some sample code to create cache by using org.apache.oro.utils package. please help me out.
Thanks,
mln15584
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
Cookie Handling - JSP-ServletCookie 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
checkbox custom tag creation in jsfcheckbox custom tag
creation in jsf how to create check box custom tags with the following functionality:
1.there must be two checkboxes
2.when the first box is checked it must populate the names of bikes,when the second
Removing existing cookie in jspRemoving 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
creation an dmanipulation of trees - Java Beginnerscreation an dmanipulation of trees Hi guys?
pls i want to find out a hind aboout what these terms or phrases means,
-To create and manipulate a Binary Search Tree
-To use the Java API's Stack in conjunction with other
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. ADS_TO_REPLACE_1
For deleteing the cookies, you will have to set the
cookie Double To Int Without TypeCastingDouble To Int
Without TypeCasting How to convert Double to Int
without using typecasting?
class ConvertDoubleToInt
{
public static void main(String[] args)
{
double d=25.5;
int num=new
Application without Interface Builder!!Application
without Interface Builder!! Can we make our iphone application
without Interface Builder???
hello,
yes , it is possible to make an iphone application
without interface builder..ADS_TO_REPLACE_1
we can