• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to track source of request coming to controller

 
Monalisa Saha
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Open the browser's debugger and inspect the Network tab. It should show the network activity and perhaps contain clues as to what is going on.

Suspect: this type of problem can often happen with poorly-coded form validation script code. Do you have any such script in your page?
 
Monalisa Saha
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 should either 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.
 
Monalisa Saha
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am submitting a form with hidden values on the body onload (of the page) through a javacript function.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are submitting the form in a load event handler before the user can enter any information?
 
Monalisa Saha
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
framesets? in 2014?

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.
 
Monalisa Saha
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ajax and CSS.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!