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]>