Notice
Recent Posts
Recent Comments
Link
- Arawn's Dev Blog
- Outsider's Dev Story
- Toby's Epril
- Benelog
- NHN 개발자 블로그
- SK 플래닛 기술 블로그
- OLC CENTER
- 소프트웨어 경영/공학 블로그
- 모바일 컨버전스
- KOSR - Korea Operating System …
- 넥스트리 블로그
- 리버스코어 ReverseCore
- SLiPP
- 개발자를 위하여... (Nextree 임병인 수석)
- "트위터 부트스트랩: 디자이너도 놀라워할 매끈하고 직관…
- Learning English - The English…
- real-english.com
- 'DataScience/Deep Learning' 카테…
- Deep Learning Summer School, M…
- Deep Learning Courses
민서네집
[java] request.getSession(); 값이 null 이 될 수 있다. 본문
HttpSession session = request.getSession();
위 코드에서 getSession() 의 설명을 찾아보면,
HttpSession getSession()
- Returns the current session associated with this request, or if the request does not have a session, creates one.
-
-
- Returns:
- the
HttpSession
associated with this request - See Also:
getSession(boolean)
이렇게 나와 있다.
그래서 null 이 안 나올 줄 알았는데, null 이 나오는 경우가 있었다.
request 변수를 static 변수로 만들었는데, (물론 이렇게 만들면 안된다.)
A request 에서 B request 값을 통해 getSession() 을 호출했더니, getSession() 이 null 이 되었다.
이 경우 request.isRequestedSessionIdValid() 를 호출해 보았더니, false 가 나왔다.
boolean isRequestedSessionIdValid()
- Checks whether the requested session ID is still valid.
If the client did not specify any session ID, this method returns
false
. -
-
- Returns:
true
if this request has an id for a valid session in the current session context;false
otherwise- See Also:
getRequestedSessionId()
,getSession(boolean)
,HttpSessionContext
이런 특별한 경우가 아니더라도, session 값이 있기는 있되, 만료되서 invalidate 된 session 이라면
request.getSession() 의 값이 null 이 나올것 같다.
'Java' 카테고리의 다른 글
[eclipse] 특정 폴더 이하를 validation에서 제외시키기 (How to exclude specific folders or files from validation in Eclipse?) (0) | 2013.08.17 |
---|---|
[maven] pom.xml profile 설정 (0) | 2013.08.15 |
[eclipse] github 와 연동하기. (0) | 2013.07.28 |
eclipse에서 Web Application 이 시작하지 못하는 이유 (0) | 2013.07.26 |
Java Reflection 설명 잘 된 웹페이지 (0) | 2013.07.22 |
Comments