1 package com.knowgate.http; 2 3 8 9 import java.net.URLDecoder ; 10 import javax.servlet.http.Cookie ; 11 import javax.servlet.http.HttpServletRequest ; 12 13 public class Cookies { 14 15 public static String getCookie (HttpServletRequest req, String sName, String sDefault) { 16 Cookie aCookies[] = req.getCookies(); 17 String sValue = null; 18 19 for (int c=0; c<aCookies.length; c++) { 20 if (aCookies[c].getName().equals(sName)) { 21 sValue = URLDecoder.decode(aCookies[c].getValue()); 22 break; 23 } } return sValue!=null ? sValue : sDefault; 26 } } | Popular Tags |