JSP - Clicking Links or Buttons Twice

R

Randhir Singh

Hello,

I developed a straight forward J2EE web application that allows users
to query a LDAP server. This app was built following a previous ASP
version. The problem that I'm having is that anytime I click a link
or button twice (before the link page loads up) the next page displays
all the data twice. Additionally, if I have two queries running on
the same machine in two different IE windows at the same time, the
data from the second query shows up on the other query's page in
addition to the data from the original query (hope that makes sense).
It seems as if the iPlanet web server cant distinguish that the two IE
windows are different sessions.

My major question is:
Why do JSP pages display data twice if a link or button is clicked
twice, and how can i prevent this?

Thanks,

Randhir
 
R

Ryan Stewart

Randhir Singh said:
Hello,

I developed a straight forward J2EE web application that allows users
to query a LDAP server. This app was built following a previous ASP
version. The problem that I'm having is that anytime I click a link
or button twice (before the link page loads up) the next page displays
all the data twice. Additionally, if I have two queries running on
the same machine in two different IE windows at the same time, the
data from the second query shows up on the other query's page in
addition to the data from the original query (hope that makes sense).
It seems as if the iPlanet web server cant distinguish that the two IE
windows are different sessions.

My major question is:
Why do JSP pages display data twice if a link or button is clicked
twice, and how can i prevent this?

In my experience, they don't. Beyond that I'm afraid I can't offer much
help. What are you doing with your JSPs? What are the links/buttons supposed
to do?
 
T

Tony Morris

I'm going to take a punt and suggest you have a concurrent access issue.
Your browser is issuing the request twice, and the server application (in
this case, the J2EE app.) is not handling the requested data exclusively as
it should.

First place to look: do you have member variables as part of your
servlet/JSP ? They must be protected from race conditions if you do.
Second place to look: A profiler/debugger

--
Tony Morris
(BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
Software Engineer
IBM Australia - Tivoli Security Software
(2003 VTR1000F)
 
R

Randhir Singh

These links are supposed to provide detail on a given entry.
Basically, they will link users to another jsp page that displays
formatted data (retrieved from the LDAP server). The data is
displayed in a table. If the link is clicked twice the data will be
displayed twice when it loads. However, if the user clicks refresh
(on the page with the duplicate data) the page will be displayed
correctly. Any help, insight, suggestions will be appreciated.
Thanks for your quick response.

Just a side note: If a user clicks refresh shortcut (<ctrl>+R) twice
before a page has refreshed, the data will be displayed twice.
 
D

Debian User

Tony Morris said:
First place to look: do you have member variables as part of your
servlet/JSP ? They must be protected from race conditions if you do.

This is AFAIK not a problem in JSP's, but it can be in servlets.
To solve it, your servlets must be thread-safe. This means that the
servlet and any singleton classes it uses may not use member variables to
retain a state. You have the session for that.


Oscar
 
C

Christophe Vanfleteren

Debian said:
This is AFAIK not a problem in JSP's, but it can be in servlets.

That is incorrect. JSP's get translated to servlets, and are then used in
the exact same way as servlets, so you need to be as cautious about thread
safeness if you have member variables.
 
T

Tony Morris

JSP == Servlet.

All ya gotta to do is create a data member and not protect it from race
conditions and you're in trouble,
regardless of whether your source is a JSP or a servlet; at the end of the
day, they are both servlets.

--
Tony Morris
(BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
Software Engineer
IBM Australia - Tivoli Security Software
(2003 VTR1000F)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,835
Latest member
KetoRushACVBuy

Latest Threads

Top