Hi everyone,
Further to my thread of 18th Oct,I should mention that the cookies I am
trying to write are persistent and not session cookies. Using the code
bellow : (Please note that the problem is not being able to retrieve it
and I think the reason is the cookie is not being issued in the first
place).
<HTML>
<HEAD><TITLE> issue cookie </TITLE>
<BODY>
<%@ page import="java.util.*"%>
<%@ page import="javax.servlet.http.*"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="java.io.*"%>
<%
Cookie c = new Cookie ("firstname","mazin");
c.setMaxAge(3600);
c.setDomain(".scitse.wlv.ac.uk:7777");
c.setPath("/");
response.addCookie(c);
response.setContentType("text/html");
%>
</BODY>
</HTML>
and the following to retrieve:
<HTML>
<HEAD><TITLE> get cookie </TITLE>
<BODY>
<%@ page import="java.util.*"%>
<%@ page import="javax.servlet.http.*"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="java.io.*"%>
<%
Cookie[] cookies = request.getCookies ();
response.setContentType("text/html");
if (cookies!=null){
for (int i=0; i<cookies.length;i++){
Cookie c = cookies[i];
String name = c.getName();
String value = c.getValue();
int version = c.getVersion();
out.println(name + " = " + value);
}
}
%>
</BODY>
</HTML>