Examples of Cookie


Examples of javax.servlet.http.Cookie

   * @param cookieName
   * @return
   */
  public static String getCookieValue(HttpServletRequest request, String cookieName) {
    try {
      Cookie cookie = getCookie(request, cookieName);
      if (null == cookie) {
        return null;
      } else {
        return URLDecoder.decode(cookie.getValue(), "utf-8");
      }
    } catch (Exception e) {
      return null;
    }
  }
View Full Code Here

Examples of javax.servlet.http.Cookie

   *            the name of the cookie to find
   * @return the cookie (if found), null if not found
   */
  public static Cookie getCookie(HttpServletRequest request, String name) {
    Cookie[] cookies = request.getCookies();
    Cookie returnCookie = null;

    if (cookies == null) { return returnCookie; }
    for (int i = 0; i < cookies.length; i++) {
      Cookie thisCookie = cookies[i];
      if (thisCookie.getName().equals(name) && !thisCookie.getValue().equals("")) {
        returnCookie = thisCookie;
        break;
      }
    }
    return returnCookie;
View Full Code Here

Examples of javax.servlet.http.Cookie

   * @param path
   */
  public static void addCookie(HttpServletRequest request, HttpServletResponse response, String name,
      String value, String path, int age) {
    LOG.debug("add cookie[name:{},value={},path={}]", new String[] { name, value, path });
    Cookie cookie = null;
    try {
      cookie = new Cookie(name, URLEncoder.encode(value, "utf-8"));
    } catch (UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }
    cookie.setSecure(false);
    cookie.setPath(path);
    cookie.setMaxAge(age);
    response.addCookie(cookie);
  }
View Full Code Here

Examples of javax.servlet.http.Cookie

            try {
                int equals = token.indexOf('=');
                if (equals > 0) {
                    String name = token.substring(0, equals).trim();
                    String value = token.substring(equals+1).trim();
                    cookies.add(new Cookie(name, value));
                }
            } catch (Throwable e) {
               
            }
        }
View Full Code Here

Examples of javax.servlet.http.Cookie

         getNext().invoke(request, response);
         return;
      }

      // Check for the single sign on cookie
      Cookie cookie = null;
      Cookie cookies[] = request.getCookies();
      if (cookies == null)
         cookies = new Cookie[0];
      for (int i = 0; i < cookies.length; i++)
      {
         if (Constants.SINGLE_SIGN_ON_COOKIE.equals(cookies[i].getName()))
View Full Code Here

Examples of javax.servlet.http.Cookie

  }
 
  private void setRFC2019cookies(HttpServletRequest request, HttpServletResponse response) {
   
    //A very simple cookie
    Cookie cookie = new Cookie("simpleCookie","jboss");
    response.addCookie(cookie);   
   
    //A cookie with space in the value. As per ASPATCH-70, there has been some issue with this.
    cookie = new Cookie("withSpace", "jboss rocks");
    response.addCookie(cookie);
   
    //cookie with comment
    //TODO read servlet 2.5 spec and rfc2109, then re-fix it
    /* Servlet 2.5 Cookie.java disable comment attribute
    cookie = new Cookie("comment", "commented cookie");
    cookie.setComment("This is a comment");
    response.addCookie(cookie);
    */
   
    //cookie with expiry time. This cookie must not be set on client side
    cookie = new Cookie("expired","expired cookie");
    cookie.setMaxAge(0);
    response.addCookie(cookie);
   
    cookie = new Cookie("withComma","little,comma");
    response.addCookie(cookie);
   
    cookie = new Cookie("expireIn10Sec","will expire in 10 seconds");
    cookie.setMaxAge(10);
    response.addCookie(cookie);
  }
View Full Code Here

Examples of javax.ws.rs.core.Cookie

      return this;
   }

   public MockHttpRequest cookie(String name, String value)
   {
      Cookie cookie = new Cookie(name, value);
      httpHeaders.getCookies().put(name, cookie);
      return this;
   }
View Full Code Here

Examples of net.matuschek.http.cookie.Cookie

    JOptionPane.showMessageDialog(this, "Domain invalid: "+e1.getMessage());
    return;
  }
  try {
      if (cookieStr.startsWith("Set-Cookie")) {
        Cookie cookie;
      cookie = new Cookie(cookieStr,url);
      jobobase.getRobot().getCookieManager().add(cookie);
        JOptionPane.showMessageDialog(this, "Cookie added");
      } else {
        Cookie[] cookies = Cookie.cookieStringToCookies(cookieStr, domain);
        for (int i=0; i<cookies.length; i++) {
View Full Code Here

Examples of net.matuschek.http.cookie.Cookie

      doc.addHeader(head);

      if (cookiesEnabled
    && head.isSetCookie()) {
        try {
    Cookie cookie = new Cookie(head.toLine(),u);
    cookieManager.add(cookie);
    log.debug("Got a cookie "+cookie);
        } catch (CookieException e) {
    log.info("Could not interpret cookie: "+e.getMessage());
        }
View Full Code Here

Examples of ninja.Cookie

        assertEquals("mockedRemoteAddr", context.getRemoteAddr());
    }

    @Test
    public void testAddCookieViaResult() {
        Cookie cookie = Cookie.builder("cookie", "yum").setDomain("domain").build();
        context.init(servletContext, httpServletRequest, httpServletResponse);
        //context.addCookie(cookie);

        //generate an arbitrary result:
        Result result = Results.html();
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.