student registration example

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>


January 18, 2012 at 12:08 PM









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
Develop user registration form
;  In this example we are going to work with a user registration... user registration jsp page.  In this example we will create a simple..."> <description> User Registration and Login Example. <
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 info
student info  code of insert,delete,update,view,search of student information using jsp and servelts   Hi Friend, Please visit the following links:ADS_TO_REPLACE_1 http://www.roseindia.net/jsp/user-search.shtml http
Student
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
course registration
course registration  project for course registration system in java programming
html code for student information?
html code for student information?  html code for student information
registration application
registration application  How to develop a registration application in struts which has seperate file for database connection and data checking and form and action
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
Registration Form
Registration Form  Hi Friends I am Working on a small project.I have to create a Registration page using MVC pattern where i have to insert data username,password,date of birth,Mobile number number into database. How to insert
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
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
Registration - Ajax
Registration  i want to create a registration page. in which User... me on this topic. How i can connect this registration page to data base. i am...;hi friend, registration form in jsp function checkEmail(email
REGISTRATION OF MBEAN
REGISTRATION OF MBEAN  my question is... i have installed jboss, and created a managed Bean(MBEAN)and provided interface and everything. but i dont know whether the service registerd in jmx or not. please suggest me
user registration
user registration  hi frnds...am working on a project in JSP.i want to create a user registration form with username,password,mail id and check box option for community selection.once the details are registered i want to save
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
college student admission
college student admission  Front End -JAVA Back End - MS Access Hello Sir, I want College Student Admission Project in Java with Source code, that includes Following Forms 1) Student Admission based on Enterance Exam Marks
to creating a registration form
to creating a registration form  how to create a registration form
student attendence report
student attendence report  Hi every body iam doing a school project iam using backend as oracle 10g front end as java . in my project generate student attendence daywise ,monthly ,halfyearly and yearly how i generate plz
HTML Code for registration form
HTML Code for registration form Here is an example of Registration form using.... The name in front of Text Field is called "Label". At the end of the registration... registration forms, which is used by the websites for enabling the users
data science student jobs
data science student jobs  Hi, I am beginner in Data Science... student jobs Try to provide me good examples or tutorials links so that I can learn the topic "data science student jobs". Also tell me which
Student - Java Beginners
Student  Create a class named Student which has data fields of student metric number, mark for the quizzes (15% from the total mark), lab assignments..., Try the following code: import java.util.*; public class Student{ int
creating an applet for student management system
creating an applet for student management system  Write an applet/awt... a student management system having the following characteristics: The interface... it to act), and reasonably realistic. It must accept the student id,name,age,address
registration form
registration form  Hii.. I have to design one registration page in java that looks like REGISTER USERNAME (here i have to check whether username already exists in database) EMAIL ADDRESS (here i have to check whether
ModuleNotFoundError: No module named 'registration'
ModuleNotFoundError: No module named 'registration'  Hi, My Python... 'registration' How to remove the ModuleNotFoundError: No module named 'registration' error? Thanks   Hi, In your python
Registration Form in HTML
Registration Form in HTML  User Registration Form in HTML - i wanted to design a user registration form in HTML. So, Can anyone please guide me or give me a peace of code to design a user registration form in HTML. Thanks
ModuleNotFoundError: No module named 'student-bsu-by'
ModuleNotFoundError: No module named 'student-bsu-by'  Hi, My... named 'student-bsu-by' How to remove the ModuleNotFoundError: No module named 'student-bsu-by' error? Thanks   Hi, In your python

Ads