HomeDigital EditionSys-Con RadioSearch Java Cd
Advanced Java AWT Book Reviews/Excerpts Client Server Corba Editorials Embedded Java Enterprise Java IDE's Industry Watch Integration Interviews Java Applet Java & Databases Java & Web Services Java Fundamentals Java Native Interface Java Servlets Java Beans J2ME Libraries .NET Object Orientation Observations/IMHO Product Reviews Scalability & Performance Security Server Side Source Code Straight Talking Swing Threads Using Java with others Wireless XML
 

"Jlink: Cybelink's Framework"
Vol. 6, Issue 2, p. 78

	

Listing 1

//Setting Cookies
package test;
import javax.servlet.*;
public class CookieSetter(HttpServletResponse resp, String sessionData){
     //Client Id is "CybelinkCookie"
     Cookie coo=new Cookie("CybelinkCookie", sessionData);
     coo.setDomain("cybelink.com");
     coo.setPath("/");
     coo.setMaxAge(24*60*60) //One day
     coo.setVersion(0);
     resp.addCookie(coo);
}

//Retrieving Cookies
package test;
import javax.servlet.*;
public class CookieRetriever(HttpServletRequest req, String sessionData){
     Cookie[] cookies=req.getCookies();
      Cookie found=null
     if(cookies != null){
     for(int i=0; i<cookies.length ; ++i){
          if(cookies(i).getName.equals("CybelinkCookie")){
found=cookies[i];
break;
   }
}
     }
}


Listing 2

import javax.servlet.*;
import javax.servlet.http.*;


import java.io.*;

public class ItemsCatalogServlet extends HttpServlet {

         public void doGet (HttpServletRequest req,
                            HttpServletResponse resp)
    throws ServletException, IOException{
    //....get ShoppingCart
             Items[] items = shoppingCart.getItems();
             for(int i=0; i < items.length; i++) {
out.println("<a href=\"" 
+response.encodeURL("/servlet/items?bookId=" +bookId)+
                "\"> <strong>" + items[i].getName() + "</strong></a></td>");
             }
         }
     }



  
 
 

All Rights Reserved
Copyright ©  2004 SYS-CON Media, Inc.
  E-mail: [email protected]

Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.