PDA

View Full Version : Flash front-end JSP issues


CheckersMcGavern
01-08-2008, 07:44 PM
Well, I'm not sure if it's Flash, or JSP... but considering I know less JSP than I do Actionscript, I assume that's the problem.

I'm pretty much creating a Flash log-in for my site. Upon pressing the submit button Flash sends the text field to JSP, then JSP takes the required info from the server and compares the 2. If they are the same, it prints &comparej=true&. if not, it's prints &comparej=false&. And I have an else statement that's meant to cover anything else that might get thrown at me.

I checked out the JSP and had it print the information it's getting from Flash.... and it's giving me a null value. I'm assuming this means that somehow I'm not able to get the information I want from Flash.

Alright, enough chatter, here's the code. First Flash: This is the code I have set up on the submit button.
on (release) {
regVars = new LoadVars();
regVars.unamef = uName.text;
regVars.upassf = userPassword.text;
regVars.sendAndLoad("login.jsp", regVars, "POST");
regVars.onLoad = Compare;

function Compare() {

if (regVars.comparej == "true"){
testtext.text = "It says true";
}else if (regVars.comparej == "false"){
testtext.text = "It says false";
}
else{
testtext.text = "Oh crap";}
}
}

And here is the JSP:
<%@ page contentType="text/html; charset=utf-8" language="java"

import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<%
String namef = "";
namef = request.getParameter("unamef");

String passf = "";
passf = request.getParameter("upassf");


//mysql strings for logging in with, specifying the business db root is the user,

mysql the password
String host="youcannothavemyinfohere";
String user="idontwanttogiveyouthis";
String pass="nothingtoseehere";
String db="blahblahblah";
String conn;

//specifically loads the connector j driver and logs into mysql
Class.forName("com.mysql.jdbc.Driver");
conn = "jdbc:mysql://" + host + "/" + db + "?user=" + user
+ "&password=" + pass;
Connection Conn = DriverManager.getConnection(conn);
Statement SQLStatement = Conn.createStatement();

String Query = "SELECT * FROM register WHERE id = '1';";
ResultSet SQLResult = SQLStatement.executeQuery(Query);
SQLResult.first();

String namej = SQLResult.getString("name");
//out.println("Your Username is: "+namej);
out.println("&namebackj="+namej+"&");

String passj = SQLResult.getString("pass");
//out.println("Your Username is: "+passj);
out.println("&passbackj="+passj+"&");

if(namef == namej){
out.println("&comparej=true&");
} else if(namef != namej){
out.println("&comparej=false&");
} else{
out.println("&comparej=null&");
}
out.println("<br/>");
out.println("|" + namef + "|<br/>|" + namej + "|");
%>

<body>
</body>
</html>


As far as I can tell, the only issue is that the info from Flash is showing Null. Oh, and don't worry about the cod for the password confirmation. Right now I just want name confirmation. I can copy the code for the name and alter it for the password.

Please, any help is appreciated. Thanks!