FSD Lab Manual
FSD Lab Manual
FSD Lab Manual
FULL STACK
DE VEL O PM EN T
20CS52I
V Semester
Computer Science
Certificate
Name : Sem: IV Semester
Register Number :
KALABURGI
This is certified that the above mentioned student has successfully carried out lab
practice sessions in the Full Stack Development – 20CS51I integrated course during the
Course Coordinator
Examiner Signature
1. _____________________
2. _____________________
List of Programs
SNo. Name of the programs Date of programs Page Remarks
no
Develop small retail application for
online shopping, Write the user stories
1.
for this application using jira project
management tool.
Write the user stories for building a
2. 100 bed hospital using jira Project
management tool.
Create a student resume to apply in a
3. company and upload it on git
repository and update it.
A student want to login his/her Online
Examnitaion Form. Create an Online
4.
Examination login Form and check
validation.
Write a SpringCore program and inject
5.
the object using MethodInjection.
Write a SpringCore program and inject
6. the object using ConstructionInjection
method.
Write a SpringCore program and inject
7. the object using setterInjection
method.
Write a SpringCore program and inject
8. the object using FieldInjection
method.
EPIC:
Develop small Retail application for online shopping
STORY :
1. Develop product search UI screen [description-gather product items, add in product
screen,create search facility for this screen]
2. Task
3. Find product items as provided by user
4. Develop product search service
5. Develop shopping CARD UI for selected product
6. Develop shopping CARD service
7. Develop searched product online order UI component
8. Develop searched product online order service
9. Develop searched product online payment UI components
BUG :
Shopping card screen not working properly
Issue while searching product in product search screen (description-issue fixed and unit testing
done please procced with QA testing)
OUTPUT :
EPIC:
Click on, Create Repository , name the repository (kctp) set for PUBLIC & add
README.md file.
Create a file (file1.html) in (main branch repository(kctp)).
CLONING A REPOSITORY
Click on Code , copy that https link ,
Now open GIT BASH or download it from the browser
Type (cd ..) till you come to C:drive .
1: check git version (git --version)
2: git config --global user.name “xyz”
3: git config --global user.email xyz@gmail.com
4: Now paste that https link
Git clone https://github.com/username/xyz.git
5: ls, after typing this command ,your repository will be there, locally
6: cd (your repository name) ,now you will be in the main branch
Style.css:-
body {
background: linear-gradient(to right, #0f2027, #203a43,
#2c5364);
font-family: 'Poppins', sans-serif;
}
#form {
width: 300px;
margin: 20vh auto 0 auto;
padding: 20px;
background-color: whitesmoke;
border-radius: 4px;
font-size: 12px;
}
#form h1 {
color: #0f2027;
text-align: center;
}
#form button {
padding: 10px;
margin-top: 10px;
width: 100%;
color: white;
background-color: rgb(41, 57, 194);
border: none;
border-radius: 4px;
}
.input-control {
display: flex;
flex-direction: column;
}
.input-control input {
border: 2px solid #f0f0f0;
border-radius: 4px;
display: block;
font-size: 12px;
padding: 10px;
width: 100%;
}
.input-control input:focus {
outline: 0;
}
.input-control.success input {
border-color: #09c372;
}
.input-control.error input {
border-color: #ff3860;
}
.input-control .error {
color: #ff3860;
font-size: 9px;
height: 13px;
}
Js:-
const form = document.getElementById('form');
const username = document.getElementById('username');
const email = document.getElementById('email');
const password = document.getElementById('password');
const password2 = document.getElementById('password2');
form.addEventListener('submit', e => {
e.preventDefault();
validateInputs();
});
errorDisplay.innerText = message;
inputControl.classList.add('error');
inputControl.classList.remove('success')
}
errorDisplay.innerText = '';
inputControl.classList.add('success');
inputControl.classList.remove('error');
};
};
Output:-
5: Write a SpringCore program and inject the object
using MethodInjection.
1. Create a simple java maven project.
2. Maven dependency
Add spring and maven dependency in pom.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.gwpt.cs</groupId>
<artifactId>SpringCoreXML_Ex1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.9</version>
</dependency>
</dependencies>
</project>
package com.gwpt.cs.entity;
public abstract class Student {
4. ApplicationContext.xml
Create ApplicationContext.xml in src/main/resources as
below.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/conte
xt"
xsi:schemaLocation="http://www.springframework.org/schema/
beans
http://www.springframework.org/schema/beans/spring-
beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-
context.xsd ">
</beans>
5. Create SpringXMLConfigurationMain.java
Create a class named "MyMain.java"
in com.gwpt.cs.main package.
package com.gwpt.cs.main;
import org.springframework.context.ApplicationContext;
import
org.springframework.context.support.ClassPathXmlApplicatio
nContext;
import com.gwpt.cs.entity.Student;
public class MyMain {
<properties>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.9</version>
</dependency>
</dependencies>
</project>
package com.gwpt.cs.config;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan("com.gwpt.cs")
public class AppConfig {
package com.gwpt.cs.entity;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component("sobj")
public class Student {
@Value("John")
public void setName(String name) {
this.name = name;
}
package com.gwpt.cs.entity;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component("aobj")
public class Address {
@Value("kalaburgi")
String city;
package com.gwpt.cs.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gwpt.cs.entity.Address;
import com.gwpt.cs.entity.Student;
@Service
public class StudentService {
}
//Autowired Annotation is used for injecting the object
@Autowired
public StudentService(Student s, Address ad) {
this.stud = s;
this.ad = ad;
}
5. Create SpringXMLConfigurationMain.java
Create a class named "MyMain.java"
in com.gwpt.cs.main package.
package com.gwpt.cs.main;
import org.springframework.context.ApplicationContext;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext;
import com.gwpt.cs.config.AppConfig;
import com.gwpt.cs.service.StudentService;
public class MyMain {
<properties>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.9</version>
</dependency>
</dependencies>
</project>
package com.gwpt.cs.config;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan("com.gwpt.cs")
public class AppConfig {
package com.gwpt.cs.entity;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component("sobj")
public class Student {
@Value("GEETHA")
public void setName(String name) {
this.name = name;
}
}
package com.gwpt.cs.entity;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component("aobj")
public class Address {
@Value("kalaburgi")
String city;
package com.gwpt.cs.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.gwpt.cs.entity.Address;
import com.gwpt.cs.entity.Student;
@Component
public class StudentService {
private Student s;
private Address ad;
5. Create SpringXMLConfigurationMain.java
Create a class named "MyMain.java"
in com.gwpt.cs.main package
package com.gwpt.cs.main;
import org.springframework.context.ApplicationContext;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext;
import com.gwpt.cs.config.AppConfig;
import com.gwpt.cs.service.StudentService;
<modelVersion>4.0.0</modelVersion>
<groupId>com.gwpt.cs</groupId>
<artifactId>SpringCoreXML_Ex1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.9</version>
</dependency>
</dependencies>
</project>
@Configuration
@ComponentScan("com.gwpt.cs")
public class AppConfig {
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class Student {
@Value("106")
private int rollNo;
@Value("Ashweta")
private String name;
package com.gwpt.cs.entity;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class Address {
@Value("kalaburgi")
String city;
package com.gwpt.cs.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.gwpt.cs.entity.Address;
import com.gwpt.cs.entity.Student;
@Component
public class StudentService {
//injecting object by field Injection
@Autowired
private Student s;
@Autowired
private Address ad;
5. Create SpringXMLConfigurationMain.java
Create a class named "MyMain.java"
in com.gwpt.cs.main package
package com.gwpt.cs.main;
import org.springframework.context.ApplicationContext;
import
org.springframework.context.annotation.AnnotationConfigApplicationCo
ntext;
import com.gwpt.cs.config.AppConfig;
import com.gwpt.cs.service.StudentService;
import org.springframework.boot.SpringApplication;
import
org.springframework.boot.autoconfigure.SpringBootApplicati
on;
import org.springframework.context.ApplicationContext;
import com.gwpt.cs.entity.Student;
@SpringBootApplication
public class Application {
Com.gwpt.cs.entity:-
Student.java:-
package com.gwpt.cs.entity;
import
org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class Student {
@Value("101")
private int rollNo;
@Value("Geeta")
private String name;
@Autowired
private Address addr;
Address.java:-
package com.gwpt.cs.entity;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class Address {
@Value("Kalaburagi")
private String city;
}
Pom.xml:-
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-
parent</artifactId>
<version>2.7.7</version>
<relativePath/> <!-- lookup parent from
repository -->
</parent>
<groupId>com.gwpt.cs</groupId>
<artifactId>9GSpringBoot_FirstEx</artifactId>
<version>1.0</version>
<name>9GSpringBoot_FirstEx</name>
<description>Demo project for Spring
Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-
test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-
plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
OUTPUT:
10: Develop the data access layer of the employee
management application to perform the database
operations given below using spring data JPA.
import org.springframework.boot.SpringApplication;
import
org.springframework.boot.autoconfigure.SpringBootApplicati
on;
@SpringBootApplication
public class Application {
Com.gwpt.cs.entity:-
Employee.java:-
package com.gwpt.cs.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="emptab")
public class Employee {
@Id
@GeneratedValue
private Integer empId;
@Column(length=30)
private String empName;
private Double empSal;
@Column(length=30)
private String empDept;
public Employee() {
}
public Employee(String empName, Double empSal, String
empDept) {
super();
this.empName = empName;
this.empSal = empSal;
this.empDept = empDept;
}
public Employee(Integer empId, String empName, Double
empSal, String empDept) {
super();
this.empId = empId;
this.empName = empName;
this.empSal = empSal;
this.empDept = empDept;
}
public Integer getEmpId() {
return empId;
}
public void setEmpId(Integer empId) {
this.empId = empId;
}
public String getEmpName() {
return empName;
}
public void setEmpName(String empName) {
this.empName = empName;
}
public Double getEmpSal() {
return empSal;
}
public void setEmpSal(Double empSal) {
this.empSal = empSal;
}
public String getEmpDept() {
return empDept;
}
public void setEmpDept(String empDept) {
this.empDept = empDept;
}
@Override
public String toString() {
return "Employee [empId=" + empId + ", empName="
+ empName + ", empSal=" + empSal + ", empDept=" + empDept
+ "]";
}
Com.gwpt.cs.repo:-
EmployeeRepository.java:-
package com.gwpt.cs.repo;
import java.util.List;
import
org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.gwpt.cs.entity.Employee;
@Repository
public interface EmployeeRepository extends
JpaRepository<Employee, Integer> {
//ReturnType findBy<VariableName>(<DataType>
<paramName>);
//SQL: select * from emptab where ename=?
List<Employee> findByEmpName(String empName);
List<Employee> findByOrderByEmpSalAsc();
}
Com.gwpt.cs.runner:-
EmployeeDataInserRunner.java:-
package com.gwpt.cs.runner;
import
org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import com.gwpt.cs.entity.Employee;
import com.gwpt.cs.repo.EmployeeRepository;
@Component
public class EmployeeDataInsertRunner implements
CommandLineRunner{
@Autowired
private EmployeeRepository repo;
@Override
public void run(String... args) throws Exception {
// --- insert data ----
repo.save(new
Employee("Kajol",10000.0,"Development"));
repo.save(new
Employee("Sapana",4000.0,"Sales"));
repo.save(new
Employee("Ashweta",5000.0,"Accounts"));
repo.save(new
Employee("Rose",9000.0,"Development"));
repo.save(new
Employee("Sneha",5000.0,"Testing"));
repo.save(new
Employee("Sahithi",3000.0,"Sales"));
repo.save(new
Employee("Jythoi",5000.0,"Marketing"));
repo.save(new
Employee("Neha",10000.0,"Development"));
repo.save(new
Employee("Rama",6500.0,"Marketing"));
repo.save(new
Employee("Yamini",8000.0,"Development"));
}
FindByTestRunner.java:-
package com.gwpt.cs.runner;
import java.util.List;
import
org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import com.gwpt.cs.entity.Employee;
import com.gwpt.cs.repo.EmployeeRepository;
@Component
public class FindByTestRunner implements CommandLineRunner
{
@Autowired
private EmployeeRepository repo;
@Override
public void run(String... args) throws Exception {
List<Employee>
list1=repo.findByEmpName("Sapana");
displayResult(list1);
System.out.println("--------------------");
List<Employee> list2=repo.findByEmpSal(5000.0);
displayResult(list2);
System.out.println("--------------------");
List<Employee>
list3=repo.findByEmpSalLessThan(9000.0);
displayResult(list3);
System.out.println("--------------------");
List<Employee>
list4=repo.findByOrderByEmpSalAsc();
displayResult(list4);
System.out.println("--------------------");
}
Src/main/resources:-
Application.properties:-
# Following are DataSource (Database Connection)
properties
spring.datasource.driver-class-
name=oracle.jdbc.driver.OracleDriver
spring.datasource.url=jdbc:oracle:thin:@localhost:1521:XE
spring.datasource.username=system
spring.datasource.password=manager
Pom.xml:-
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-
parent</artifactId>
<version>2.7.7</version>
<relativePath/> <!-- lookup parent from
repository -->
</parent>
<groupId>com.gwpt.cs</groupId>
<artifactId>9JSpringBoot_DataJPA_findBy_Ex3</artifact
Id>
<version>1.0</version>
<name>9JSpringBoot_DataJPA_findBy_Ex3</name>
<description>Demo project for Spring
Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-
jpa</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-
test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-
plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
OUTPUT:
11: Create a springboot application and perfrom CURD
operations.
Src/main/java:-
Application.java:-
package com.gwpt.cs;
import org.springframework.boot.SpringApplication;
import
org.springframework.boot.autoconfigure.SpringBootApplicati
on;
@SpringBootApplication
public class Application {
Com.gwpt.cs.entity:-
Employee.java:-
package com.gwpt.cs.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="emptab")
public class Employee {
@Id
@GeneratedValue
private Integer eid;
@Column(length=15)
private String ename;
@Column(length=24)
private String email;
Com.gwpt.cs.controller:-
EmployeeController.java:-
package com.gwpt.cs.controller;
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.GetMapping;
import
org.springframework.web.bind.annotation.ModelAttribute;
import
org.springframework.web.bind.annotation.PostMapping;
import
org.springframework.web.bind.annotation.RequestParam;
import com.gwpt.cs.entity.Employee;
import com.gwpt.cs.service.EmployeeService;
@Controller
public class EmployeeController {
@Autowired
private EmployeeService empService;
@GetMapping("/all")
public String showAllEmps(Model model) {
//call service to fetch data
List<Employee> list =
empService.getAllEmployees();
//send to UI
model.addAttribute("employeeList", list);
return "EmpData";
}
@GetMapping("/delete")
public String removeEmp(@RequestParam Integer
eid,Model model){
//delete data based on Id
empService.deleteEmployee(eid);
return "redirect:all";
}
return "EmployeeEdit";
}
Com.gwpt.cs.repo:-
EmployeeRepository.java:-
package com.gwpt.cs.repo;
import org.springframework.data.jpa.repository.JpaRepository;
import com.gwpt.cs.entity.Employee;
public interface EmployeeRepository extends JpaRepository<Employee,
Integer>{
}
Com.gwpt.cs.service:-
EmployeeService.java:-
package com.gwpt.cs.service;
import java.util.List;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gwpt.cs.entity.Employee;
import com.gwpt.cs.repo.EmployeeRepository;
Src/main/resources:-
Application.properties:-
server.port=8088
# Following are DataSource (Database Connection)
properties
spring.datasource.driver-class-
name=oracle.jdbc.driver.OracleDriver
spring.datasource.url=jdbc:oracle:thin:@localhost:1521:XE
spring.datasource.username=system
spring.datasource.password=manager
# MVC
spring.mvc.view.prefix=/WEB-INF/view/
spring.mvc.view.suffix=.jsp
src:-
main:-
webapp:-
WEB-INF:-
View:-
EmpData.jsp:-
<%@ page language="java" contentType="text/html;
charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib prefix="c"
uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h3>WELCOME TO EMPLOYEE DATA PAGE!!</h3>
<table border="1">
<tr>
<th>ID</th>
<th>NAME</th>
<th>MAIL</th>
<th>SALARY</th>
<th>DEPT</th>
<th>LINK</th>
</tr>
<c:forEach items="${employeeList}" var="ob">
<tr>
<td>${ob.eid}</td>
<td>${ob.ename}</td>
<td>${ob.email}</td>
<td>${ob.esal}</td>
<td>${ob.dept}</td>
<td>
<a
href="delete?eid=${ob.eid}">DELETE</a> |
<a href="edit?eid=${ob.eid}">EDIT</a>
</td>
</tr>
</c:forEach>
</table>
${message}
</body>
</html>
EmployeeEdit.jsp:-
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h3>EMPLOYEE EDIT PAGE</h3>
<form:form action="update" method="POST"
modelAttribute="employee">
<pre>
ID : <form:input path="eid" readonly="true"/>
NAME: <form:input path="ename"/>
MAIL: <form:input path="email"/>
SAL : <form:input path="esal"/>
DEPT: <form:select path="dept">
<form:option value="">-SELECT-</form:option>
<form:option value="CSE">CSE</form:option>
<form:option value="EC">EC</form:option>
<form:option value="CP">CP</form:option>
</form:select>
<input type="submit" value="Update"/>
</pre>
</form:form>
</body>
</html>
EmployeeReg.jsp:-
Pom.xml:-
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-
parent</artifactId>
<version>2.7.7</version>
<relativePath /> <!-- lookup parent from
repository -->
</parent>
<groupId>com.gwpt.cs</groupId>
<artifactId>9LSpringBoot_SpringWebMVC_CRUD_Ex4</artif
actId>
<version>1.0</version>
<name>9LSpringBoot_SpringWebMVC_CRUD_Ex4</name>
<description>Demo project for Spring
Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-
jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-
web</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-
test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-
devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-
plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
OUTPUT:
12: Create a RESTcontroller class to insert employee
details and display them.
Src/main/java:-
Application.java:-
package com.gwpt.cs;
import org.springframework.boot.SpringApplication;
import
org.springframework.boot.autoconfigure.SpringBootApplicati
on;
@SpringBootApplication
public class Application {
Com.gwpt.cs.entity:-
Employee.java:-
package com.gwpt.cs.entity;
import java.util.List;
Com.gwpt.cs.controller:-
EmployeeController.java:-
package com.gwpt.cs.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import
org.springframework.web.bind.annotation.ModelAttribute;
import
org.springframework.web.bind.annotation.PostMapping;
import com.gwpt.cs.entity.Employee;
@Controller
public class EmployeeController {
@GetMapping("/reg")
public String showRegForm(Model model) {
Employee e = new Employee();
e.setEmpId(889);
e.setEmpName("Anny");
e.setEmpGen("Female");
e.setEmpDept("CSE");
model.addAttribute("employee", e);
return "EmployeeReg";
}
@PostMapping("/save")
public String readData(@ModelAttribute Employee
employee,Model model) {
model.addAttribute("emp",employee);
return "EmpData";
}
}
Com.gwpt.cs.
Src/main/resource:-
Application.properties:-
server.port=8088
spring.mvc.view.prefix=/WEB-INF/view/
spring.mvc.view.suffix=.jsp
src:-
main:-
webapp:-
WEB-INF:-
View:-
EmployeeData.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>Insert title here</title>
</head>
<body>
<h3>WELCOME TO DATA PAGE!!: </h3>
<pre>
Employee Id :${emp.empId}<br>
Employee Name :${emp.empName}<br>
Employee Dept :${emp.empDept}<br>
</pre>
</body>
</html>
EmployeeReg.jsp:-
<%@ page language="java" contentType="text/html;
charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib prefix="form"
uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h3>WELCOME TO EMPLOYEE REGISTER PAGE</h3>
<form:form action="save" method="POST"
modelAttribute="employee">
<pre>
ID : <form:input path="empId"/>
NAME : <form:input path="empName"/>
SAL : <form:input path="empSal"/>
PWD : <form:password path="empPwd"/>
GEN :
<form:radiobutton path="empGen" value="Male"/> Male
<form:radiobutton path="empGen" value="Female"/>
Female
LANGS:
<form:checkbox path="empLang" value="ENGLISH"/>
ENGLISH
<form:checkbox path="empLang" value="HINDI"/> HINDI
<form:checkbox path="empLang" value="KANNADA"/>
KANNADA
</pre>
</form:form>
</body>
</html>
Pom.xml:-
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-
parent</artifactId>
<version>2.7.7</version>
<relativePath /> <!-- lookup parent from
repository -->
</parent>
<groupId>com.gwpt.cs</groupId>
<artifactId>9LSpringBoot_SpringWebMVC_SpringTag_Ex3</
artifactId>
<version>1.0</version>
<name>9LSpringBoot_SpringWebMVC_SpringTag_Ex3</name>
<description>Demo project for Spring
Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-
web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-
test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-
plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
OUTPUT: