Posts

Showing posts from July, 2020

Struts 2 Troubleshooting

Image
  How to add session in struts2 action class: You can access the session object using a jsp scriplet and set your required variables there. <% request.getSession().setAttribute("your_variable",obj) %> From the Action class , you can get access to session either by implementing the ServletRequestAware Interface within your action class or by implementing the SessionAware interface. request.getSession().getAttribute("var"); ref:   http://struts.1045723.n5.nabble.com/How-to-set-a-variable-in-session-in-the-JSP-td3499780.html OR add an attribute "private Map session;" in Action class. create getters and setters. use below code to put and get values from sesiion. session = ActionContext.getContext().getSession();  session.put("logged_in", "no"); boolean loggedIn = (Boolean) session.get("logged-in"); session.remove("selectedMatch");