That clarifies a lot :-) ! You are indeed dealing with two separate requests from client to server. As such the Request object won't be the same between the jsp and the servlet and is the reason your storage of an attribute in the request didn't work. Sessions are buit for just this reason.

There may be a problem with concurrent access to the session if the user get's click happy or has multiple browser windows open on the same session and you'll have to be able to handle that. In general I would avoid attributes in the session that might cause conflicts depending on where each browser is in the app. In your case two windows could be prompted for a different random question/answer on the same session. Such a issue might be mitigated with a one time random token stored both as a hidden form field and a session attribute. As each request comes in, compare the tokens and handle appropriately.

Additionally I believe there was a bugzilla issue describing a version (or versions) of tomcat that didn't use a thread-safe method of storing session attributes, so you might have to introduce synchronize blocks in your code to deal with that. You'll have to look at the bugzilla database for the issue, tomcat version(s) and it's resolution. I don't have that info off hand.

--David

Mohammed Zabin wrote:

Well, I will descript the problem exactly. the first page use a tag class to
render a random question from database, and their possible answers, the user
must choose the right answer and submit the form for processing.

I need the random question numbers, which are question ids to
*Results*servlet.
*Results* servlet is a servlet that must display the same questions that was
displayed in the Questions page to run a query against the database to
display the questions and the correct and wrong answers.

My Problem is that, I want to pass these numbers, Questions IDs, from the
first page, which i have made it as a tag class, to Results page, which was
made as servlet. I tried to use request.setAttribute("Ids", ids); but when
retrieve it in Results servlet, I got *null. *

That was my problem my buddy, by the way, when i used session, it worked
fine. and you stated that this will not work, but i think that storing these
ids in a session is a good choice, isn't it?

If you have any comments please post it.


On 7/26/07, Caldarale, Charles R <[EMAIL PROTECTED]> wrote:
From: Mohammed Zabin [mailto:[EMAIL PROTECTED]
Subject: Re: Bean and Servlet

What do you suggest to overcome this problem?
In the seven messages you've posted in this thread, you've never really
explained what this attribute is being used for; nor have you answered
the question of whether or not it's used only for the duration of a
single request or is applicable to everything a given user does with
this particular webapp.

Until you give us some idea of what your intent is (as opposed to code
snippets), I don't think anyone can really answer your questions.

If you do need to store attributes in a session, you will need at least
some synchronization logic to see if the attribute is already present,
since multiple requests can easily be using the Session object
concurrently.

- Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to