Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet student registration example
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


mahender
student registration example
2 Answer(s)      2 years and 9 months ago
Posted in : JSP-Servlet


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


Advertisement
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>



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
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
user registration example
user registration example  hello roseindia i'm searching for a user registration application/example using struts can you pls help me
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
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
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
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
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 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
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...; User Registration and Login Example. </description> <display
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
course registration
course registration  project for course registration system in java programming
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 info
student info  code of insert,delete,update,view,search of student information using jsp and servelts   Hi Friend, Please visit the following links: http://www.roseindia.net/jsp/user-search.shtml http
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 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
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
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
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
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 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
to creating a registration form
to creating a registration form  how to create a registration form
Advertisements
 

 

 

DMCA.com