Results 1 to 2 of 2
  1. #1
    butterhero is offline Member
    Join Date
    Jan 2009
    Posts
    1
    Rep Power
    0

    Default Need advice on JSP with bean

    i am currently doing a project that requires me to do a registration page and a log in page.. but i am required to put database bean on the registration jsp which updates the database...

    i have done most of it... but i am not too sure how to continue...

    Java Code:
    <%@ page import = "java.sql.*" %>
    <%@ page import = "java.util.*" %>
    <%@ jsp:useBean id="registered" scope="session"  class="myjsp.registeredBean" />
    
    <html><head><title>Books-For-U(B4U)</title></head>
    <body>
    <%
    
    
    
    
         dBean.connectDB("db1","","");<--------the bean (i am stuck here)
         
         
    
    
    
    
    	String lID=request.getParameter("loginID");
    	String pwd=request.getParameter("password1");
    	String fname=request.getParameter("firstname");
    	String lname=request.getParameter("lastname");
    	String email=request.getParameter("emailadd");
    	String home=request.getParameter("homeadd");
    
    	try
    	{
    		status = statement.executeUpdate("INSERT INTO LogIn(logID, password, Firstname, LastName, Email, HomeAddress) VALUES ('"+lID+"', '"+pwd+"', '"+fname+"', '"+lname+"', '"+email+"', '"+home+"')");
    	}
    
    	catch(SQLException sqle)
    	{
    		//handle exception here
    	}
    
    	
    	if(status > 0)
    	{
    		out.println("<h2>@__@ Account Creation Successful @__@</h2>");
    
    %>
    		<font size = "2" face = "Georgia" color = "pink">Snap <a href = "SignIn.html"> here</a> to login.</font><br>
    
    <%
    
    	}
    
    	else
    	{
    		out.println("<h2> xxxxxxERROR!! Please Re-register!xxxxxx</h2>");
    %>
    		<font size = "2" face = "Georgia" color = "pink">Snap <a href = "registration.html"> here</a> to login.</font><br>
    
    
    <%
    
    	}
    
    	statement.close();
    	connection.close();
    
    %>
    </body>
    </html>

  2. #2
    Tirka is offline Member
    Join Date
    Feb 2009
    Posts
    12
    Rep Power
    0

    Default

    use the bean id "registered" in place of dbean
    if connectDB("db1","","") is any method of registeredBean.class
    then it will be:

    registered.connectDB("db1","","");
    instead of:
    dBean.connectDB("db1","","");

    hope that helps.

Similar Threads

  1. Advice needed
    By dineshjf in forum Advanced Java
    Replies: 18
    Last Post: 01-09-2009, 04:17 AM
  2. UREGENT-accessing session bean ok but entity bean
    By parimal in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 08-28-2008, 02:34 PM
  3. Advice on best method for....
    By shaungoater in forum Java 2D
    Replies: 1
    Last Post: 06-23-2008, 08:36 PM
  4. Replies: 0
    Last Post: 03-30-2008, 11:03 AM
  5. Replies: 0
    Last Post: 09-26-2007, 09:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •