tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: Servlet running twice at the same moment.
Date Wed, 02 Jan 2002 19:29:40 GMT

Glad someone brought this up.  Seems as though some of my jsp pages are
being executed twice.  It doesn't seem to send information to the browser
twice, but it is causing havoc on my logic.  I can see System.outs being
executed twice and any logic / methods are being executed twice.  In my
case it seems as though the jsp:forward is in some way causing the

If anyone else has run across this situation, I would definitely like to
know what is going on and how to resolve this issue.

I'm also using IE 5.x, tomcat 3.2.x and linux.  If code is needed, I'll
have to send tomorrow.

Thanks in advance............


                    Robin Lee                                                            
                    <tech_support        To:     Tomcat Users List <>
          >            cc:                                          
                                         Subject:     Re: Servlet running twice at the same
                    11:12 AM                                                             
                    respond to                                                           
                    Tomcat Users                                                         

Well, that depends on which code you would like to see?  The login code is
pretty basic...

Here's is my validateLoginServlet...
I am using a type4 jdbc driver (thinweb.tds driver).

import Common.dbfiles.*;

import java.util.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class ValidateLoginServlet extends HttpServlet
 public void service(HttpServletRequest req, HttpServletResponse res)
            throws IOException
  String errorCode = "";

   // get a connection
   Class c = Class.forName("com.thinweb.tds.Driver");
   Connection dbConn =
   // instantiate data objects
   DBCustomersSet customersSet = new DBCustomersSet(dbConn,"Customers");
   //DBCustomers customers = new DBCustomers();

   // Now set the where clause to get the member (using setFilter)
   customersSet.setFilter("LoginID='" +
        req.getParameter("LoginID") + "'");

   Vector customersQuery = customersSet.query();
   //Create a session.
   HttpSession session = req.getSession(true);
   //Now let's see if any records were returned.
   if (customersQuery != null && !customersQuery.isEmpty())

    //DBCustomers cust = (DBCustomers) custSet.record();
    DBCustomers theCustomer = (DBCustomers) customersSet.record();
    //DBCustomers theCustomer = (DBCustomers)customersQuery.elementAt(0);

    //Now we want to check the password.
    if (theCustomer.getPassword().equals(req.getParameter("Password")))
     errorCode = "0";
     System.out.println("UserID: " + theCustomer.getLoginID() +
       " has logged in.");
     //Wrong password, set the errorCode to 1.
     errorCode = "1";
    //Not found, set the errorCode to 2.
    errorCode = "2";
   //System.out.println("ValidateLoginServlet errorCode: " + errorCode);
  catch (SQLException sqle)
   System.out.println("Sql Exception: " + sqle);
  catch (ClassNotFoundException cnfe)
  catch (ArrayIndexOutOfBoundsException aioobe)

In this case, it shows "userid has logged in".  At times it will do it just
once, but other times it will do it twice... Did i add something in here
that shouldn't be?

----- Original Message -----
From: "Micael Padraig Og mac Grene" <>
To: "Tomcat Users List" <>
Sent: Wednesday, January 02, 2002 11:50 AM
Subject: Re: Servlet running twice at the same moment.

> At 12:00 PM 1/2/02 -0700, you wrote:
> >Hello,
> >
> >I don't know why this is happening, but... It seems like whenever I run
> >single servlet, there are times it will run twice.  As in, this...
> >...Robin
> Robin, there is no way to have any clue why this is happening without
> seeing the code. Micael
> --
> To unsubscribe:   <>
> For additional commands: <>
> Troubles with the list: <>

To unsubscribe:   <>
For additional commands: <>
Troubles with the list: <>

To unsubscribe:   <>
For additional commands: <>
Troubles with the list: <>

View raw message