student registration example

Ads
 

student registration example

1.reg.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>login</title>
</head>
<body>

<script type="text/javascript">

function validateAndSubmit() 
{
    var name = document.f1.id.value;  //first textbox document.formname.elementname.value
    var name1=document.f1.pw.value;

    /*if(f1.login[0].checked==false || f1.login[1].checked==false)
    {
        alert("select the login type");
        return false;*/


     if(name ==""  ||name == null ) {
        alert("user id cannot be blank!!" );
        return false;
    }
    else if(name1=="" ||name1==null)
    {
        alert("enter the password" );
        return false;
    }



    document.f1.action ="Servlet";
    document.f1.submit();

    }
</script>

<form  name="f1" >
<form action="Servlet" method="get">

<center>


<font color="253556">USERNAME</font>
<input type="text" name="id"/>


<font color="253556">PASSWORD</font>
<input type="password" name="pw"/>


</center><br>
<center><b><input type="submit" value="Submit"  onclick="javascript:validateAndSubmit();"/></b></center>
<br>
<a href="register.jsp">REGISTER HERE</a>
 </form>     
</body>
</html>

2,register.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

    <head>
    <title>example</title>
    <script type="text/javascript">

function validateAndSubmit() 
{
    var name = document.f1.id.value;  //first textbox document.formname.elementname.value
    var name1=document.f1.pw.value;

    /*if(f1.login[0].checked==false || f1.login[1].checked==false)
    {
        alert("select the login type");
        return false;*/


     if(name ==""  ||name == null ) {
        alert("user id cannot be blank!!" );
        return false;
    }
    else if(name1=="" ||name1==null)
    {
        alert("enter the password" );
        return false;
    }



    document.f1.action ="Servlet";
    document.f1.submit();

    }
</script>


<form name="f1" onsubmit="return validateAndSubmit()" action="Regservlet" mehtod ="post">

<center>


<font color="253556">USERNAME</font>
<input type="text" name="id"/>


<font color="253556">PASSWORD</font>
<input type="password" name="pw"/>


</center><br>
<center><b><input type="submit" value="Regsiter"  /></b></center>
</form>
    </body>
</html>

3.Regservlet.java

package servlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class Regservlet
 */
public class Regservlet extends HttpServlet {
    private static final long serialVersionUID = 1L;


    /**
     * Default constructor. 
     */
    public Regservlet() {
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub


    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub

        try
        {
         UserBean user = new UserBean();
         user.setUserName(request.getParameter("id"));
         user.setPassword(request.getParameter("pw"));

         user=UserDAO.regist(user);
         if(user.isValid())
         {
             HttpSession session = request.getSession(true);
             session.setAttribute("currentuser", user);
             response.sendRedirect("welcome.jsp");
         }
         else
         {
             System.out.println("sorry not inserted");
             response.sendRedirect("Invalid.jsp");
         }
        }
        catch (Throwable theException)      
        {
            System.out.println(theException); 
        }

    }

}

4.userbean.java

package servlets;

public class UserBean {
private String UserName;
private String Password;
private boolean valid;




public boolean isValid() {
    return valid;
}
public void setValid(boolean valid) {
    this.valid = valid;
}
public String getUserName() {
    return UserName;
}
public void setUserName(String userName) {
    UserName = userName;
}
public String getPassword() {
    return Password;
}
public void setPassword(String password) {
    Password = password;
}
}

5.userDao.java

package servlets;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

public class UserDAO {
    static Connection con;
    static Statement stmt;


    public static UserBean regist(UserBean user) {
        // TODO Auto-generated method stub

        String username=user.getUserName();
        String pass=user.getPassword();
        String query="insert into register values('"+username+"','"+pass+"')";


        try {
            con = ConnectionManager.getConnection();
            stmt=con.createStatement();
            int rows = stmt.executeUpdate(query);
            if(rows!=0)
            {
                user.setValid(true);
            }
            else
                user.setValid(false);

        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return user;
    }
}

6.connectionmanager.java

package servlets;


    import java.sql.*;


       public class ConnectionManager {

          static Connection con;
          static String url;

          public static Connection getConnection()
          {

             try
             {

                Class.forName("oracle.jdbc.driver.OracleDriver");
                System.out.println(" Defing the URL");

                 String url= "jdbc:oracle:thin:@172.24.137.30:1521:ORA10G";
                // assuming "DataSource" is your DataSource name

               // Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

                try
                {   


                    System.out.println(" Defing the username");
                    String username= "e5"; 
                    System.out.println(" Defing the password");
                    String password= "";
                    System.out.println(" Defing the connection");
                    con = DriverManager.getConnection(url,username,password); 
                    System.out.println(" connection done" +con);





                }

                catch (SQLException ex)
                {
                   ex.printStackTrace();
                }
             }

             catch(ClassNotFoundException e)
             {
                System.out.println(e);
             }

          return con;
    }

}

Thanks

View Answers

January 17, 2012 at 7:18 PM

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>login</title>
</head>
<body>

<script type="text/javascript">

function validateAndSubmit() 
{
    var name = document.f1.id.value;  //first textbox document.formname.elementname.value
    var name1=document.f1.pw.value;

    /*if(f1.login[0].checked==false || f1.login[1].checked==false)
    {
        alert("select the login type");
        return false;*/


     if(name ==""  ||name == null ) {
        alert("user id cannot be blank!!" );
        return false;
    }
    else if(name1=="" ||name1==null)
    {
        alert("enter the password" );
        return false;
    }



    document.f1.action ="Servlet";
    document.f1.submit();

    }
</script>

<form  name="f1" >
<form action="Servlet" method="get">

<center>


<font color="253556">USERNAME</font>
<input type="text" name="id"/>


<font color="253556">PASSWORD</font>
<input type="password" name="pw"/>


</center><br>
<center><b><input type="submit" value="Submit"  onclick="javascript:validateAndSubmit();"/></b></center>
<br>
<a href="register.jsp">REGISTER HERE</a>
 </form>     
</body>
</html>

2.register.jsp


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

    <head>
    <title>example</title>
    <script type="text/javascript">

function validateAndSubmit() 
{
    var name = document.f1.id.value;  //first textbox document.formname.elementname.value
    var name1=document.f1.pw.value;

    /*if(f1.login[0].checked==false || f1.login[1].checked==false)
    {
        alert("select the login type");
        return false;*/


     if(name ==""  ||name == null ) {
        alert("user id cannot be blank!!" );
        return false;
    }
    else if(name1=="" ||name1==null)
    {
        alert("enter the password" );
        return false;
    }



    document.f1.action ="Servlet";
    document.f1.submit();

    }
</script>


<form name="f1" onsubmit="return validateAndSubmit()" action="Regservlet" mehtod ="post">

<center>


<font color="253556">USERNAME</font>
<input type="text" name="id"/>


<font color="253556">PASSWORD</font>
<input type="password" name="pw"/>


</center><br>
<center><b><input type="submit" value="Regsiter"  /></b></center>
</form>
    </body>
</html>

Ads









Related Tutorials/Questions & Answers:
student registration example
student registration example  1.reg.jsp <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>... visit the following links: http://www.roseindia.net/jsp/user-registration-form
html code for student registration form
html code for student registration form Here is an example of html code for student registration form. In this example, we have displayed many text fields... in student registration form. If you will not enter value in text field than an error
Advertisements
user registration example
user registration example  hello roseindia i'm searching for a user registration application/example using struts can you pls help me
Java GUI to build a Student Registration Program
Java GUI to build a Student Registration Program   Write a program... if the student is successfully registered for the course. Graduate students can... should graphically display a sorted list of registered courses for a student
How to Create Student Registration Form with HTML Code?
How to Create Student Registration Form with HTML Code? At present, the concept of online student registration form has emerged as a great relief... will learn to create a student registration form using html code in easy steps
Spring MVC User Registration example
Spring MVC User Registration example  hi, I am unable to find springMVCUserRegistration example full code can u send me full code of this example   Please visit the following link: Spring MVC USer Registration
Spring 2.5 MVC User Registration Example
Spring MVC User Registration example       Spring 2.5 MVC User Registration Example This tutorial shows you how to create user registration application in Spring MVC. This application
PLEASE Help me write a Java program which will store, manipulate, and print student registration information.
student registration information.  HERES TEH QUESTION - I AM MISSING SOME OF THE STUDENT CLASS - AND THE COURSES CLASS I NEED THE PART WHERE IT ENTERS... will store, manipulate, and print student registration information. As part
Request for complete code of the Spring 2.5 MVC User Registration Example
Request for complete code of the Spring 2.5 MVC User Registration Example  Hi, The Spring 2.5 MVC User Registration Example is very helpfull... the complete code of this example or rest of the part. Best Regards, Uttam kumar
student information system
student information system  can you show me example of "student information system" pseudo code and flow chart with "student name, student id, student residential hall, student course, student phone numbers
How to solve this java code by adding the student marks not in the list of the table. For example -10 and 156 in GUI?
How to solve this java code by adding the student marks not in the list of the table. For example -10 and 156 in GUI?  import java.awt.*; import...; a++) { String input=JOptionPane.showInputDialog(null,"Please insert student
Student database
Student database  Create a class Student with Name, Gender, and Date of Birth and Input Student and print as ?Dear Mr/Mrs Name, your Age is 99 Years?. Mr/Mrs - only one should be displayed based on their age and Gender
student details
student details  hi sir/madam i have a doubt in PHP how to insert student details using mysql with php..   Have a look at the following link: PHP Mysql insert
student details
student details  create an application for details of 1st to 5th standard students by using loops and scanner
student database
student database  student records such as fees-school fees, dob,age,if any due.the record stored should be like this record,name,age,dob,fee list or any dues of the student record1 isha 15 20jan record2 spandana 14 4feb record3
Student average
Student average  you are an academic scholar.one requirement... that reads student's number of subject taken, the final grade of each subject... should display the average grade of the student and would display the message
student
student
Student
Student Marks
Student Marks  Hi everyone I have to do this java assignment... programming grades of 8 IT students. Randomly create student numbers for each... in an array. Addresses of Students and store them in array. Previous Grade for student
Student Marks
Student Marks  Create a simple application which can calculate 5 marks entered by user and find the grade. Create a simple application which can calculate 5 marks entered by user and find the grade. You must display the grade
html code for student information?
html code for student information?  html code for student information
course registration
course registration  project for course registration system in java programming
student admission system project
student admission system project  College Student Admission System... Student Admission Project in Java with Source code, that includes Following Forms 1) Student Admission based,its urgent sir
school student attendence report
school student attendence report  Hi i want school student attendence genaration source code please urgent help me
student weekly attandence genaration
student weekly attandence genaration  Hievery body iam doing student project in that i want student weekly ,yearly attendence generation report this project doing on struts frame front as java back end as oracle 10 g
STUDENT MANAGEMENT SYSTEM
STUDENT MANAGEMENT SYSTEM  can any one help me with the coding if this using awt please!!!!!!! STUDENT MANAGEMENT SYSTEM Table details Student...:insert/update/delete/search student:insert/update/delete/search :result entry
project for Student Admission System
project for Student Admission System  I want Mini Java Project for Student Admission System. actually i want 2 know how 2 start this...please show me my way
Student Management System
Student Management System  Hi , Friend can i get the solution for connecting login page of JFrames to JDBC
How do I compile the registration form?
How do I compile the registration form?  How do I compile the registration form as stated at the bottom of the following page (URL is below). Do I need ANT? If so, please give instructions. I am a student. http
JDBC Connection and Registration
stored in database. How to validate user registration. Thanks in advance... student is our dsn. import java.sql.*; public class CreateTable { public static... = DriverManager.getConnection("jdbc:odbc:student"); Class.forName

Ads