File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Servlet called more than once Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet called more than once" Watch "Servlet called more than once" New topic

Servlet called more than once

Srividya Shiv
Ranch Hand

Joined: Jul 20, 2000
Posts: 31
I have this strange problem. I noticed this in my application :
When I submit my form, the servlet is being called many times(I checked this thru my logs). After 3 or 4 times, my session is killed and I am logged off the application. This doesnt happen always but sometimes. When I looked at some FAQs for a solution, there was a suggestion that I should not have a 'form action' and also a 'javascript submit' in the same JSP. I removed the cation attribute from form tag , but my problem hasnt been solved. Can anybody give me some idea as to why this happens and what i can do to solve it?
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

where is the javascript (i mean on what event)? If it's possible, post some of your code (the HTML that contains your form and javascript)
Srividya Shiv
Ranch Hand

Joined: Jul 20, 2000
Posts: 31
My page looks like this(Its too lengthy,so I edited it):
function submitButton(sValuex) {
doSubmit(sValuex, 'home');
function doSubmit(valuex, formName) {
evaluate('var Form= document.'+formName);
evaluate('Form.mode.value = valuex');

<form name="home" method ="POST">
------some code---------
<a href="javascript:submitButton(1000)"><img src="/jsp/images/btn_users.gif" border="0"></a>

<input type="hidden" name="mode" value="0">
Srividya Shiv
Ranch Hand

Joined: Jul 20, 2000
Posts: 31
I had to use evaluate insted of eval, because otherwise I cannot post it.
I agree. Here's the link:
subject: Servlet called more than once
It's not a secret anymore!