• Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating Cookies in JSP page'  RSS feed

 
Jany G
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I'm having problem in "creating cookie in JSP Page and reading them in servlets". Servlet is not able to read cookie created in JSP page but it is reading other cookies.
JSP Code Snap is as follows:
--------------------------------
<%@ page import="javax.servlet.http.*" %>
<%@ page import="javax.servlet.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%String model= request.getParameter("ModelAfter");
Cookie groupid=new Cookie("ModelAfter1", model);
groupid.setMaxAge(36000);
groupid.setDomain("cat.com");
request.addCookie(groupid);%>
--------------------------------
Any idea's please.
Thanks in Advance.
 
Jany G
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry! I added code as follows. Previous code is When I did trails.
-----------------------------
<%@ page import="javax.servlet.http.*" %>
<%@ page import="javax.servlet.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%String model= request.getParameter("ModelAfter");
Cookie groupid=new Cookie("ModelAfter1", model);
groupid.setMaxAge(36000);
groupid.setDomain("cat.com");
response.addCookie(groupid);%>
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Jany G",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!