JSP and Servlet Advanced

JSP and Servlet Advanced


1. Download Mysql DB MYSQL
2. Download attached employee-form.zip
3. To run it in Eclipse: right-click employee-form → Run As → Run on Server → Tomcat v9.0. URLs will be:

http://localhost:8105/employee-form/ — index with all links
http://localhost:8105/employee-form/employeeregister.jsp— the form
4.

Forms and Session Management

Employee Registration using JSP form + Servlet + JDBC + MySQL, followed by
Servlet Session Management concepts.



Tools & Technologies (per PPT)


  • JSP 2.2+
  • STS / Eclipse Neon.3
  • JDK 1.8+
  • Apache Tomcat 8.5
  • JSTL 1.2.1
  • Servlet API 2.5
  • MySQL mysql-connector-java-8.0.13


Dependencies — WEB-INF/lib

jsp-api-2.3.1.jar
servlet-api-2.3.jar
mysql-connector-java-8.0.13.jar
jstl-1.2.jar


Development Steps


  1. File > New > Project… > Web > Dynamic Web Project
    name = jsp-servlet-jdbc-mysql-example, runtime = Tomcat 8.5
  2. Add the dependencies
  3. Project structure
  4. MySQL database setup
  5. Employee.java — JavaBean
  6. EmployeeDao.java — JDBC code
  7. EmployeeServlet.java — controller
  8. employeeregister.jsp — registration form
  9. employeedetails.jsp — success page
  10. Demo — deploy on Tomcat and submit the form


Database Steps


  1. Connect to mysql workbench database using Database >> Connect to database

    User name is root (by default) and password is "system"
  2. Create database and then the table with below command

    CREATE DATABASE employees;
    USE employees;
    CREATE TABLE employee(
    id int(3) NOT NULL AUTO_INCREMENT,
    first_name varchar(20) DEFAULT NULL,
    last_name varchar(20) DEFAULT NULL,
    username varchar(250) DEFAULT NULL,
    password varchar(20) DEFAULT NULL,
    address varchar(45) DEFAULT NULL,
    contact varchar(45) DEFAULT NULL,
    PRIMARY KEY (id)
    );
  3. 2. URL http://localhost:9090/employee-form/employeeregister.jsp
Code Snippets 1
Quiz

No quiz for this topic.

Discussion

Login to join the discussion.


No comments yet.