here is the working code...
Regards,
Ravindra Kakani
**************start ****************
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ValidateServet extends HttpServlet{
private String sURL;
private String username;
private String password ;
PrintWriter output;
Connection connection;
public void init() throws ServletException {
sURL ="jdbc:odbc:DBase";
username = "";
password = "";
}
public void doGet( HttpServletRequest req,
HttpServletResponse res )
throws ServletException, IOException
{
username = req.getParameter("username");
password = req.getParameter( "password" );
output = res.getWriter();
res.setContentType( "text/html" );
if (username.equals( "" ) ||
password.equals( "" )) {
output.println( "<H3> Please click the back " +
"button and fill in all " +
"fields.</H3>" );
output.close();
return;
}
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connection = DriverManager.getConnection
(sURL,username,password);
Statement statement = connection.createStatement();
String query = "SELECT username FROM Details WHERE
password = '" + password + "'";
Statement statement1 = connection.createStatement();
String query1 = "SELECT password FROM Details WHERE
username = ' " + username + "'";
ResultSet rs = statement.executeQuery(
query );
rs.next();
int usernameT = rs.getInt("username");
ResultSet rs1 = statement1.executeQuery(query1 );
rs1.next();
String passwordT = rs1.getString("Password");
int x = passwordT.compareTo(password);
int y = Integer.parseInt(username);
if(x == 0 && usernameT == y){
output.println( "<H1><Font color:Red>Welcome
to our Online Service!</FONT><BR></H1>");
output.println(getServletInfo());
}
if(x > 0 ){
output.println( "<H1><Font
color:Red>Incorrect Password!</FONT><BR></H1>");
output.println( "<BR><BR><H1><Font
color:Blue>Please click the, Back, button and try again! </FONT><BR></H1>");
}
if(usernameT != y){
output.println( "<H1><Font
color:Red>Incorrect Username Entered!</FONT><BR></H1>");
output.println( "<BR><BR><H1><Font
color:Blue>Please click the, Back, button and try again! </FONT><BR></H1>");
}
statement.close();
statement1.close();
}
catch ( SQLException sqlex ){ //catch any exceptin that may
occur as a result of try
sqlex.printStackTrace();
//output.append( sqlex.toString() );
}
catch (Exception E) {
output.println("Error " + E.toString());
}
output.close();//close output
}
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
**************end *****************
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html