hi all,

I'm to connect my .jsp to my database and i've wrote the bean for it. Now
i'll have to get a field via jsp so i use the get and set method.

<jsp:useBean id="mybeanc" scope="session" class="myc.newNameHandler"/>
<jsp:setProperty name="mybeanc" property="from" param="from" />

now i need to send the paramater "from" to a bean id tocheckdup which has
the function checkduplicate. so is it correct if i do this :

<jsp:useBean id="tocheckdup" scope="page" class="myc.checkduplicate" />
<% tocheckdup.checkduplicate() %>


but how do i really pass the parameter over ? And is there anyway i can
print out the result of the bean ?

I really appreciate any advice or recommendations to any online
resources as my concepts are still quite fuzzy.
Thanks. And this is how my bean tocheckdup goes:

package myf;

import java.sql.*;

public class checkduplicate {

    private static Connection con;
    private static Statement stmt;
    private static String createString, updateString;
    private static ResultSet rs;

    private String from;




   static String checkduplicate(String name){



      // CASE INSENSITIVE
      createString = "SELECT NAME FROM userprofile " + "WHERE NAME LIKE '"
+ name + "'";
           String result = "User does not exist in database";

            try {
              stmt = con.createStatement();
         rs = stmt.executeQuery(createString);
          while(rs.next()) {
                     String newname = rs.getString("NAME");

              // CASE SENSITIVE
                      if (newname.equals(name)){
                       result = "User exist in database";
                                               }

                      else {
                       result = "User does not exist in database";
                                }
                                      }//for while
                  }//for try

       catch(SQLException ex) {
              System.err.println("SQLException: checkduplicate" +
ex.getMessage());
                                    }
          return(result);
              }

}


brenda

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to