hi,
i am trying to set a cookie using Jsps and
beans......my code is this
*****jsp page*******
<%@ page import="anurag.Example1" %>
<jsp:useBean id="abean" scope="session"
class="anurag.Example1" />
<jsp:setProperty name="abean" property="*" />
<jsp:forward page="test2.jsp" />
with html...
*****bean***************
package anurag;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class Example1{
private String username;
HttpServletResponse res;
HttpServletRequest req;
public Example1(){
username=null;
}
public void setUsername(String name){
username=name;
res.addCookie(new Cookie("session_id",username));
}
public String getUsername() {
Cookie[] cookies = req.getCookies();
if (cookies != null)
{
for(int i=0;i < cookies.length;i++)
{
String name=cookies[i].getName();
return name;
}
}
return username;
}
}
******jsp page*******
<%@ page import="anurag.Example1" %>
<jsp:useBean id="abean" scope="session"
class="anurag.Example1" />
<jsp:getProperty name="abean" property="username" />!
with html....
the final page is displaying only the "username" not
he name of the cookies......
please help
thanks
-anurag
____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie
===========================================================================
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://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets