top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Cookie in struts2

0 votes
94 views

I have no difficulty to handle cookie in struts 1, but have lots of error in struts 2

i have the following program

public class SecurityVerifySessionIntercepter extends AbstractInterceptor implements ServletResponseAware, ServletRequestAware {
....

Map session= ActionContext.getContext().getSession();

Cookie cookieList[]=HttpServletRequest.getCookies();

for above program, the compiler give so much error about cookie.

cannot find symbol
symbol  : class Cookie
location: class SecurityVerifySessionIntercepter
          Cookie cookieList[]=HttpServletRequest.getCookies();

non-static method getCookies() cannot be referenced from a static context
          Cookie cookieList[]=HttpServletRequest.getCookies();

please advise

posted May 15, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

2 Answers

0 votes

Import the Cookie class, and get the cookies from the request, not the class of the request?

answer May 15, 2013 by anonymous
thanks, in my program, after i import it, the compile error is gone.
0 votes

You might want to look into the CookiesAware interface. It's a better way of accessing cookies. Here's a good post on handling Cookies in Struts 2: http://omkarp.blogspot.com/2007/07/working-with-cookies-in-struts2.html

answer May 15, 2013 by anonymous
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...