Doctor Table Data Entry
Doctor Table Data Entry
Doctor Table Data Entry
xml:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.hrs.dataentry</groupId>
<artifactId>Hospital_Reception_System_Data_Entry</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.2.20.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jasper</artifactId>
<version>9.0.12</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2
</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.3.1</version>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.0.32</version>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.13.Final</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
</plugin>
</plugins>
</build>
</project>
Doctor_Details.java
package com.CRUD.beans;
Doctor_Details_Dao.java
package com.CRUD.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import com.CRUD.beans.Doctor_Details;
Doctor_Details_Controller.java
package com.CRUD.controllers;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.CRUD.beans.Doctor_Details;
import com.CRUD.dao.Doctor_Details_Dao;
@Controller
public class Doctor_Details_Controller {
@Autowired
Doctor_Details_Dao dao;
@RequestMapping("/adddoctordetailsform")
public String showform(Model m) {
m.addAttribute("command", new Doctor_Details());
return "adddoctordetailsform";
}
@RequestMapping(value="/save",method=RequestMethod.POST)
public String save(@ModelAttribute("doctor_details") Doctor_Details
doctor_Details) {
dao.save(doctor_Details);
return "redirect:/viewdoctordetailsform";
}
@RequestMapping("/viewdoctordetailsform")
public String viewdoctordetailsform(Model m) {
List<Doctor_Details> list=dao.getEmployees();
m.addAttribute("list", list);
return "viewdoctordetailsform";
}
@RequestMapping(value="/editdoctordetails/{doctor_Id}")
public String edit(@PathVariable int doctor_Id, Model m) {
Doctor_Details doctor_Details=dao.getDoctor_DetailsById(doctor_Id);
m.addAttribute("command", doctor_Details);
return "editdoctordetailsform";
}
@RequestMapping(value="/editsave",method=RequestMethod.POST)
public String editSave(@ModelAttribute("doctor_details")Doctor_Details
doctor_Details) {
dao.update(doctor_Details);
return "redirect:/viewdoctordetailsform";
}
@RequestMapping(value="deletedoctordetails/{doctor_Id}",method=RequestMethod.GET)
public String delete(@PathVariable int doctor_Id) {
dao.delete(doctor_Id);
return "redirect:/viewdoctordetailsform";
}
}
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>SpringMVC</display-name>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
spring-servlet.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="com.CRUD.controllers"/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
<bean id="ds" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.cj.jdbc.Driver"/>
<property name="url"
value="jdbc:mysql://localhost:3306/hospital_reception_system"/>
<property name="username" value="root"/>
<property name="password" value="as12@#as"/>
</bean>
<bean id="jt" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="ds"/>
</bean>
<bean id="dao" class="com.CRUD.dao.Doctor_Details_Dao">
<property name="template" ref="jt"/>
</bean>
</beans>
index.jsp:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>AAA Hospital Reception System</title>
</head>
<body bgcolor="miranda">
<h2>Welcome to Our Hospital's Portal</h2>
<a href="adddoctordetailsform">Add Doctor Details</a>
<a href="viewdoctordetailsform">View Doctor Employees</a>
</body>
</html>
editdoctordetailsform:
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<h1>Edit Doctor_Details</h1>
<form:form method="POST" action="/Hospital_Reception_System_Data_Entry/editsave">
<table>
<tr>
<td></td>
<td><form:hidden path="Doctor_Id"/></td>
</tr>
<tr>
<td>Age: </td>
<td><form:input path="Age"/></td>
</tr>
<tr>
<td>Gender: </td>
<td><form:input path="Gender"/></td>
</tr>
<tr>
<td>Specialization: </td>
<td><form:input path="Specialization"/></td>
</tr>
<tr>
<td>Experience: </td>
<td><form:input path="Experience"/></td>
</tr>
<tr>
<td>Language: </td>
<td><form:input path="Language"/></td>
</tr>
<tr>
<td>Mobile_No: </td>
<td><form:input path="Mobile_No"/></td>
</tr>
<tr>
<td>Email_ID: </td>
<td><form:input path="Email_ID"/></td>
</tr>
<tr>
<td>Schedule: </td>
<td><form:input path="Schedule"/></td>
</tr>
</table>
</form:form>
adddoctordetailsform:
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
viewdoctordetailsform:
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<h1>Employees List</h1>
<table border="2" width="70%" cellpadding="2">
<tr><th>Doctor_Id</th><th>Age</th><th>Gender</th><th>Experience</th><th>Language</
th><th>Mobile_No</th><th>Email_ID</th><th>Schedule</th><th>Edit</th></tr>
<c:forEach var="doctor_details" items="${list}">
<tr>
<td>${doctor_details.doctor_Id}</td>
<td>${doctor_details.age}</td>
<td>${doctor_details.gender}</td>
<td>${doctor_details.specialization}</td>
<td>${doctor_details.experience}</td>
<td>${doctor_details.language}</td>
<td>${doctor_details.mobile_No}</td>
<td>${doctor_details.email_ID}</td>
<td>${doctor_details.schedule}</td>
<td><a href="editdoctordetails/${doctor_details.doctor_Id}">Edit</a></td>
<td><a href="deletedoctordetails/${doctor_details.doctor_Id}">Delete</a></td>
</c:forEach>
</table>