Advertisement
berend

Cookies

Dec 12th, 2012
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. package com.bmtargoss.smart.webadmin;
  2.  
  3. import javax.servlet.http.Cookie;
  4. import javax.servlet.http.HttpServletRequest;
  5.  
  6. public class CookieUtils {
  7.  
  8.     public static int getServerId(HttpServletRequest hreq) {
  9.         int result = -1;
  10.        
  11.         /*
  12.          * Get cookie which includes the database id.
  13.          */
  14.         Cookie[] cookies = hreq.getCookies();
  15.         if (cookies != null) {
  16.           for (Cookie ck : cookies) {
  17.             if ("database".equals(ck.getName())) {
  18.                 result = Integer.parseInt(ck.getValue());
  19.             }
  20.           }
  21.         }
  22.        
  23.         return result;
  24.     }
  25.    
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement