httpsession

When does JSF creates a session & what does it puts in a session map?

删除回忆录丶 提交于 2019-12-04 05:02:00
问题 I am running Mojarra 2.2.0. <context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>client</param-value> </context-param> The managed bean action method is- public void action() { HttpSession session = (HttpSession) FacesContext.getCurrentInstance() .getExternalContext().getSession(false); System.out.println(session.getId()); // not null for stateful views } For stateless views session.getId() throws NPE For views which are not stateless- Firing a GET request,

Xhtml pages and HttpSession test , no jstl?

蓝咒 提交于 2019-12-03 21:38:37
I have a dynamic web application in Java EE with JSF, Facelets, Richfaces. My pages are all xhtml pages. So JSTL isn't working in it. For my account pages and all other private pages to be reachable, I want to test if the user got connected, so if the attribute session in HttpSession is not null. If it's null, the user gets redirected in the welcome page. I tried in my xhtml page : <jstl:if test="${sessionScope['session']==null}"> <jstl redirect...> </jstl:if>--> but as it's not jsp page it won't work. So where am I supposed to test if the session is not null to allow the user to see his

Why isn't getSession() returning the same session in subsequent requests distanced in short time periods?

巧了我就是萌 提交于 2019-12-03 09:02:40
问题 I am sending a $.getJSON (HTTP GET) request twice (with different data), one after another (lets say we have request1 and request2). I can see in the developer tools from FF and Chrome that I have the same cookie:JSESSIONID=FD0D502635EEB67E3D36203E26CBB59A header field. On the server side I try to get the session: HttpSession session = request.getSession(); boolean isSessionNew = session.isNew(); String sessionId = session.getId(); String cookieFromRequestHeader = request.getHeader("cookie");

Grails get Session and Management in Service class

ぐ巨炮叔叔 提交于 2019-12-03 09:00:48
问题 I have a problem with Grails Session. I was thinking about having a Service Class for my session handling. So I created a class called "SessionService" (under grails-app/services/grails/). class SessionService { static transactional = true GrailsWebRequest request = RequestContextHolder.currentRequestAttributes() GrailsHttpSession session = request.session def setTestvar(String value) { if (session != null) session.setAttribute("sTeststring", value) } def getTestvar() { if (session != null)

Spring MVC - difference between HttpSession.setAttribute and model.addObject

☆樱花仙子☆ 提交于 2019-12-03 07:33:56
I am trying to learn Spring MVC recently. It seems that i did not understand well the functionalities of @ModelAttribute annotation and HttpSession. @SessionAttributes({"shoppingCart", "count"}) public class ItemController { @ModelAttribute("shoppingCart") public List<Item> createShoppingCart() { return new ArrayList<Item>(); } @ModelAttribute("count") public Integer createCount() { return 0; } @RequestMapping(value="/addToCart/{itemId}", method=RequestMethod.GET) public ModelAndView addToCart(@PathVariable("itemId") Item item, @ModelAttribute("shoppingCart") List<Item> shoppingCart,

Java HttpSession

笑着哭i 提交于 2019-12-03 07:24:35
问题 Is HttpSession in java servlet is created only after HttpSession s = request.getSession(); ? In my code I didn't write that, but when I use if (request.getSession(false) == null) ... , it doesn't work. Why? 回答1: A HttpSession is created when calling request.getSession(). But if you access a JSP by default it will automatically create a session.This behaviour can be disabled by using: <%@ page session="false"> Are you using JSP? 回答2: Read JavaDocs, it says clearly: This says, request

Spring session-scoped beans as dependencies in prototype beans?

笑着哭i 提交于 2019-12-03 05:21:42
问题 I read spring docs on this subject several times, but some things are still unclear to me. Documentation states: If you want to inject (for example) an HTTP request scoped bean into another bean, you must inject an AOP proxy in place of the scoped bean. That is, you need to inject a proxy object that exposes the same public interface as the scoped object but that can also retrieve the real, target object from the relevant scope (for example, an HTTP request) and delegate method calls onto the

Why isn't getSession() returning the same session in subsequent requests distanced in short time periods?

血红的双手。 提交于 2019-12-02 23:16:35
I am sending a $.getJSON (HTTP GET) request twice (with different data), one after another (lets say we have request1 and request2). I can see in the developer tools from FF and Chrome that I have the same cookie:JSESSIONID=FD0D502635EEB67E3D36203E26CBB59A header field. On the server side I try to get the session: HttpSession session = request.getSession(); boolean isSessionNew = session.isNew(); String sessionId = session.getId(); String cookieFromRequestHeader = request.getHeader("cookie"); If I print these variables for both requests I get, request1: isSessionNew:true

Grails get Session and Management in Service class

大城市里の小女人 提交于 2019-12-02 22:58:26
I have a problem with Grails Session. I was thinking about having a Service Class for my session handling. So I created a class called "SessionService" (under grails-app/services/grails/). class SessionService { static transactional = true GrailsWebRequest request = RequestContextHolder.currentRequestAttributes() GrailsHttpSession session = request.session def setTestvar(String value) { if (session != null) session.setAttribute("sTeststring", value) } def getTestvar() { if (session != null) session.getAttribute("sTeststring") } } The Problem is now, that I get a Nullpointer-Exception: " Method

Java HttpSession

两盒软妹~` 提交于 2019-12-02 20:56:19
Is HttpSession in java servlet is created only after HttpSession s = request.getSession(); ? In my code I didn't write that, but when I use if (request.getSession(false) == null) ... , it doesn't work. Why? A HttpSession is created when calling request.getSession(). But if you access a JSP by default it will automatically create a session.This behaviour can be disabled by using: <%@ page session="false"> Are you using JSP? Read JavaDocs, it says clearly: This says, request.getSession() Returns the current session associated with this request, or if the request does not have a session, creates