"LEONG MUN WAI, CUSD" wrote:

> This looks like a good candidate for standardized tags discussion.
>
> >      <html>
> >          <head>
> >          </head>
> >          <body>
> >            <%
> >            //adds a cookie
> >            Cookie c = new Cookie("foo","foobar");
> >            response.addCookie(c);
> >
> >            //gets the cookies
> >            Cookie[] cookies = request.getCookies();
> >            out.print("# of cookies found = " + cookies.length);
> >            if (cookies != null)
> >            {
> >              for (int i = 0; i<cookies.length; i++)
> >              {
> >
> >                  out.print("name: " + cookies[i].getName()+"<P>");
> >                  out.print("value: " + cookies[i].getValue()+"<P>");
> >              }
> >            }
> >            %>
> >          </body>
> >      </html>

Cookies save session information on the client side.  This can also be done using
URL rewriting, but to the JSP author, these details can be abstracted away using:

<% session.putValue((String)key, (Object)value);
      session.getValue((String)key); %>

The Servlet engine should use cookies if enabled on the client, or URL rewriting if
cookies are not available.

The corresponding standardized tags would be:
<setData name="key" value="value" scope="session"/>
<getData name="key" scope="session"/>

--
Michael Hu, Paradox Team, Corel Corporation

===========================================================================
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