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
behavior.
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............
kb
Robin Lee
<tech_support To: Tomcat Users List
<[EMAIL PROTECTED]>
@uls.com> cc:
Subject: Re: Servlet running twice at the
same moment.
01/02/02
11:12 AM
Please
respond to
Tomcat Users
List
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.io.*;
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 = "";
try
{
// get a connection
Class c = Class.forName("com.thinweb.tds.Driver");
Connection dbConn =
DriverManager.getConnection("jdbc:twtds:sqlserver://[removed];user
=[removed]
;password=[removed];TDS=7.0");
// 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())
{
customersSet.firstRecord();
//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")))
{
session.setAttribute("theCustomer",theCustomer);
errorCode = "0";
System.out.println("UserID: " + theCustomer.getLoginID() +
" has logged in.");
customersSet.userLoggedIn();
}
else
{
//Wrong password, set the errorCode to 1.
errorCode = "1";
}
}
else
{
//Not found, set the errorCode to 2.
errorCode = "2";
}
session.setAttribute("errorCode",errorCode);
//System.out.println("ValidateLoginServlet errorCode: " + errorCode);
dbConn.close();
}
catch (SQLException sqle)
{
System.out.println("Sql Exception: " + sqle);
}
catch (ClassNotFoundException cnfe)
{
System.out.println(cnfe);
}
catch (ArrayIndexOutOfBoundsException aioobe)
{
System.out.println(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?
Thanks.
----- Original Message -----
From: "Micael Padraig Og mac Grene" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[EMAIL PROTECTED]>
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
a
> >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: <mailto:[EMAIL PROTECTED]>
> For additional commands: <mailto:[EMAIL PROTECTED]>
> Troubles with the list: <mailto:[EMAIL PROTECTED]>
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>