Link to home
Start Free TrialLog in
Avatar of k41d3n
k41d3n

asked on

Cookie method error

I got this method from an older jsp question:

public static String getCookieValue(String cookieName) {
     Cookie[] theCookies = request.getCookies();
     if (theCookies != null) {
        for (int i =0; i< cookies.length; i++) {
           Cookie currentCookie = theCookies[i];
           if (currentCookie.getName().equalsIgnoreCase(cookieName)
            return currentCookie.getValue();
           }
        }
   return null;
}

but when I try to use it, I get an error on the line:


     Cookie[] theCookies = request.getCookies();

that says package request does not exist.

Any ideas?

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of ldbkutty
ldbkutty
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of k41d3n
k41d3n

ASKER

I do :(
SOLUTION
Avatar of ramazanyich
ramazanyich
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of k41d3n

ASKER

Excellent, thank you.

I dont understand..i showed the same in my code and explained it as "request defined"

?
Avatar of k41d3n

ASKER

You are absolutely correct, it's my fault I didn't read it properly.
Thanks for replying.

Please post here a Question and the moderators will re-open this Question:
https://www.experts-exchange.com/Community_Support/

:-)