Wrox Programmer Forums
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Flash (all versions) section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 6th, 2005, 11:39 AM
Registered User
 
Join Date: Dec 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to raghav_shenoy Send a message via Yahoo to raghav_shenoy
Default 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
 
Old January 6th, 2005, 11:59 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 249
Thanks: 0
Thanked 0 Times in 0 Posts
Default

On your line in your jsp file
mainMessage="userInfo=true"

I think it should have the "&" in front of the mainMessage
&mainMessage="userInfo=true"

I don't know jsp but in ASP I have to write my strings out as
&stringToLoad=<%=StringFromDatabase %>

hope this works
 
Old January 6th, 2005, 12:53 PM
Registered User
 
Join Date: Dec 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to raghav_shenoy Send a message via Yahoo to raghav_shenoy
Default

Thanks for the reply

Actually it is printing on the screen as

&mainmessage=userInfo=false
 
Old January 6th, 2005, 01:02 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 249
Thanks: 0
Thanked 0 Times in 0 Posts
Default

my mistake, you are after the userInfo. your string should read
&userInfo=true

Mike
 
Old January 6th, 2005, 02:46 PM
Registered User
 
Join Date: Dec 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to raghav_shenoy Send a message via Yahoo to raghav_shenoy
Default

Yes i have tried the same but no result :((
 
Old January 6th, 2005, 04:14 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 249
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I noticed you do not have anything telling flash where to get the variables from. I would comment out your information and use this below. If you get a True or False, your code is working. If you get an undefined then it is defintely in the jsp file, and you might try posting that code in another forum on here. Another thing I just noticed how are you writing the information to the jsp page, does jsp have a document.write or something similar you need to have the &userInfo=true string write to the page for flash to grab.

document.write "&userInfo=true"

var login_lv:LoadVars = new LoadVars();
login_lv.load("YourJSPFileName");
this.createTextField("blnLogin_txt", 500, 150, 80, 200, 40);
login_lv.onLoad = function() {
blnLogin_txt=login_lv.userInfo
}





Similar Threads
Thread Thread Starter Forum Replies Last Post
View HTML page in flash haaglin Flash (all versions) 1 January 4th, 2007 01:11 AM
Login page back to original page pablohoney Classic ASP Basics 1 October 3rd, 2006 07:09 PM
Page flash from using master page wirerider ASP.NET 2.0 Basics 7 March 8th, 2006 05:50 PM
Newbie Help. Login to unique login page per user Kainan Classic ASP Professional 10 May 3rd, 2005 07:47 AM
page have a flash file alyeng2000 HTML Code Clinic 2 April 19th, 2005 08:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.