Setting the cookies

Hi

I trying to add the cookie into local machines.Problems is i written cookie program on cookietest.jsp then i incude this jsp into index.jsp.When accessing the index.jsp the cookies are not setting But when iam acessing cookietest.jsp cookies are adding.why index.jsp accessing time not adding?please help me how to achive this one.

below the code snippet

**********************cookietest.jsp***********************

<%@ page import="java.util.Date"%>

<%@ page import="java.net.*"%>

<%

Date now = new Date();

String timestamp = now.toString();

Cookie cookie = new Cookie ("Venkateswarlu", "ravi");

cookie.setMaxAge(365 * 24 * 60 * 60);

response.addCookie(cookie);

%>

<HTML>

<HEAD>

</HEAD>

<BODY>

</BODY>

</HTML>

**************************end*****************************

***********************index.jsp***************************

<jsp:include page="/cookietest.jsp"/>

Thanks for advace

Venkatesearlu Ravi

[1113 byte] By [-1805693921433274168a] at [2007-11-26 14:52:59]
# 1

> <jsp:include page="/cookietest.jsp"/>

Since you are using <jsp:include> it is only going to include the response from the cookietest.jsp. The cookie setting part gets lost in between the page include. Use the include directive instead.

<%@ include file="relativeURL" %>

The include directive includes the code at jsp compile time and the cookie setting code will get processed when it really should.

aniseeda at 2007-7-8 8:41:16 > top of Java-index,Java Essentials,Java Programming...
# 2

Thanks a lot its working fine.

But i have one more dout.Now this the jsp to jsp means inside one jsp i written java and iam icludieng someother jsp

I wrriten cookie servlet and iam accessing the servlet to cookietest.jsp.This jsp i icluded into index.jsp.same way "<%@ include file="/cookietest.jsp" %>" i do this it will work?

-1805693921433274168a at 2007-7-8 8:41:16 > top of Java-index,Java Essentials,Java Programming...