I have a controller that on the basis of commands (formaction and subaction) dispatch requests to different jsp pages.
But somehow when I am debugging my application, I can find duplicate request coming to the controller, so one jsp page does load twice.
I am not sure from where the duplicate request is generating. Can anyone please help me regarding this.
Yes, I have many ajax functions, but I am using Direct web Remoting(dwr.jar) for that, so I am not suspecting these function (because they should be using DWR Servlet for the requests). Other than that I have only one function that does some validation and is called onSubmit of the form (onSubmit= return function()). When the page loads, I tried debugging, and I could see two requests with the same action and subaction. Is there no way that when the request is in the controller, I can find out from where it could have generated?
It sounds likely that your script is firing one form submission and that the browser is going ahead and also submitting it. Do you submit the form through Ajax? Call the submit function on the form from script? Do you stop propagation of the submit event in the submit handler?
You shouldeither submit the form yourself through script (either Ajax or "normal) or allow the submit event to propagate and let the browser do the submitting; but never both.
The form that the user has to give input, and the form that is submitting are different, the submitted form just has hidden values.
let me explain the whole flow. I have frameset that has 3 frames. A frametop (src set as a static jsp page).
A frameright (src set as a Wait.jsp which simply shows a waiting symbol on the page).
A frameleft(src as /controller?formaction="somecommand"&subaction="params") that is supposed to provide the user a
page with various kinds of select and input fields.
The controller when finds subaction=params dispatches request to params.jsp,this page body onload submits a form with target
as frameright and all default values of the param form(along with hidden value of subaction=getreport)
The controller when finds subaction=getreport dispatches request to report.jsp,
hence when the frameset loads, the right frame should show wait until the left frame has loaded and submitted default values to generate the report page.
But in the controller, I am able to get two requests to the param page.
Does the logic sound right or is there any obvious flaw?
I'd really approach the layout and page with a more modern approach. frames just complicate everything; there are good reasons that they are no longer favored.
I'd use the browser's debugger to find out where and how the two requests are being made to find out where they are coming from. But really; refactor without frames. In the age of Ajax and CSS, they are dinosaurs. Very early dinosaurs.
Yes, I understand framesets are obsolete now. The application was built some 10 years ago, and I am adding some pages to it, hence I cant go and change the whole architecture of the application now. So, I dont have any other option than this.
Sure, will try with the browser's degugger.
What could have been used instead of framests if the application was to built now.
(so that from a single page could be sending different requests and load differently as in frames)