我如何在SERVLET中取得SESSION中的内容

jndszl 2003-10-12 07:40:15
我如何在SERVLET中取得SESSION中的内容,在JSP中取得SESSION中的内容我知道,因为JSP初始化的时候就把SESSION初始化好了,但我想在SERVLET中取得SESSION的值,但不成功,哪位有相就的SERVLET的源代码,给贴一下
...全文
456 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
aku0708 2003-10-15
  • 打赏
  • 举报
回复
在SERVLET中加入
HttpSession httpsession = HttpServletRequest.getSession();
honkyjiang 2003-10-15
  • 打赏
  • 举报
回复
public HttpSession getSession(boolean create)

Returns the current HttpSession associated with this request or, if if there is no current session and create is true, returns a new session.

If create is false and the request has no valid HttpSession, this method returns null.这几句英文搞不定那搞软件可就比较难了!
jndszl 2003-10-15
  • 打赏
  • 举报
回复
问题又来了,

加上 HttpSession httpsession = httpservletrequest.getSession();
中传入参数 true和false和不传参数,有什么区别
凋零的老树 2003-10-15
  • 打赏
  • 举报
回复
HttpSession httpsession = httpservletrequest.getSession();
jndszl 2003-10-15
  • 打赏
  • 举报
回复
HttpSession session=request.getSession(true);
strMobileNumber = session.getAttribute("mobile_num");


中的request.getSession(true); 这个TRUE 和 FALSE传进去这两个参数有什么区别
hozi 2003-10-14
  • 打赏
  • 举报
回复
HttpSession session=request.getSession(true);
strMobileNumber = session.getAttribute("mobile_num");
hj12 2003-10-14
  • 打赏
  • 举报
回复
HttpSession session=request.getSession();
session.getAttribute("sessVal");就这么写了
web_spider 2003-10-14
  • 打赏
  • 举报
回复
request.getSession().getAttribute("SessionVarName");
windowsDNA 2003-10-14
  • 打赏
  • 举报
回复
in servlet:
HttpSession session=request.getSession();
session.getAttribute("sessVal");
emaoshan0731 2003-10-12
  • 打赏
  • 举报
回复
因为JSP初始化的时候就把SESSION初始化好了,

这句话错了!要通过 HttpSession session = New HttpSession();这样才能访问Session!

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧