Examples of Cookie


Examples of javax.servlet.http.Cookie

     * will always try to set this cookie again)
     */
    public static Cookie setCookie(HttpServletRequest request, HttpServletResponse response, String name, String value, int maxAge, String path)
    {
        log.debug("CookieUtils.setCookie " + name + ":" + value);
        Cookie cookie = new Cookie(name, value);
        cookie.setMaxAge(maxAge);
        cookie.setPath(path);
        response.addCookie(cookie);

        return cookie;
    }
View Full Code Here

Examples of javax.servlet.http.Cookie

     * @param name the name of the cookie
     * @return the value of the cookie, or null if the cookie does not exist.
     */
    public static String getCookieValue(HttpServletRequest request, String name)
    {
        Cookie cookie = getCookie(request, name);
        if (cookie != null)
        {
            return cookie.getValue();
        }
        return null;
    }
View Full Code Here

Examples of javax.servlet.http.Cookie

            anvil.Log.log().debug("   " + key + " : " + value);
        }
        anvil.Log.log().debug("Cookies in this request");
        Cookie[] cookies = request.getCookies();
        for (int i = 0; i < cookies.length; i++) {
            Cookie cookie = cookies[i];
            anvil.Log.log().debug("   " + cookie.getName() + " = " + cookie.getValue());
        }
        anvil.Log.log().debug("Auth Type: " + request.getAuthType());
        anvil.Log.log().debug("HTTP Method: " + request.getMethod());
        anvil.Log.log().debug("Path Info: " + request.getPathInfo());
        anvil.Log.log().debug("Path Trans: " + request.getPathTranslated());
View Full Code Here

Examples of javax.servlet.http.Cookie

        }
        return headerName;
    }

    private Cookie getCookie(String cookieName, InjectionPoint ip) {
        Cookie cookie = null;
        for (Cookie c : request.getCookies()) {
            if (c.getName().equals(cookieName)) {
                cookie = c;
                break;
            }
        }

        if (cookie == null) {
            String defaultValue = getDefaultValue(ip);
            if (defaultValue != null) {
                cookie = new Cookie(cookieName, defaultValue);
            }
        }

        return cookie;
    }
View Full Code Here

Examples of javax.servlet.http.Cookie

  public Cookie[] getCookies() {
    List<Cookie> cookies = new ArrayList<Cookie>();
    if ( ! fCookies.isEmpty() ) {
      for(String name: fCookies.keySet()){
        String value = fCookies.get(name);
        Cookie cookie = new Cookie(name, value);
        cookies.add(cookie);
      }
    }
    return cookies.isEmpty() ? null : cookies.toArray(new Cookie[0]);
  }
View Full Code Here

Examples of javax.servlet.http.Cookie

    Cookie[] cookies = aRequest.getCookies();
    if ( cookies != null ){
      List cookieList = Arrays.asList(cookies);
      Iterator iter = cookieList.iterator();
      while ( iter.hasNext() ) {
        Cookie cookie = (Cookie)iter.next();
        result.put(cookie.getName(), "Value:" + cookie.getValue() + ", Comment:" + cookie.getComment() + ", Domain:" + cookie.getDomain() + ", Max-Age:" + cookie.getMaxAge() + ", Path:" + cookie.getPath() + ", Spec- Version:" + cookie.getVersion());
      }
      result = sortMap(result);
    }
    return result;
  }
View Full Code Here

Examples of javax.servlet.http.Cookie

  public void index(HttpServletRequest request, HttpServletResponse response, PrintWriter out) {

    String cookieName = request.getParameter("cookiename");
    String cookieValue = request.getParameter("cookievalue");
    Cookie aCookie = null;
    if (cookieName != null && cookieName.length() > 0 && cookieValue != null) {
      aCookie = new Cookie(cookieName, cookieValue);
      response.addCookie(aCookie);
    }

    response.setContentType("text/html");
    out.println("<html>");
    out.println("<body bgcolor=\"white\">");
    out.println("<head>");

    String title = RB.getString("cookies.title");
    out.println("<title>" + title + "</title>");
    out.println("</head>");
    out.println("<body>");

    // relative links

    // XXX
    // making these absolute till we work out the
    // addition of a PathInfo issue

    out.println("<a href=\"../cookies.html\">");
    out.println("<img src=\"../images/code.gif\" height=24 " + "width=24 align=right border=0 alt=\"view code\"></a>");
    out.println("<a href=\"../index.html\">");
    out.println("<img src=\"../images/return.gif\" height=24 " + "width=24 align=right border=0 alt=\"return\"></a>");

    out.println("<h3>" + title + "</h3>");

    Cookie[] cookies = request.getCookies();
    if ((cookies != null) && (cookies.length > 0)) {
      out.println(RB.getString("cookies.cookies") + "<br>");
      for (int i = 0; i < cookies.length; i++) {
        Cookie cookie = cookies[i];
        out.print("Cookie Name: " + HTMLFilter.filter(cookie.getName()) + "<br>");
        out.println("  Cookie Value: " + HTMLFilter.filter(cookie.getValue()) + "<br><br>");
      }
    } else {
      out.println(RB.getString("cookies.no-cookies"));
    }
View Full Code Here

Examples of javax.servlet.http.Cookie

import javax.servlet.http.HttpServletRequest;

public class Cookies {

  public static String getCookie (HttpServletRequest req, String sName, String sDefault) {
    Cookie aCookies[] = req.getCookies();
    String sValue = null;

    for (int c=0; c<aCookies.length; c++) {
      if (aCookies[c].getName().equals(sName)) {
        sValue = URLDecoder.decode(aCookies[c].getValue());
View Full Code Here

Examples of javax.servlet.http.Cookie

    return sValue!=null ? sValue : sDefault;
  } // getCookie()

  public static String getCookie (HttpServletRequest req, String sName, String sDefault, String sEncoding)
    throws java.io.UnsupportedEncodingException {
    Cookie aCookies[] = req.getCookies();
    String sValue = null;

    if (null != aCookies) {
      for (int c=0; c<aCookies.length; c++) {
        if (aCookies[c].getName().equals(sName)) {
View Full Code Here

Examples of javax.servlet.http.Cookie

      String defaultValue) {
    if(cookies == null){
      return null;
    }
    for (int i = 0; i < cookies.length; i++) {
      Cookie cookie = cookies[i];
      if (cookieName.equals(cookie.getName()))
        return (cookie.getValue());
    }
    return (defaultValue);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.