Thank you for this input, it look great.


>  <jsp:useBean id="cookies" class="com.canetoad.CookieBean"/>
>  <jsp:setProperty name="cookies" property="request" value="<%= request
%>"/>

But this last statement is not working, the setRequest of CookieBean is not
called, maybe because the value is not a String.

My JSP engine is Jrun 2.3.3 under NT.

I don't known if this syntax is JSP 1.0 - compliant?

Larne, with wich servlet engine did you have it worked?


>C�dric Janssens:
>
>> > How do you retrieve cookies with the JSP 1.0 <jsp:useBean>
</jsp:useBean>,
>> > ..., <jsp:getProperty ... /> syntax ?
>> >
>You can also write a bean that will handle the cookie stuff if you
>want to hide the details from page authors:
>
>----------------------------------------
>package com.canetoad;
>
>import javax.servlet.http.*;
>import java.util.Hashtable;
>
>public class CookieBean {
>    private Hashtable cookies;
>
>    public CookieBean() {
>        cookies = new Hashtable();
>    }
>
>    public void setRequest(HttpServletRequest request) {
>        Cookie _cookies[] = request.getCookies();
>
>        for(int i=0;i<_cookies.length;i++) {
>            cookies.put(_cookies[i].getName(),_cookies[i]);
>        }
>    }
>
>    public String getCookieValue(String name) {
>        Cookie tmp = (Cookie) cookies.get(name);
>        if(tmp != null) return tmp.getValue();
>        return null;
>    }
>
>    public String getMyCookie() {
>        return getCookieValue("myCookie");
>    }
>}
>
>----------------------------------------
>
>You could also write similar accessors to get the domain, comments, max
>age, etc.
>
>In your JSP you could then do:
>
><jsp:useBean id="cookies" class="com.canetoad.CookieBean"/>
>
><jsp:setProperty name="cookies" property="request"
> value="<%= request %>"/>
>
><P>
>Your cookie named myCookie has the value:
><jsp:getProperty name="cookies" property="myCookie"/>
></P>
>
>
>                                                  - Larne
>
>===========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
>FAQs on JSP can be found at:
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to