Login page in flash
Hello friends,
Iam trying to connect to database through flash and middleware as jsp to Access.
I have succesfully finished doing the connection through asp. But Iam not able to do the same with jsp page. Iam pasting my code of the flash and the jsp page here
Flash code
//////////////////////////////////////////////////////
login_lv = new LoadVars();
login_lv.onLoad = function() {
if (this.userInfo == "true") {
getURL("http://www.macromedia.com");
} else {
getURL("http://www.yahoo.com");
login_txt.text = "";
password_txt.text = "";
}
};
onLogin = function () {
if (login_txt.text.length<1) {
trace("please provide a login name");
} else if (password_txt.text.length<5) {
trace("invalid password");
password_txt.text = "";
} else {
login_lv.username = login_txt.text;
login_lv.password = password_txt.text;
login_lv.sendAndLoad("login.jsp", login_lv, "POST");
}
};
stop();
//////////////////////////////////////////
jsp code here
///////////////////////////////////////////
<%@ page import="java.util.*, java.lang.*, java.sql.*" %>
<% %>
<%
String name,pwd;
boolean found=false;
String mainMessage=null;
//get the user name and password from flash
String username=request.getParameter("username");
String password=request.getParameter("password");
//Establish connection
//Class.forName("oracle.jdbc.driver.OracleDriver");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
PreparedStatement ps;
//Connection dbconn = DriverManager.getConnection("jdbc:oracle:thin:@192 .168.7.45:1521:cod", "ibm", "ibm");
Connection dbconn = DriverManager.getConnection("jdbc:odbc:login", "", "");
//get the user name and password from the database
Statement s = dbconn.createStatement();
ResultSet rs = s.executeQuery("select * from loginTable");
//SELECT login.username,login.password FROM login WHERE login.username = '" + username + "' and login.password = '" + password + "'
//if values exist print them on console
while (rs.next()) {
name=rs.getString(1);
pwd=rs.getString(2);
if(name.equals(username) && pwd.equals(password)) {
mainMessage="userInfo=true";
found=true;
}else{
mainMessage="userInfo=false";
}
//end of if
}//end of while
//if values don't exist output error message
if (found==false)
{
mainMessage="userInfo=false";
}//end of if
out.println("&"+mainMessage+"&");
//Close connection objects
rs.close();
s.close();
dbconn.close();
%>
////////////////////////////////////////////
thanks in advance
please help me out
eagerly waiting for the reply
|