Hello Readers,
I am going to share part 2 of my interview question which is CRUD application ask in practical round so here I am sharing the complete code here.
hope you will enjoy it !
INCLUDED ALL .JSP FILES
Project Name : meavenCrudSpring
this file is for add product in to the database.
File 1 : add_product_form.jsp (location : meavenCrudSpring\src\main\webapp\WEB-INF\views\)
CODE :
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<%@include file="./base.jsp" %>
</head>
<body>
<div class="container mt-3" >
<div class="row">
<div class="col-md-6 offset-md-3">
<h1 class="text-center mb-3">Fill The Product Form</h1>
<form action="handle-product" method="post">
<div class="form-group">
<label for="name">Product Name </label>
<input type="text" class="form-control" id="name" name="name" placeholder="Enter Product Name ">
</div>
<div class="form-group">
<label for="description">Product Description </label>
<textarea class="form-control" id="description" name="description" row="5" placeholder="Enter Product Description " ></textarea>
</div>
<div class="form-group">
<label for="price">Product Price </label>
<input type="text" class="form-control" id="price" name="price" placeholder="Enter Product Price ">
</div>
<div class="container text-center">
<button type="submit" class="btn btn-primary">Add</button>
<a href="${pageContext.request.contextPath }/" class="btn btn-outline-danger">Back</a>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
-----------------------------------------------------------------------------------------------------------------------------
this file is for taglib, scripts and title.
File 2 : base.jsp (location : meavenCrudSpring\src\main\webapp\WEB-INF\views\)
CODE :
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<%@ page isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<title> <c:out value="${title}"></c:out></title>
-----------------------------------------------------------------------------------------------------------------------------
this file is for update product in to the database
File 3 : update_form.jsp (location : meavenCrudSpring\src\main\webapp\WEB-INF\views\)
CODE :
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<%@include file="./base.jsp" %>
</head>
<body>
<div class="container mt-3">
<div class="row">
<div class="col-md-6 offset-md-3">
<h1 class="text-center mb-3">Update Product Details </h1>
<form action="${pageContext.request.contextPath }/handle-product" method="post">
<div class="form-group">
<label for="id">Product Id </label>
<input type="text" id="id" value="${product.id }" name="id" />
</div>
<div class="form-group">
<label for="name">Product Name </label>
<input type="text" class="form-control" id="name" name="name" placeholder="Enter Product Name " value="${product.name }">
</div>
<div class="form-group">
<label for="description">Product Description </label>
<textarea class="form-control" id="description" name="description" row="5" placeholder="Enter Product Description " >${product.description }</textarea>
</div>
<div class="form-group">
<label for="price">Product Price </label>
<input type="text" class="form-control" id="price" name="price" placeholder="Enter Product Price " value="${product.price}">
</div>
<div class="container text-center">
<button type="submit" class="btn btn-warning">Update</button>
<a href="${pageContext.request.contextPath }/" class="btn btn-outline-danger">Back</a>
</div>
</form>
</div>
</div>
</div>
</body>
Thanks for Reading !!
0 comments:
Post a Comment