set values in cookies ?
Hello Friends
m using cookies in jsp
i want to store startMonth and endMonth fields data in cookies
so for startDate m using
"Cookie ck=new Cookie("startmonth",request.getParameter("startMonth"));
response.addCookie(ck);"
but i wana store endDate also in cookie so what is the way to store
it in cookies
m using
"Cookie ck1=new Cookie("startMonth",request.getParameter("startMonth"));
response.addCookie(ck1);"
"Cookie ck2=new Cookie("endMonth",request.getParameter("endMonth"));
response.addCookie(ck2);"
is this the proper way to create two cookies objects for stoaring two values in cookies
if yes then what if i wana store 10 values in cookies
# 3
Whatever u r doing is right
so u can use muliple value in cookies by following way
<%
Cookie strtMonth=new Cookie("startmonth",request.getParameter("stMonth"));
strtMonth.setMaxAge(30*60);
Cookie strtYr=new Cookie("startyr",request.getParameter("minyear"));
strtYr.setMaxAge(30*60);
Cookie EnMonth=new Cookie("endmonth",request.getParameter("endMonth"));
EnMonth.setMaxAge(30*60);
Cookie EnYr=new Cookie("endyr",request.getParameter("maxyear"));
EnYr.setMaxAge(30*60);
response.addCookie(strtMonth);
response.addCookie(strtYr);
response.addCookie(EnMonth);
response.addCookie(EnYr);
%>
# 4
Whatever u r doing is right
just use following code to set multiple value in cookies
<%
Cookie strtMonth=new Cookie("startmonth",request.getParameter("stMonth"));
strtMonth.setMaxAge(30*60);
Cookie strtYr=new Cookie("startyr",request.getParameter("minyear"));
strtYr.setMaxAge(30*60);
Cookie EnMonth=new Cookie("endmonth",request.getParameter("endMonth"));
EnMonth.setMaxAge(30*60);
Cookie EnYr=new Cookie("endyr",request.getParameter("maxyear"));
EnYr.setMaxAge(30*60);
response.addCookie(strtMonth);
response.addCookie(strtYr);
response.addCookie(EnMonth);
response.addCookie(EnYr);
%>
# 7
Hi BalusC
ya u are absolutly right,that we shud not play with clients data.
but with my client, scenario is he wants his last selected start date and EndDate on every Reports as default report date value for 8 days.
that why m using cookie to set default date value as last selected dates
so is that a right way?
waiting
# 8
Hi BalusC
ya u are absolutly right,that we shud not play with clients data.
but with my client, scenario is he wants his last selected start date and EndDate on every Reports as default report date value for 8 days.
that why m using cookie to set default date value as last selected dates
so is that a right way?
waiting