Reputation: 12770
I'm working on a project in Java using the spring framework, hibernate and tomcat.
Background: I have a form page which takes data, validates, processes it and ultimately persists the data using hibernate. In processing the data I do some special command (model) manipulation prior to persisting using hibernate.
Problem: For some reason my onSubmit method is being called twice, the first time through things are processed properly. However the second time through they are not; and the incorrect information is being persisted.
I've also noticed that on other pages which are simply pulling information from the data base and displaying on screen; Double requests are happening there too.
Is there something misconfigured, am I not using spring properly..any help on this would be great!
Additional Information:
The app is still being developed. In testing the app I'm running into this problem. I'm using the app as I would expect it to be used (single clicks,valid data,etc...)
Upvotes: 6
Views: 2731
Reputation: 847
This is a very common problem faced by someone who is starting off. And not very sure about the application eco-system. To deploy a spring app, we build the war file. Then we put it inside 'webapps' folder of tomcat. Then we run the tomcat instance using terminal (I am presuming a linux system). Now, we set up env in that terminal.
The problem arises when we set up our environment for the spring application where there can be more than one war files to be deployed. Then we must cater to the fact that the env must be exclusive to a specific war file.
To achieve this, what we can do is create exclusive env files for every war. (e.g. war_1.sh,war_2.sh,.....,war_n.sh) and so on.
Now we can source that particular env file for which we have to deploy its corresponding war. This way we can segregate the multiple wars (applications) and their environment.
Upvotes: 0
Reputation: 18690
If you are testing in IE, make note that in some versions of IE it sometimes submits two requests. What browsers are you testing the app in?
There is the javascript issue, if an on click handler is associated with submit button and calls submit() and does not return false to cancel the event bubble.
Upvotes: 1
Reputation: 139921
Could be as simple as users clicking on a link twice, re-submitting a form while the server is still processing the first request, or hitting refresh on a POST-ed page.
Are you doing anything on the server side to account for duplicate requests such as these from your users?
Upvotes: 0