Comment

Parameter
Parameter,
March 12, 2008 at 10:53 PM

Cookie Class In JSP cookie are the object of the class javax.servlet.http.Cookie. This class is used to creates a cookie, a small amount of information sent by a servlet to a Web browser, saved by the browser, and later sent back to the server. A cookie's value can uniquely identify a client, so cookies are commonly used for session management. A cookie has a name, a single value, and optional attributes such as a comment, path and domain qualifiers, a maximum age, and a version number. The getCookies() method of the request object returns an array of Cookie objects. Cookies can be constructed using the following code: Cookie(java.lang.String name, java.lang.String value) Cookie objects have the following methods. Method Description getComment() Returns the comment describing the purpose of this cookie, or null if no such comment has been defined. getMaxAge() Returns the maximum specified age of the cookie. getName() Returns the name of the cookie. getPath() Returns the prefix of all URLs for which this cookie is targeted. getValue() Returns the value of the cookie. setComment(String) If a web browser presents this cookie to a user, the cookie's purpose will be described using this comment. setMaxAge(int) Sets the maximum age of the cookie. The cookie will expire after that many seconds have passed. Negative values indicate the default behavior: the cookie is not stored persistently, and will be deleted when the user web browser exits. A zero value causes the cookie to be deleted setPath(String) This cookie should be presented only with requests beginning with this URL. setValue(String) Sets the value of the cookie. Values with various special characters (white space, brackets and parentheses, the equals sign, comma, double quote, slashes, question marks, the "at" sign, colon, and semicolon) should be avoided. Empty values may not behave the same way on all browsers. Example Using Cookies No we will write code in JSP file to set and then display the cookie. Create Form Here is the code of the form (cookieform.jsp) which prompts the user to enter his/her name. <%@ page language="java" %> <html> <head> <title>Cookie Input Form</title> </head> <body> <form method="post" action="setcookie.jsp"> <p><b>Enter Your Name: </b><input type="text" name="username"><br> <input type="submit" value="Submit"> </form> </body> Above form prompts the user to enter the user name. User input are posted to the setcookie.jsp file, which sets the cookie. Here is the code of setcookie.jsp file:
<%@ page language="java" import="java.util.*"%> <% String username=request.getParameter("username"); if(username==null) username=""; Date now = new Date(); String timestamp = now.toString(); Cookie cookie = new Cookie ("username",username); cookie.setMaxAge(365 * 24 * 60 * 60); response.addCookie(cookie); %>
View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
JSP Servlet Questions

Passing Parameter - JSP-Servlet
Passing Parameter  I would like to ask how to pass a parameter from javascript section into the jsp section.It will be something like this: function change() { var answer = document.getElementById('selc').value 

JSP Servlet Questions

Passing Parameter - JSP-Servlet
, there's var answer. I need to pass this parameter back into the jsp part, how should i do it which means the String answer in jsp part will equal to the var answer...= ; } Use of Select Box in JSP Select items from select box > 

JSP Interview Questions

validate parameter before using it
validate parameter before using it   How to validate the parameter before using it in JSP 

JSP Tutorials

JSP Session Parameter rewrite
JSP Session Parameter rewrite       In the section you will study about the session parameter in jsp. JSP session provides methods like getCreationtime(), getLastAccessedTime 

JSP Interview Questions

Set Parameter - JSP-Interview Questions
Set Parameter  Hi, could someone please explain the process of setting parameter in the session from JSP with the help of code? Thanks!  Hi,In your JSP page use the Set Tag, and set the scope attribute 

JSP Interview Questions

pass parameter names and values
pass parameter names and values  What is the <jsp:param> standard action?   The <jsp:param> standard action is used with <jsp:include> or <jsp:forward> to pass parameter names and values 

JSP Tutorials

JSP get Parameter
JSP get Parameter          JSP get Parameter is used to return... in the body of request. Syntax JSP get Parameter: <%= request.getParameter 

JSP Servlet Questions

JSP parameter passing throught out web app
JSP parameter passing throught out web app  i want to pass one param from page1.jsp page to page4.jsp page but in between this i need to navigate page3.jsp and page2.jsp.Please help me to understand how could i transfer param 

JSP Servlet Questions

Passing Parameter Values to another jsp in Query Strings
Passing Parameter Values to another jsp in Query Strings  HI ALL, I m trying to pass a variable value to another JSP using query string... response.sendRedirect("http://localhost:8080/SWIFT/index.jsp?loginid='"+loginid 

JSP Servlet Questions

Exception during parsing a parameter from the form in JSP
Exception during parsing a parameter from the form in JSP  Exception during parsing params from a form? I get parameters from a html form. I parse the integer one in the JSP file, but I get exception. Is there anyway I can get 

Struts 2 Tutorials

Static Parameter
Static Parameter       In this section, we... a JavaBean to set and get the static parameters. Each static parameter has a value...;   } } Create a jsp page (showparameters.jsp) to view 

JSP Servlet Questions

Parameter passing from jsp page to jsp page - JSP-Servlet
Parameter passing from jsp page to jsp page  Hi I intends to pass... parameter in respective string variables. I have to passed the parameters... :  For more information on JSP visit to : http 

JSP Servlet Questions

How to pass query as parameter? - JSP-Servlet
How to pass query as parameter?  Hi Friends, I have a real tough time in finding the solution of a problem. I am here to find a real solution of my problem. Please help me solve this problem. My Problem is: I have 3 query 

JSP Servlet Questions

passing .properties file as a parameter to another function
passing .properties file as a parameter to another function  passing .properties file as a parameter to another function in an jsp file 

JSP Servlet Questions

passing .properties file as a parameter to another function
passing .properties file as a parameter to another function  passing .properties file as a parameter to another function in an jsp file 

JSP Servlet Questions

passing .properties file as a parameter to another function
passing .properties file as a parameter to another function  passing .properties file as a parameter to another function in an jsp file 

JSP Servlet Questions

passing .properties file as a parameter to another function
passing .properties file as a parameter to another function  passing .properties file as a parameter to another function in an jsp file 

Java Beginners

JSP:Passing query as parameter - Java Beginners
JSP:Passing query as parameter  Hi Friends, I have a real tough time in finding the solution of a problem. I am here to find a real solution of my problem. Please help me solve this problem. My Problem is: I have 3 query 

Java Beginners

JSP:Passing query as parameter - Java Beginners
JSP:Passing query as parameter  Hi Friends, I have a real tough time in finding the solution of a problem. I am here to find a real solution of my problem. Please help me solve this problem. My Problem is: I have 3 query 

Java Beginners

pass parameter - file - Java Beginners
pass parameter - file  Hi, I want to pass paramter file to method..., If you are working with the JSP and Servlet then this code can be understood immediately. file.jsp ========== File Parameter Use 

JSP Servlet Questions

How to append a request parameter in a jsp page - JSP-Servlet
How to append a request parameter in a jsp page   i have a jsp page which have a some school names link. when i click to link of a school name... to attach a request parameter in a link which appended from first page so that i can 

Struts 2 Tutorials

Static Parameter, Static Parameter in Struts 2, Struts 2 Static Parameter
a jsp page(showparameters.jsp) to view the static parameters.   

Java Beginners

Parameter month I Report - Java Beginners
Parameter month I Report  hy, I want to ask about how to make parameter in I Report, parameter is month from date. How to view data from i report... like Java/JSP/Servlet/JSF/Struts etc ... Thanks 

JSP Servlet Questions

url parameter using retrive data from database in jsp
url parameter using retrive data from database in jsp   the user can... clicks the Preview button, you have to create a dynamic jsp which should read the contents from the db based on the event id. But this jsp url should be a public 

Ajax Questions

passing file parameter through ajax - Ajax
passing file parameter through ajax  I have file parameter in jsp...; Hi friend, file1.jsp passing file using jsp... for more information. http;//www.roseindia.net/jsp/ Thanks.   

JSP Interview Questions

url parameter using retrive data from database in jsp
url parameter using retrive data from database in jsp  The user can... clicks the Preview button, you have to create a dynamic jsp which should read the contents from the db based on the event id. But this jsp url should be a public url 

Servlets

Check if parameter exists in servlet request
Check if parameter exists in servlet request... will see how to check is parameter exists in servlet request. In this example...() returns the next element of enumeration. We have used a jsp page 

Struts Questions

Request[/DispatchAction] does not contain handler parameter named 'parameter'. This may be caused by whitespace in the label text. - Struts
Request[/DispatchAction] does not contain handler parameter named 'parameter... struts-config.xml file & three jsp pages but it shows the warning Request[/DispatchAction] does not contain handler parameter named 'parameter'. This may 

JSP Servlet Questions

Wrong parameter values while exporting data from jsp to excel
Wrong parameter values while exporting data from jsp to excel   This is a jsp report. When i export the report data to an excel, the parameter..., specifically, if the parameter value is ALL, it gets translated to NO in excel 

JSP Servlet Questions

Getting Parameter from a css styled jsp file to a java servlet file...
Getting Parameter from a css styled jsp file to a java servlet file...  This is my code.... login page-- <!DOCTYPE html PUBLIC "-//W3C//DTD... is it not getting the parameter??? How do i accept the value in the servlet file 

JSP Tutorials

Passing Parameter with <jsp: include>
Passing Parameter with <jsp: include>      In this example we are going to use <jsp:include>... a file in a jsp page. While using <jsp:param> we are adding 

JSP Servlet Questions

How to pass parameter through drop down list using session management in jsp??
How to pass parameter through drop down list using session management in jsp??  How to pass parameter through drop down list in the URL and access it on same jsp page using session management 

Servlets

Get Parameter Name From Servlet Request
Get Parameter Name From Servlet Request       This example illustrates about how to get parameter from jsp page in your servlet. In the jsp (parameter.jsp) page we have taken three input fields 

Servlet Interview Questions

Init Parameter
Init Parameter  How set Init Parameter in servlet 

JSP Servlet Questions

Need Help-How to store input parameter in DB through Java Bean - JSP-Servlet
Need Help-How to store input parameter in DB through Java Bean  Hello Sir, I have a simple Issue but It is not resolve by me i.e input parameter are not store in Ms-Access. I store the input parameter through Standard Action 

Java Beginners

add text box and select list dynamically and get its value to store it into database using jsp request parameter
add text box and select list dynamically and get its value to store it into database using jsp request parameter  its very helpful when you have only... added select box also into next jsp page plz reply me as early as posssible 

Subversion Questions

Request[/searchMenu] does not contain handler parameter named 'function'. This may be caused by whitespace in the label text. - Subversion
Request[/searchMenu] does not contain handler parameter named 'function... not contain handler parameter named 'function'. This may be caused by whitespace in the label text. jsp file = Search for - Shipping Category struts-config.xml 

JSP Tutorials

JSP Include Param
;       JSP Include Param is used to pass parameter... the parameter name and value to the dynamic jsp page. This clause is only used... parameter value to the dynamic jsp. The Request.getParameter ( ) retrieve the value 

Java Interview Questions

Java parameter passing
Java parameter passing  What type of parameter passing does Java support 

JSP Interview Questions

JSP
what is JSP forward tag for  what is JSP forward tag for   It forwards the current request to another JSP page. Below is the syntax for the same:- <jsp:forward page="...url..." /> We can also forward parameter 

Servlets-Tutorials

Getting Context Parameter Names
Getting Context Parameters NamesGetting Context Parameter Names In this section, you will learn how to get  the context parameters which we have given... of the ServletContext to the context init parameters. The servlet and jsp which 

JUNIT Questions

optional parameter of Test annotattion
optional parameter of Test annotattion   What are two optional parameters of @Test annotation ?   The Test annotation supports two optional... parameter, timeout, causes a test to fail if it takes longer than a specified amount 

JUNIT Questions

optional parameter of Test annotattion
optional parameter of Test annotattion   The Test annotation supports two optional parameters. The first, expected, declares that a test method should throw an exception. If it doesn't throw an exception or if it throws 

Programming Tutorials

SQL Out Parameter
SQL Out Parameter       SQL Out Parameter allows the stored procedure to the pass data value ... from SQL Out Parameter .In this Example we create a procedure 'abc 

JDBC Questions

parameter meta data - JDBC
parameter meta data   i wnts to know about the finition of parameter in jdbc as well as the diffrent methods used in parameter meta data  Hi friend, public interface ResultSetMetaData An object that can be used 

Struts 1 Tutorials

Parameter Tag:
Parameter Tag:       bean:parameter...) of the specified request parameter. This tag retrieve the value of the specified request parameter and define the attribute of  type String or String[] in page scope 

Java Server Faces Questions

Passing a parameter using URL string
Passing a parameter using URL string  How to pass a parameter using the URL string in a JSF application 

JSP Servlet Questions

jsp
jsp  JSP that accepts a string parameter from the browser and simply displays it back in the HTML response.   Hi Friend, Try the following code 1)passtohtml.jsp: <html> <form name="form" method="get" action 

Applet Questions

Applet code parameter - Applet
 

JSP Servlet Questions

JSP
the ajax send the parameter to another jsp page. That JSP page retrieves the record...JSP  Hello, I want to perform search based on the parameters entered in the JSP page and display the results back to the same JSP page. Thanks 

PHP Questions

PHP add parameter to url - PHP
PHP add parameter to url  need an example of parse_url in PHP. Thanks in advance 

JSP Servlet Questions

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 Questions

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 Questions

JSP-Servlet - JSP-Servlet
JSP-Servlet   how to pass the value or parameter from jsp page to servlet and view the passed value 

Java Beginners

passing parameter from html to applet
passing parameter from html to applet  how to pass the following from HTML to applet in Java code - font size,font style,font size?give me suitable code 

Swing AWT

how to pass the parameter in callable statement
how to pass the parameter in callable statement  calstat=conn.prepareCall("{call studentrc(?,?,?,?,?)}"); // it show error parameter value is null...=smark1,mark2=smark2,total=stotal where Regno=Regno; end;// how can i pass the parameter 

JPA

JPA setParameter (Named Parameter)
JPA setParameter (Named Parameter)   ... API's method setParameter as a named parameter. JPA Query API's supports two... Here we are going to develop an application for using the named parameter 

SQL Tutorial

SQL Out Parameter
SQL Out Parameter       SQL Out Parameter allows the stored procedure to the pass data... an example from SQL Out Parameter .In this Example we create a procedure 'abc 

SQL Question

Set Date Parameter to get specific value
Set Date Parameter to get specific value  How to set the date parameter or fetch a specific data records based on date? For example fetching the two or three months old records 

JSP Servlet Questions

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 

Java-Tutorials

Applet - Passing Parameter in Java Applet
Applet - Passing Parameter in Java Applet   ... of retrieving the parameter values passed from the html page. So, you can pass... and passing parameter in applet, a example is given below. In this example, we 

JSP Servlet Questions

JSP Populate - JSP-Servlet
JSP Populate  Hi, I want to call a XYZ jsp via URL with some parameters and at the same time want to use that parameter to populate the same XYZ jsp from database. How do I populate this XYZ jsp after hitting that URL (it needs 

Java Technology Tutorials

Objective-C program with multiple parameter
Objective-C program with multiple parameter  ... with multiple parameter. These parameter can be of same type or of different... method for more than one parameter -(int) sum: (int) a andb: (int) b andc:(int)c 

JPA

JPA Positional Parameter
JPA Positional Parameter       In this section, you will learn about the JPA Positional Parameter... the value in parameter. So, We don't have use the same query for different values 

JPA

JPA Named Parameter List
JPA Named Parameter List   ... application using JPA Named Parameter List. This is similar as named parameter but here we use the an array list as named parameter.  Named Parameter List 

Java Technology Tutorials

JPA setParameter (Numbered Parameter)
JPA setParameter (Numbered Parameter)  ... the setParameter. Here, we will see setParameter to set a numbered parameter. We are going to develop an example code to use the numbered parameter 

JPA

JPA Named Parameter
JPA Named Parameter       In this section, you will learn how to use JPA Named Parameter in your jpa application. In JPA named parameter is used where you assign names 

Java Beginners

Parameter month I Report - Java Beginners
Parameter month I Report  ok, my problem now is in Report in java with I report. I want to give parameter month/year to my design in I Report. But Date format in database dd/mm/yyyy , my question how to get mm/yyyy from database 

Servlets

Multiple values for a single parameter
Multiple values for a single parameter       In our program it may be that we may have multiples values for a single parameter like in checkboxes. We are going to make one 

Java Beginners

java/jsp
java/jsp  In a JSP program called books.jsp, the Java code out.print(request.getParameter(‚??number‚??)); displays "1111111‚??. What are the possible ways for the parameter number to have got its value 

Struts 2 Tutorials

Subset Tag (Control Tags) Example Using Start
the start parameter. The start parameter is of integer type. It indicates...;return myList;   } } Now create a jsp... a subset of it. The parameter start is of integer type and it indicates 

Ajax Questions

Main function parameter in C language - Ajax
Main function parameter in C language  Please let me know how this Main(int argc,char*argv[]) works and detailed example on their roles in command line arguement.Also how is fgetpos() and fsetpos() used in file operation  

JSP Servlet Questions

JSP - JSP-Servlet
Difference between jsp forward and sendRedirect  What is difference between jsp forward and send Redirect?  Difference between jsp forward and sendRedirectJSP forward action (<jsp: forward/>)jsp forward action 

General

Java method final parameter
Java method final parameter   .... In the example the radius parameter for calculating the area of circle have been... the constant declared parameter radius inside the class constructor FinalParameterExample 

JSP Servlet Questions

jsp applet communication - JSP-Servlet
jsp applet communication  Hi... We've an application where v need to create an object in the jsp and send that to an applet... For this v used in which we passed object as a parameter... v created a connection object in jsp 

Servlets

Show Parameter In Servlet
Show Parameter In Servlet      ... parameter names into the table. The following program uses two methods, which... up all the parameter names via the getParameterNames() method 

JSP Tutorials

JSP Include jsp
; clause to pass the parameter name and value and the included jsp page displays... JSP Include jsp          This section illustrates you about the <jsp 

JSP Servlet Questions

JSP - JSP-Servlet
to access data from one to another without using of any get parameter but it is some 

Java Server Faces Questions

Passing parameter over Form to BackingBean - Java Server Faces Questions
Passing parameter over Form to BackingBean  Dear User, i have problems concerning passing parametes from form to my backing bean. I have... here, my Bean Code. This is the form 

JavaScript Questions

JSP-parameters possible ways
JSP-parameters possible ways  In a JSP program called books.jsp, the Java code out.print(request.getParameter(‚??number‚??)); displays ‚??1111111‚??. What are the ways for the parameter number to have got its value 

JavaScript Questions

JSP-parameters possible ways
JSP-parameters possible ways  In a JSP program called books.jsp, the Java code out.print(request.getParameter(‚??number‚??)); displays ‚??1111111‚??. What are the ways for the parameter number to have got its value 

Struts 2 Tutorials

Subset Tag (Control Tags) Example Using Count
the count parameter. The count parameter indicates the number of entries...; } } Now create a jsp page using <s.... The subset tag takes an iterator and outputs a subset of it. The parameter count 

JSP-Tutorials

database connectivity in jsp form
database connectivity in jsp form We are going to create jsp registration form... of a request parameter passed as string of request. We have used database connection.... This application can be used by any jsp web project.  syntax of getParameter:- < 

JSP Servlet Questions

Servlet - JSP Programming - JSP-Servlet
Servlet - JSP Programming  Hi, I'm writing a jsp page as shown below. I have to buttons of type submit. Any time only one is selected(either add... it is showing error with "checkout" parameter and viceversa. The starting of my 

JDBC Questions

jsp - JDBC
: Unable to compile class for JSP An error occurred at line: 20 in the jsp file...\localhost\Airlines-Project\org\apache\jsp\Flightdetails_jsp.java:69: cannot find symbol symbol : variable src location: class org.apache.jsp.Flightdetails_jsp 

JSP Servlet Questions

parameters - JSP-Servlet
parameters  Hello Roseindia, I got one problem with parametrs pass with link in servlet to jsp...these parameter values coming from database... example with sending parameters with hyperlibk in srevlets to jsp.. Thanqs advnce 

JSP Servlet Questions

error:Parameter index out of range (1 > number of parameters, which is 0).
error:Parameter index out of range (1 > number of parameters, which is 0).  my code:String org=request.getParameter("Org"); String desg=request.getParameter("des"); String From=request.getParameter("From"); String 

Blog

Sitemap JSP Tutorial Section
to the Server Console | Nested If Statement JSP | Session Parameter rewrite... | JSP Include jsp | JSP Include File | JSP Get URL | JSP get Parameter... Map | Business Software Services India JSP Tutorial Section  Intro 

JSP Servlet Questions

java servlets - JSP-Servlet
java servlets  how to get the parameter value of input type file using java servlets  Hi, You can use request.getParameter(). In Jsp, --- --- IN servlet, String fileName=request.getParameter('fl'); If you 

JSP Servlet Questions

java - JSP-Servlet
java   in eclipse after submiting the data throgh jsp page i got the following error com.microsoft.sqlserver.jdbc.SQLServerException: The value is not set for the parameter number 1.   Hi Friend, It seems 

JSP Servlet Questions

Session Timeour - JSP-Servlet
the following link: http://www.roseindia.net/jsp/jsp-session-parameter...Session Timeour  Hi, How to create a session timeout page in JSP? Session timeout should happen after 15 mins of idle instance. Thanks  

JSP Servlet Questions

Passing Parameters - JSP-Servlet
Passing Parameters  Hi I have to pass parameter like... First Name /**SECOND PAGER upto this page I passed the parameter through query... is For more information on JSP visit to : http://www.roseindia.net/jsp 

JavaScript Questions

jsp- adding user defined functions to a jsp
jsp- adding user defined functions to a jsp  Trying to write the function as below but getting errors. Can you please identify the cause of error... "retrieveAndClearErrorMessage". It does not like the parameter.) Multiple annotations found 

Programming Tutorials

JSP Standard Actions 'jsp:setProperty' & 'jsp:getProperty'
JSP Standard Actions <jsp:setProperty> & <jsp:getProperty>  <jsp:setProperty> It sets a property value or values in a Bean only...: <jsp:setProperty         name=" 

JSP Tutorials

Passing Parameters in jsp
for retrieving parameter values by name. Parameters can be passed by using a tag <jsp... Passing Parameters in jsp       This section illustrates you how to pass parameters in jsp. JSP can 

JSP Tutorials

JSP Actions
; The jsp:param action is used to add the specific parameter to current... JSP Actions       In this section we will explain you about JSP Action tags and in the next section we 

JSP Servlet Questions

data are not display in JSP from database - JSP-Servlet
data are not display in JSP from database   i want to finding some data through a SQL query from SQL server database to a JSP page based on some.... one.jsp value of 'school' request parameter are comming from the link 

Design concepts & design patterns Questions

passing parameter from Java code to CSS file - Design concepts & design patterns
passing parameter from Java code to CSS file  hi, i have to pass a string variable from by java code to a CSS file so that i can use that variable in my CSS file. Plz help me as soon as possible 

HTML Questions

WRITE a simple JSP
WRITE a simple JSP  Write a JSP that accepts a string parameter from the browser and simply displays it back in the HTML response   Hi Friend, Try the following code: 1)form.jsp: <html> <form name="form 

JSP Tutorials

JSP Tutorials - Page2
JSP Tutorials page 2 JSP Examples Hello World JSP Page... world" on your browser. Jsp can be learned very easily. This is just... Directive in JSP Page This section illustrates you about the page 

Advertisements Advertisements
 

 

 

DMCA.com