Java Beans Program


Index.jsp
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
     
        <form action="process.jsp">
           <input type="text" name="uname" value="name" onclick="this.value="/><br/>
            <input type="text" name="uemail" value="emailid" onclick="this.value="/><br/>
           <input type="password" name="upass" value="password" onclick="this.value="/><br/>
            <input type="Submit" value="register"/>
        </form>
         
           
       </body>
</html>


Process.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="bean.RegisterDao" %>
        <jsp:useBean id="obj" class="bean.User"/>
        <jsp:setProperty property="*" name="obj"/>
        <%int status=RegisterDao.register(obj);
        if(status>0)
            out.print(status);
        out.print("regsitered succefully");
        %>



RegisterDao.java
package bean;
import java.sql.*;
public class RegisterDao {
    public static int register(User u)
    {
        int status=0;
        try
        {
            Connection con=ConnectionProvider.getCon();
            PreparedStatement ps=con.prepareStatement("insert into emp values(?,?,?)");
            ps.setString(1,u.getUname());
            ps.setString(2,u.getUemail());
            ps.setString(3,u.getUpass());
            status=ps.executeUpdate();
            System.out.println("inserted");
        }
        catch(Exception i)
        {
            System.out.println(i);
            }
        return status; }}
       


ConnectionProvider.java
package bean;
import java.sql.*;
import  bean.Provider;
import static bean.Provider.Conn;
import static bean.Provider.Driver;
import static bean.Provider.Username;
import static bean.Provider.pass;
public class ConnectionProvider {
    private static Connection con=null;
    static
    {
        try
        {
            Class.forName(Driver);
            con=DriverManager.getConnection(Conn,Username,pass);
        }
        catch(Exception e)
        {
            System.out.print(e);
        }
       
    }
       public static Connection getCon()
        {
            return con;
        }    
   
}



Provider.java
package bean;
public interface Provider {
    String Driver="org.apache.derby.jdbc.ClientDriver";
    String Conn="jdbc:derby://localhost:1527/kbn";
            String Username="kbn";
            String pass="kbn";
}



User.java
package bean;
public class User {
    private String uname,upass,uemail;
    public String getUname()
    {
        return uname;
    }
    public void setUname(String uname)
    {
        this.uname=uname;
    }
    public String getUpass()
    {
        return upass;
    }
    public void setUpass(String upass)
    {
        this.upass=upass;
    }
     public String getUemail()
    {
        return uemail;
    }
    public void setUemail(String uemail)
    {
        this.uemail=uemail;
    }
    }
   

Comments

  1. Thanks for sharing this blog. The content is beneficial and useful. Very informative post.For More Information about Python Python Online Training

    ReplyDelete
  2. When Blockchain two-factor authentication get fails, it can create endless troubles and one of them is hacking attempts. Despite having tight security measures, hackers use their inventive ways to steal information and funds from Blockchain users account, thus, it is suggested that two-factor authentication should always be working to avoid such troubles. If you don’t know how to deal with it and need solutions, always contact the team via calling on Blockchain phone number which is functional all the time for help.

    ReplyDelete
  3. Thanks for the post. It was very interesting and meaningful. I really appreciate it! Keep updating stuff like this.
    We are giving all Programming Courses such as

    Register for a free Demo Sessions

    Online DevOps Training
    RPA Ui Path Online Training
    Best Python Online Training
    Online AWS Training
    Online Data Science Training

    ReplyDelete
  4. Thanks for sharing and it was useful and knowlegable blog.Keep posting. otherwise anyone wants to learn Advanced Java Course so contact here- +91-9311002620 or visit website- https://www.htsindia.com/Courses/java/advanced-java-training-institute-in-delhi

    ReplyDelete

Post a Comment

Popular posts from this blog

MACHINE LEARNING IN REAL WORLD

MACHINE LEARNING INTRODUCTION