Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet being Invoked Twice?

 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a pretty simple web application that I'm mocking up and I've run into something very peculiar.

The user comes to a certain page in which they can search the system for files. The page consists of two frames - the frame on the left contains controls for the user to enter their search criteria and a button to press to initiate the search. The frame on the right is empty, initially, but I'd like to populate it with the results of the search.

To this end, I've made my "control" (the frame on the left) page like this:



It's really pretty basic. The user can enter their search criteria and pressing the "Search" button causes the method submitForm() to be invoked. This method really only does two things. First, it pops up an alert to let me know it got there. Second, it changes the location of the other frame - redirecting it to a servlet so that it gets the result of the search.

I know that this method is only being invoked one time because I only get one pop-up box.

However, in the servlet that is called, I have a println statement so that I can be sure it got there - this statement executes two times.

Anyone have any idea why the doGet method is bring invoked twice when I set the location as I have above?

Thanks,
Corey
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, let me add a bit more to the story...

I added a little more functionality to the web app. When the user performs a search, I first check to see if the user is logged in to the application (to prevent people trying to bypass the login page or a session that has timed out). If the user isn't logged in, I redirect them to another page. If they are logged in, I go ahead and perform the search. The code looks roughly like this:



The odd thing here is that, if the user is not logged in and I redirect them to the "session timed out" page, the doGet() method only executed once, as I'd expect. If, however, the user is logged in and I go ahead and return a file, it actually execued the doGet() method a second time.

I'm confused.
 
dema rogatkin
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can only guess that something in your html code which does submission twice as regular and as a result of on click handler. You can verify that looking in access log your web server.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic