• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlet being Invoked Twice?

 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic