开发者

Is there only one way to get session in java calling request.getSession()?

I like to know is there only one way 开发者_如何转开发to call session using request.getSession() or is there any other way?


The api shows two methods. Basically one creates the session for you if needed, and the other doesn't.

http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServletRequest.html#getSession%28%29

and

http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServletRequest.html#getSession%28boolean%29


If you're thinking of something like MagicSessionSignleton.getSession(), that can be called from anywhere in the code, unfortunately there isn't. You can however, build a filter that does that for you (or use a framework that provides simple access to the request/session context).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜