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

Facebook Login
Site Registration
Print Preview

Cookie in struts2

0 votes

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:

answer May 15, 2013 by anonymous
Similar Questions
+1 vote

Will it restrict the information being stored at the browser cache.

+2 votes

Anyone have tried struts2 on springboot? can we run it on spring boot? or anyone tested it?

+1 vote

We are in the beginning of the migration to struts2 and it seems like there will be some period when both frameworks will be active at the same time..the only problem now is accessing the session beans managed by struts2 in struts1 and vice-versa form beans from strut1 mapped in struts2 . Half of the jsp would use struts1 tags and other half struts2 tags. So there should be beans instantiated in both frameworks.

Probably struts2 bean can be injected to struts1 action with struts1 form still accessible as execute() argument, but what about other way? accessing struts1 form bean (not just data, but managed bean) in struts2 execute() ?

Useful Links with Similar Problem
Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.