473,323 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

A weird problem about AJAX+JSP

Do what I say below. You will see the problem.

1.Write a HTML page. There's a button on it. When you click it, send a
request(whatever is ok, for example, "value=1") to a JSP page.
2.Write a JSP page to recieve the request. On the JSP page you should
set a session variable to count how many requests you recieved. Then
show the variable's value on the HTML page by alert.
3.Click the button. Then watch the value returned. You will see the
value is a constant.
4.If you write some output to console in the JSP, you will see the JSP
is only be excuted one time - the first time you click the button.

I tried it on Tomcat5.5 and JBoss4.

I use "get" method to transport the parameters. Does it matter?
Why? and How to solve it?

May 9 '06 #1
5 1130

"sleepinglord" <sh*************@gmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
Do what I say below. You will see the problem.

1.Write a HTML page. There's a button on it. When you click it, send a
request(whatever is ok, for example, "value=1") to a JSP page.
2.Write a JSP page to recieve the request. On the JSP page you should
set a session variable to count how many requests you recieved. Then
show the variable's value on the HTML page by alert.
3.Click the button. Then watch the value returned. You will see the
value is a constant.
4.If you write some output to console in the JSP, you will see the JSP
is only be excuted one time - the first time you click the button.

I tried it on Tomcat5.5 and JBoss4.

I use "get" method to transport the parameters. Does it matter?
Why? and How to solve it?

If I recall, the session object uses cookies. Are they disabled?
May 9 '06 #2
I didn't catch what you mean?
If I wanna realize such a count variable in the JSP, how to?

May 9 '06 #3

"sleepinglord" <sh*************@gmail.com> wrote in message
news:11*********************@v46g2000cwv.googlegro ups.com...
I didn't catch what you mean?
If I wanna realize such a count variable in the JSP, how to?


here's a link that may help
http://forum.java.sun.com/thread.jsp...sageID=2107079

May 10 '06 #4
sleepinglord wrote:
I use "get" method to transport the parameters. Does it matter?


It might. Your GET request is probably being cached, so it doesn't even hit
the server each time.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
May 10 '06 #5
sleepinglord wrote:
Do what I say below. You will see the problem.

1.Write a HTML page. There's a button on it. When you click it, send a
request(whatever is ok, for example, "value=1") to a JSP page.
2.Write a JSP page to recieve the request. On the JSP page you should
set a session variable to count how many requests you recieved. Then
show the variable's value on the HTML page by alert.
3.Click the button. Then watch the value returned. You will see the
value is a constant.
4.If you write some output to console in the JSP, you will see the JSP
is only be excuted one time - the first time you click the button.

I tried it on Tomcat5.5 and JBoss4.

I use "get" method to transport the parameters. Does it matter?
Why? and How to solve it?


Your request is cached somewhere.
Try this instead from js:

var url="yourpage.jsp?sid=" + Math.random() + "&value=1";

Should help. :-)

Regards,
Erwin Moller

PS: I hate caching.
May 10 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: nos | last post by:
I want to start learning about jsp, but I have no access to a server (got laid off). I just discovered my laptop has ability to install IIS (win xp pro). How can I set up jsp to work with IIS. I...
1
by: Babak | last post by:
Most likely a dumb question, but I am week in this area. I have a table which is generated dynamically in my jsp as I do a jdbc query. I have created an anchor...
5
by: questionit | last post by:
Hi My question is actually specifically about JSP. I am looking for a wesite where i can put my JSP code and able to run it online. I mean if i have no Tomcat or any server installed in my PC,...
3
by: anilbaraiya | last post by:
I found the problem the status error 500. when I am trying to get more then one data from the server to client.. I am using the following part of code to use xmlrequest & xmlresponse in jsp from...
2
kaleeswaran
by: kaleeswaran | last post by:
i creating registration form using jsp and i am usnig sun drivers.... i already posted my code into this forum but i could't get the proper result ... so please anyone send me the website address...
1
nmm32
by: nmm32 | last post by:
I am trying to use Ajax with JSP to populate a 2nd drop down list based on the chosen option of the first one. I am getting the error "Object Expected" on the line 13-14 of the HTML: <script...
15
by: josh | last post by:
Hi, I'm a jsp programmer and I have changed work. My boss does not matter about my previous Java experience and so he told me to learn web programming using c#. I have also many Javascript/DOM...
4
by: farad | last post by:
Hi there need your advise please help! I have been working an application of java based technologies. In some jsp files I'm using ajax action under onmouseover event. There are three files a,b,c....
35
by: sukatoa | last post by:
I have a subject that covers JSP(new to me), accessing database through JSP(new to me), applets, UML(also new to me) So, as im learning java, all i did to learn faster is i've created some...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.