I am using the following code as a jsp login page. On pressing the Login button the cookie should be created but its not. Any ideas?
<SCRIPT LANGUAGE="JavaScript"><!-- function go_search () { window.location.href = "../search/ph2Search.jsp"; } function go_failed () { window.location.href = "ph2FailedLogin.jsp"; } </SCRIPT> <%@page language="java" import="java.sql.*, java.lang.*, java.util.*" %> <jsp:useBean id="sqlBn" scope="session" class="beans.ph2Sql" /> <jsp:useBean id="loginBn" scope="page" class="beans.ph2Login" /> <jsp:useBean id="debugBn" scope="page" class="beans.ph2Debug" /> <jsp:useBean id="fileBn" scope="page" class="beans.ph2File" /> <table width="100%" border="5" cellspacing="0" cellpadding="0" name="tblCase" height="334" bgcolor="#CCCCFF"> <form name="form1" method="post"> <% Cookie loginCookie = null; %> <tr> <td height="425" align="left" valign="bottom"> <div align="left"> <table border="0" cellspacing="0" cellpadding="0" height="334"> <tr align="center" valign="top"> <td colspan="6" height="230"> <div align="left"></div> <div align="left"> <table border="0" cellspacing="0" cellpadding="0" height="153" name="tblLogin"> <tr> <td width="238" height="33"> </td> <td width="154" height="33"> </td> <td width="43" height="33"> </td> <td width="536" height="33"> </td> </tr> <tr> <td width="238"> </td> <td width="154"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">User Name:</font></b></td> <td width="43"> </td> <td width="536"> <font size="2"><b><font face="Verdana, Arial, Helvetica, sans-serif"> <input type="text" name="txtUserName" size="35" maxlength="35"> </font></b></font></td> </tr> <tr> <td width="238" height="47"> </td> <td width="154" height="47"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Password:</font></b></td> <td width="43" height="47"> </td> <td width="536" height="47"> <font size="2"><b><font face="Verdana, Arial, Helvetica, sans-serif"> <input type="password" name="txtPassword" size="35" maxlength="15"> </font></b></font></td> </tr> <tr> <td width="238"> </td> <td width="154"> <div align="left"><font size="2"><b><font face="Verdana, Arial, Helvetica, sans-serif"> <input type="checkbox" name="chkSavePassword"> </font><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Save Password</font><font face="Verdana, Arial, Helvetica, sans-serif"> </font></b></font></div> </td> <td width="43"> </td> <td width="536"><b></b></td> </tr> </table> </div> <div align="left"></div> </td> </tr> <tr> <td bgcolor="#9999FF" height="2" colspan="3"> <div align="center"> </div> </td> <td bgcolor="#9999FF" height="2" width="404"> <div align="right"> <input type="submit" name="btnLogin" value="Login"> </div> </td> <td bgcolor="#9999FF" height="2" width="405"> </td> <td bgcolor="#9999FF" height="2" width="86"> <input type="submit" name="btnCancel" value="Cancel"> </td> </tr> </table> </div> </td> </tr> <% if (request.getParameter("btnLogin") != null) { String userName = request.getParameter("txtUserName"); String password = request.getParameter("txtPassword"); debugBn.logToFile("Login : btnLogin pressed"); loginBn.setUserName(userName); loginBn.setPassword(password); Connection conn = loginBn.authenticate(); if (conn != null) { debugBn.logToFile("Login : Good connection"); sqlBn.setConnection(conn); debugBn.logToFile("Login : Connection set"); if (request.getParameter("chkSavePassword") != null) { debugBn.logToFile("Into cookie bit"); loginCookie = new Cookie(userName, password); loginCookie.setMaxAge(60*1); loginCookie.setPath("/"); response.addCookie(loginCookie); debugBn.logToFile("Made cookie"); } %> <SCRIPT> go_search() </SCRIPT> <% } else { debugBn.logToFile("Login : Bad connection"); %> <SCRIPT> go_failed() </SCRIPT> <% } } else if (request.getParameter("btnCancel") != null) { %> <SCRIPT> go_failed() </SCRIPT> <% } %> </form> </table> =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://archives.java.sun.com/jsp-interest.html http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.jsp http://www.jguru.com/faq/index.jsp http://www.jspinsider.com