----- Original Message ----- From: "mkweb" <[EMAIL PROTECTED]>
To: <users@tomcat.apache.org>
Sent: Friday, June 13, 2008 11:44 AM
Subject: Tomcat will not create session cookie



Hello,
I'm new to the forum. I have a strange problem with my tomcat installation.
I'm using tomcat5.5.26 and struts for my web projekt.

I configured the projekt in a context file, like this :
<Context path="" docBase="C:\webprojekt" debug="1" reloadable="true"
crossContext="true" cookies="true">

I set the attribute cookies to 'true' because I want to have session
cookies.

Furthermore I added the following lines to the index.jsp to display the
cookies :

out.println("<h>Cookies : </h>");
Cookie[] cookies=request.getCookies();
if(cookies==null) {
out.println("No cookies");
} else {
Cookie MyCookie;
for(int i=0;i<cookies.length;i++) {
MyCookie=cookies[i];
out.println(MyCookie.getName() + "="+MyCookie.getValue());
}
}


Mario, I dont use Struts...
But this is what my code typically looks like

           HttpSession session = request.getSession(true);
           daBean= (DaBean)session.getAttribute("daBean");
           if (daBean== null) { // make new bean
               daBean= new daBean();
           } else {// got session info

           }

That getSession(true);
makes the cookie if there isnt one... and struts probably has some XML that does this.

Then the other thing is that you must send it when you send your form... its no good only making the sesion (cookie) when you trying to read the form data, its too late then.

You dont have to set cookies="true" its the default... and it means it will use cookies, but you still have to create the things.
Somewhere underneath struts is doing this I guess...

Hope that helps...

---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to