I now see your problem.
What you need to do in that case, I
reckon, is send keepalives from the applet to the very same sevlet which
generated the page, using the URL given upon calling applet's
getDocumentBase() method, and write you servlet code so that UR Rewriting is
enabled (using response.encodeURL()).
here's how it should go:
1. Client
presses a link which leads him/her to the page containing the applet.
2. The
applet is loaded and started.
3. Using some sort of keep-alive thread, the
applet performs something like:
URL
whereICameFrom = this.getDocumentBase();
// this will return a url similar to
// http://myserver:80/chat?sessionid=243523657892638947
whereICameFrom.openConnection().getContent();
and do this periodically. This will cause some extra overhead in
network traffic, but it will allow, to my opinion, maintaining the session. the
servlet container will resume the session based on the session id supplied in
the url.
zm.
-----Original
Message-----
From: A mailing list about Java Server Pages specification and
reference [mailto:[EMAIL PROTECTED]]On
Behalf Of Christian Kurze
Sent: Monday, December 31, 2001 2:02 AM
To:
[EMAIL PROTECTED]
Subject: Re: Session in Applet??
Yes I
know. I implemented a chat-webapp, based on JSPs and Servlets. It
worked with
some JavaScript code. I used some examples from JavaWorld
(http://www.javaworld.com/javaworld/jw-03-2000/jw-03-pushlet_p.html).
But
that doesn't work with some browsers, e.g. Opera. I used the session
to
'save' a bean, the chatuser. In this bean all the properties are
set.
The problem is that the chat is part of a large community-framework and
the
session timeout is set to 15 minutes. So if someone chats, this
session
MUSTN'T get lost. In my JavaScript solution it worked very
fine.
But now my chef wants that there should be a chatapplet. And I don't
really
know how to maintain the session while the user chats. After 15
minutes he
or she will be logged out. Can I access to Cookies in an applet?
But there's
the next problem, if someone deactivates cookies it either won't
work. But
the whole community should be as browser-independent as
possible.
Either I'm already sitting on a solution or I should open the
window to get
some fresh air ;-)
Christian
> -----Original
Message-----
> From: A mailing list about Java Server Pages specification
and reference
> [mailto:[EMAIL PROTECTED]]On
Behalf Of Zvika Markfeld
> Sent: Monday, December 31, 2001 12:16
AM
> To: [EMAIL PROTECTED]
> Subject: Re: Session in
Applet??
>
>
> Hi Christian,
> If I get your drift, one
thing that you need to do sooner than later is
> separate between client
side Java code such as applets and server-side,
> which is your
JSP/Servlet. At any case, an Applet can't maintain a session
> if you
leave your site. Whenever a page which holds an applet unloads, the
>
applet gets unloaded too.
> Maintaining a session is done either by
setting a cookie, and then you can
> the cookie's expiration date as need
be, or by using URL-Rewriting, which
> maintains sessions only as long as
the client hasn't left your site. stick
> to cookies, therefore.
>
zm.
>
>
> -----Original Message-----
> From: A mailing
list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED]]On
Behalf Of Christian Kurze
> Sent: Sunday, December 30, 2001 10:32
PM
> To: [EMAIL PROTECTED]
> Subject: Session in
Applet??
>
>
> Hi all,
> I want to use an Applet for
communication between the browser and the
> web-server. In the applet
there should be a Thread that
> permanently tries to
> read from an
ObjectInputStream. A Servlet sends via sendObject()
> Objects to
>
all the client-applets.
> My problem: My session of the user might get
lost. The applet is startet
> from an JSP which uses a session. Several
attributes are bound to it. When
> the user visits another site of
my webapp the session still has to be
> valid. I don't know how tomcat3.2
handles this fact. Is it enough that the
> applet communicates with the
server that the session won't get
> lost? If not,
> how could I
implement it?
>
> thx in advance
>
>
Christian
>
>
==================================================================
>
=========
> To unsubscribe: mailto [EMAIL PROTECTED] with body:
"signoff
> JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED]
with body: "set JSP-INTEREST
> DIGEST".
> Some relevant FAQs on
JSP/Servlets can be found at:
>
> http://archives.java.sun.com/jsp-interest.html
>
http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.jsp
> http://www.jguru.com/faq/index.jsp
> http://www.jspinsider.com
>
>
==================================================================
>
=========
> To unsubscribe: mailto [EMAIL PROTECTED] with body:
"signoff
> JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED]
with body: "set
> JSP-INTEREST DIGEST".
> Some relevant FAQs on
JSP/Servlets can be found at:
>
> http://archives.java.sun.com/jsp-interest.html
>
http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.jsp
> http://www.jguru.com/faq/index.jsp
> http://www.jspinsider.com
===========================================================================
To
unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set
JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found
at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com
