由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - question: how to implement this
相关主题
一个关于generics的问题How to access ActiveX control in JSP or EJB?
Who's online--JSP?问一个J2EE和Tomcat问题
basic java questionWill Singleton Pattern work in Clustered Env?
static getInstance()三论abstract class
thread safe Singleton 的几种方法?JSP+SERVLET网站一般用下面方式来保存和传递变量和参数
看到一个关于singleton的面试题关于Jsp timeout
a synchonized problem!session lost between JSP and Struts
请教一个动态cast的问题关于RIA
相关话题的讨论汇总
话题: session话题: implement话题: question话题: jsp话题: class
进入Java版参与讨论
1 (共1页)
w******t
发帖数: 1422
1
Hi All,
I want to implment a class which gets instantiated only once per session.
Is there a way to do this? (I am out of idea on this now)
Thanks a lot!
h******b
发帖数: 312
2
static class?

~~~~~~~JSP?

【在 w******t 的大作中提到】
: Hi All,
: I want to implment a class which gets instantiated only once per session.
: Is there a way to do this? (I am out of idea on this now)
: Thanks a lot!

KG
发帖数: 515
3
Don't know what your environment is, but Singleton could be an option...

~~~~~~~JSP?

【在 h******b 的大作中提到】
: static class?
:
: ~~~~~~~JSP?

w******t
发帖数: 1422
4
singleton is one per app (in clustered environment, maybe one per jvm, if not
very strict) - not an option
I need one per session - sort of like stateful session bean, but I don't want
to use ejb, is this possible?

session.

【在 KG 的大作中提到】
: Don't know what your environment is, but Singleton could be an option...
:
: ~~~~~~~JSP?

n*****k
发帖数: 123
5

Are you using servlet? if do, you may first use
HttpServletRequest.getSession(false) to check if there is a session associated
with the request, then you can either create a new instance of this class and
then using HttpSession.putValue() method to store this new instance within the
session, or just retrive the instance from the session object.
Hope this will help.

【在 w******t 的大作中提到】
: Hi All,
: I want to implment a class which gets instantiated only once per session.
: Is there a way to do this? (I am out of idea on this now)
: Thanks a lot!

e***g
发帖数: 158
6
singleton doesn't mean single, it's about controlled instantiation.
class Foo
static public Foo getInstance(Session session){..}
this will work for you, right?

【在 w******t 的大作中提到】
: singleton is one per app (in clustered environment, maybe one per jvm, if not
: very strict) - not an option
: I need one per session - sort of like stateful session bean, but I don't want
: to use ejb, is this possible?
:
: session.

p***y
发帖数: 79
7
you can use similar idea as in singleton.

【在 w******t 的大作中提到】
: singleton is one per app (in clustered environment, maybe one per jvm, if not
: very strict) - not an option
: I need one per session - sort of like stateful session bean, but I don't want
: to use ejb, is this possible?
:
: session.

1 (共1页)
进入Java版参与讨论
相关主题
关于RIAthread safe Singleton 的几种方法?
Java EE 习题 1看到一个关于singleton的面试题
spring解决了什么问题?a synchonized problem!
Singleton Session Bean请教一个动态cast的问题
一个关于generics的问题How to access ActiveX control in JSP or EJB?
Who's online--JSP?问一个J2EE和Tomcat问题
basic java questionWill Singleton Pattern work in Clustered Env?
static getInstance()三论abstract class
相关话题的讨论汇总
话题: session话题: implement话题: question话题: jsp话题: class