R
Robert Maas, see http://tinyurl.com/uh3t
I'm writing a J2EE HttpServlet. The user logs in, gets a menu back,
then clicks on something in the menu to invoke some particular servlet
task. If cookies are enabled, the J2EE servlet container uses the
jsession (or something like that) cookie to retrieve the same old
session object on each HTTP connection. But if cookies aren't enabled,
a new session object is constructed on each new HTTP connection. But
within the form filled out by the user, there's a hidden field
containing the session ID, so even when cookies aren't enabled the
servlet knows the correct session ID and can perform stateless queries
for this user. The application stores login status in a table in a
database, so recognizing the session ID is valid, and from that knowing
which user is re-connecting, is no problem. Also for simple textual or
numeric data that needs to be retained from connection to connection,
storing the data, associated with the session-ID as a key, in the
database, is no problem. But what if I want to store a more complex
Java object in the session object and retrieve it upon
HTTP-reconnection? Is there any way the servlet can query the J2EE
servlet container to find out whether this known session-ID is
associated with any still-existing session object, and if so return
that session object so the servlet can then retrieve Java objects that
had been previously stored in it? I looked in the API spec for
HttpSession, HttpServlet and even HttpServletRequest, but I didn't find
any such method anywhere in there. Anybody know any such? I would hate
ot have to serialize an object and write the serialization as one
humungous varchar to a database, maybe broken into many pieces to fit
the maximum varchar allowed in CloudScape (here where I'm developing
the program) or MicroSoft ACCESS (on campus where I must demo it), or
write the serialization to a disk file in the system temporary
directory and put the filename in the database.
(Note, I'm using Java version 1.3.1 here, if that makes any difference.)
(and version 1.4.1 on campus, so whatever must work in both.)
then clicks on something in the menu to invoke some particular servlet
task. If cookies are enabled, the J2EE servlet container uses the
jsession (or something like that) cookie to retrieve the same old
session object on each HTTP connection. But if cookies aren't enabled,
a new session object is constructed on each new HTTP connection. But
within the form filled out by the user, there's a hidden field
containing the session ID, so even when cookies aren't enabled the
servlet knows the correct session ID and can perform stateless queries
for this user. The application stores login status in a table in a
database, so recognizing the session ID is valid, and from that knowing
which user is re-connecting, is no problem. Also for simple textual or
numeric data that needs to be retained from connection to connection,
storing the data, associated with the session-ID as a key, in the
database, is no problem. But what if I want to store a more complex
Java object in the session object and retrieve it upon
HTTP-reconnection? Is there any way the servlet can query the J2EE
servlet container to find out whether this known session-ID is
associated with any still-existing session object, and if so return
that session object so the servlet can then retrieve Java objects that
had been previously stored in it? I looked in the API spec for
HttpSession, HttpServlet and even HttpServletRequest, but I didn't find
any such method anywhere in there. Anybody know any such? I would hate
ot have to serialize an object and write the serialization as one
humungous varchar to a database, maybe broken into many pieces to fit
the maximum varchar allowed in CloudScape (here where I'm developing
the program) or MicroSoft ACCESS (on campus where I must demo it), or
write the serialization to a disk file in the system temporary
directory and put the filename in the database.
(Note, I'm using Java version 1.3.1 here, if that makes any difference.)
(and version 1.4.1 on campus, so whatever must work in both.)