dcsimg
Cookies doesnot get stored.Code provided.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Adi2000_Sharma
Posted On:   Tuesday, June 15, 2004 06:44 AM

Hi experts, I am experiencing problem in storing cookies.I am using Windows 2000 server as OS with j2sdkee1.2.1 and jdk1.3 installed on them.Internet explorer is 5.5 and supports cookies.I made sure that settings for Custom level were all low and that Cookies were enabled.Yet no cookies are been stored.I also made sure that loop is going in a right manner.Here's the code.Refer to the portion of cookies with more emphasis as it is the root cause of problem. <%@ page language="java" session="true" %> <%@ page import="java.sql.*"%> <%@ page import="java.net.*"%&   More>>

Hi experts,

I am experiencing problem in storing cookies.I am using

Windows 2000 server as OS with j2sdkee1.2.1 and jdk1.3

installed on them.Internet explorer is 5.5 and supports

cookies.I made sure that settings for Custom level were

all low and that Cookies were enabled.Yet no cookies are

been stored.I also made sure that loop is going in a right
manner.Here's the code.Refer to the portion of cookies with more emphasis as it is the root cause of
problem.





<%@ page language="java" session="true" %>

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

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







Items Added to your Cart





<%!
Connection con=null;

int ctr=0;

public static final int age=3600*24*30;

boolean cookieFound=false;

Cookie c;

String com=new String (" ");

String rt=new String(" ");

String name = "BooksJargon";

%>

<%

String st1="B00";

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

con=DriverManager.getConnection("jdbc:odbc:MyData","","");

Statement st=con.createStatement();

ResultSet rs=st.executeQuery("select * from

books_for_sale");

ctr=0;

while (rs.next()) {

com=st1+Integer.toString(ctr);

rt=request.getParameter(com);

if (rt !=null) {

%>




<%
cookieFound=false;

Cookie[] cookieset=request.getCookies();

response.setContentType("text/html");

for (int i=0;i

{

if (cookieset[i].getName().equals("BooksJargon"))

{

cookieFound=true;

c=cookieset[i];

}


}



%>




<%


if (cookieFound==false)


{
out.println("Welcome to your first shopping");


Cookie c = new Cookie(name,com);


c.setValue(com);


c.setMaxAge(age);


response.addCookie(c);


}
else if (cookieFound==true) {


out.println ("Cookie was found !!!!");


c.setValue(com);


c.setMaxAge(age);


response.addCookie(c);


}


}


ctr=ctr+1;


}


}
catch(Exception d)


{


out.println("Cannot display the record" +d);


}




%>






   <<Less
About | Sitemap | Contact