Package javax.servlet.http

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


         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

  }
 
  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

         Context context = (Context) container_;
         Connector connector = ((Response) response).getConnector();
         if (context.getCookies())
         {
            // set a new session cookie
            Cookie cookie = new Cookie(Globals.SESSION_COOKIE_NAME, sessionId);
            // JBAS-6206. Configure cookie a la o.a.c.connector.Request.configureSessionCookie()
            cookie.setMaxAge(-1);
            if (context.getSessionCookie().getPath() != null)
            {
               cookie.setPath(context.getSessionCookie().getPath());
            }
            else
            {
               String contextPath = context.getEncodedPath();
               if ("".equals(contextPath))
               {
                  contextPath = "/";
               }
               cookie.setPath(contextPath);
            }
            if (context.getSessionCookie().getComment() != null)
            {
               cookie.setComment(context.getSessionCookie().getComment());
            }
            if (context.getSessionCookie().getDomain() != null)
            {
               cookie.setDomain(context.getSessionCookie().getDomain());
            }
            if (context.getSessionCookie().isHttpOnly())
            {
               cookie.setHttpOnly(true);
            }
            if (context.getSessionCookie().isSecure())
            {
               cookie.setSecure(true);
            }
            if (connector.getSecure())
            {
               cookie.setSecure(true);
            }

            if (trace_)
            {
               log_.trace("Setting cookie with session id:" + sessionId + " & name:" + Globals.SESSION_COOKIE_NAME);
View Full Code Here

   protected void saveRequest(Request request, Session session)
       throws IOException {

       // Create and populate a SavedRequest object for this request
       SavedRequest saved = new SavedRequest();
       Cookie cookies[] = request.getCookies();
       if (cookies != null) {
           for (int i = 0; i < cookies.length; i++)
               saved.addCookie(cookies[i]);
       }
       Enumeration names = request.getHeaderNames();
View Full Code Here

  /**
   * Sets a cookie with given name and value in given response.
   */
  public static void set(HttpServletResponse response, String name,
      String value, int expiry) {
    Cookie cookie = new Cookie(name, value);
    cookie.setPath("/");
    cookie.setMaxAge(expiry);
    response.addCookie(cookie);
  }
View Full Code Here

  
   public void testBasic() throws Exception
   {
      AbstractJBossManager mgr = getManager(getContext(CONTEXT_PATH));
     
      Cookie cookie = validateResponse(executeRequest(mgr, false));
      validateCookie(cookie, CONTEXT_PATH, false);
   }
View Full Code Here

  
   public void testRootContext() throws Exception
   {
      AbstractJBossManager mgr = getManager(getContext(ROOT_PATH));
     
      Cookie cookie = validateResponse(executeRequest(mgr, false));
      validateCookie(cookie, ROOT_PATH, false);
   }
View Full Code Here

  
   public void testEmptyContextPath() throws Exception
   {
      AbstractJBossManager mgr = getManager(getContext(""));
     
      Cookie cookie = validateResponse(executeRequest(mgr, false));
      validateCookie(cookie, ROOT_PATH, false);
   }
View Full Code Here

  
   public void testSecureConnector() throws Exception
   {
      AbstractJBossManager mgr = getManager(getContext(CONTEXT_PATH));
     
      Cookie cookie = validateResponse(executeRequest(mgr, true));
      validateCookie(cookie, CONTEXT_PATH, true);
   }
View Full Code Here

TOP

Related Classes of javax.servlet.http.Cookie

Copyright © 2018 www.massapicom. 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.