如何获得一个servlet与另一个servlet的会话属性? [英] How to get the session attributes of one servlet un another servlet?

查看:144
本文介绍了如何获得一个servlet与另一个servlet的会话属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我有三个servlet,一个在另一个servlet中被调用.我在第一个servlet中创建一个http会话并为其设置一些属性.我想在第二和第三小服务程序中获取这些属性.我怎样才能做到这一点?请提出一种方法并提供适当的语法.

在此先感谢.

Hello,

I have three servlets one being called from within another.Im creating a http session in first servlet and setting some attributes for it. I want to getthose attributes in second and thirdservlets. How can i do that? Please suggest a way and give appropriate syntax.

Thanks in advance.

推荐答案

If two servlets are in the same webapp, they share the same session context, and the session is the same for both servlets. Of course, remember that a session is tight to a particular user.

Object value = request.getSession().getAttribute("nameOfTheAttributeUsedInTheFirstServlet");


这篇关于如何获得一个servlet与另一个servlet的会话属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆