• Post Reply Bookmark Topic Watch Topic
  • New Topic

Maintaining session between JSPs

 
Dimitris Zavaliadis
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone

I have a JSP page which loops through an array
of beans in order to generate dynamically a SMIL
script which in turn calls another JSP page which
generates plain text instead of HTML.
In case you haven�t used SMIL before, that�s not a
problem. It�s just an XML-based language for
synchronising and coordinating various media
components such as videos, pictures, audio, text etc.
In my case, I have to synchronise a video with a
sequence of text streams, that is to display some
sentences while the video is playing.
Anyway, that�s not the point.

Let�s say my first JSP page is called "first.smil".
It has a .smil extension since the SMIL player doesn�t
recognise a .jsp extension, and my server (Tomcat 4.0.6)
has been configured so that it treats .smil files as if
they were normal JSP. The code in "first.smil" looks
like this:


The above code works just fine. The problem is that
the "src" attribute of the <text/> tag is not
a hyperlink which is clicked by the user.
It�s just a reference that uses the output generated
by "text1.txt". And I said generated, because "text1.txt"
as with "first.smil" is actually a JSP file which
generates plain text, but since the SMIL player
doesn�t recognize a .jsp extension I have configured
my server so that it treats files with .txt extension
as JSP files, such as the .smil files.
This "text1.txt" file has to use the same array
of beans (stored as a session object) used in "first.smil",
in order to take a bean�s property and display the text
that is required.
However, it seems that if I use

in "text1.txt" it returns null.
I checked the sessionId in both "first.smil" and "text1.txt"
and they appear to be diferrent. Is this normal?
Is it necessary to use a hyperlink, or to forward
the request in order for "text1.txt" to use the same session with "first.smil"?

Since none of them is suitable for my case
(because of SMIL conventions), is there an alternative way
to maintain the same session for "text1.txt" ?

Many thanks in advance
Dimitris

[ July 28, 2004: Message edited by: Dimitris Zavaliadis ]
[ July 28, 2004: Message edited by: Dimitris Zavaliadis ]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I checked the sessionId in both "first.smil" and "text1.txt"
and they appear to be diferrent. Is this normal?

Apparently the servlet engine does not consider all of your files to be part of the same "web application" - therefore you get different sessions.
How is this application defined in your web.xml?
Bill
 
Dimitris Zavaliadis
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by William Brogden:

How is this application defined in your web.xml?

I'm not sure what exactly do you mean with "defined", but I'll try to describe it to you:

I'm working with Netbeans IDE 3.5.1.
In case you haven't used Netbeans before, it has an internal server which is Tomcat 4.0.6. When you start a new web application Netbeans automatically creates a web module with a suitable directory structure. Then it sets in the internal server's "server.xml" config file a default context. For example, the default context for the project I'm working on is:

The "WORKING_WEB_MODULE" is the name of my root directory.
Then in the application's web.xml (deployment descriptor) it sets just <servlet> and <servlet-mapping> tags whenever you create a new servlet, as well as
<session-config> tags. These are the default tags in web.xml.
Apart from these, I added some other <servlet-mapping> tags such as

Does this make any sense to you?
I really appreciate your help
Dimitris
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I have not used Netbeans, so I may be missing something essential, but I can't see why you are getting different session Ids. If this was my problem, I would look at the Java servlet source code files that the JSP compiler produces as an intermediate product for every statement in which the session is mentioned.
Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!