session-scope

How does a ScopedProxy decide what Session to use?

风格不统一 提交于 2019-11-27 16:18:41
问题 A Singleton can not autowire a SessionBean but a ScopedProxy can. Assuming 100 users have a valid Session at the same time in the same application, how does the ScopedProxy decide what session is meant? I don't think the ScopedProxy is choosing any random session, this would be nonsense in my opinion. How does the ScopedProxy decide what session to use? What if 0 users have a Session? Will a NullPointerException occur? A @Async is a different Thread than the invoking Request-Processing-Thread

Are session and sessionScope the same in JSP EL?

扶醉桌前 提交于 2019-11-27 12:27:35
public class LoginAction extends ActionSupport { private String username; private String password; @Override public String execute() throws Exception { ActionContext ctx = ActionContext.getContext(); Integer counter = (Integer)ctx.getApplication().get("counter"); // put counter into application ctx.getApplication().put("counter", counter); // put username into session ctx.getSession().put("user", username); if (getUsername().equals("crazyit.org") && getPassword().equals("leegang")) { ctx.put("tip", "Login Success! "); return SUCCESS; } else { ctx.put("tip", "Login Falied!"); return ERROR; } }

Access session scoped bean from request scoped bean

送分小仙女□ 提交于 2019-11-27 02:33:18
问题 I'm trying to use a pattern found on a IceFaces page.(I'm not using IceFaces, using PrimeFaces) In this case I have two beans: UserController and Usermodel On my UserModel I have a instance of UserVO (created by another programmer). On My UserController I have this: @ManagedBean @RequestScoped public class UserController implements Serializable { private static final long serialVersionUID = 1L; private UserBO bo; private UserModel model; public UserController() { bo = new UserBO(); model =

Are session and sessionScope the same in JSP EL?

前提是你 提交于 2019-11-26 16:01:23
问题 public class LoginAction extends ActionSupport { private String username; private String password; @Override public String execute() throws Exception { ActionContext ctx = ActionContext.getContext(); Integer counter = (Integer)ctx.getApplication().get("counter"); // put counter into application ctx.getApplication().put("counter", counter); // put username into session ctx.getSession().put("user", username); if (getUsername().equals("crazyit.org") && getPassword().equals("leegang")) { ctx.put(

Dependency Injection in Struts2 Accessing Session Scoped Beans

不打扰是莪最后的温柔 提交于 2019-11-26 13:51:23
Recently I needed to use DI in Struts2. I know it uses it's own DI implementation like Guice but not Guice, as far as I couldn't find some annotations suitable to set the scope for injected beans. To be short, I created a bean //@Repository //@Scope("session") public class Session { private Map<String, Object> map = new HashMap<>(); public Map<String, Object> getMap() { return map; } public void setMap(Map<String, Object> map) { this.map = map; } } I have commented the annotations used with Spring beans. I was successfully created the same bean via spring DI and set the scope in which my

Dependency Injection in Struts2 Accessing Session Scoped Beans

心已入冬 提交于 2019-11-26 03:44:53
问题 Recently I needed to use DI in Struts2. I know it uses it\'s own DI implementation like Guice but not Guice, as far as I couldn\'t find some annotations suitable to set the scope for injected beans. To be short, I created a bean //@Repository //@Scope(\"session\") public class Session { private Map<String, Object> map = new HashMap<>(); public Map<String, Object> getMap() { return map; } public void setMap(Map<String, Object> map) { this.map = map; } } I have commented the annotations used

How to invalidate session in JSF 2.0?

安稳与你 提交于 2019-11-26 01:06:56
问题 What is the best possible way to invalidate session within a JSF 2.0 application? I know JSF itself does not handle session. So far I could find private void reset() { HttpSession session = (HttpSession) FacesContext.getCurrentInstance() .getExternalContext().getSession(false); session.invalidate(); } Is this method correct? Is there a way without touching the ServletAPI? Consider a scenario wherein a @SessionScoped UserBean handles the login-logout of a user. I have this method in the same

How to invalidate session in JSF 2.0?

那年仲夏 提交于 2019-11-26 00:58:50
What is the best possible way to invalidate session within a JSF 2.0 application? I know JSF itself does not handle session. So far I could find private void reset() { HttpSession session = (HttpSession) FacesContext.getCurrentInstance() .getExternalContext().getSession(false); session.invalidate(); } Is this method correct? Is there a way without touching the ServletAPI? Consider a scenario wherein a @SessionScoped UserBean handles the login-logout of a user. I have this method in the same bean. Now when I call the reset() method after I'm done with necessary DB updates, what will happen to