Recent News

Part 2 : Spring Hibernate MVC Crud Application With Example Of Bank Model (.jsp files)

                 



Project Name : springMvcHibernate2


File 1 : bank-form.jsp

CODE : 

<%@page import="java.util.HashMap"%>

<%@page import="javax.print.attribute.HashPrintJobAttributeSet"%>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

<%@page isELIgnored="false" %>


<html>

<head>

<meta charset="ISO-8859-1">

<!-- Bootstrap CSS -->

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<title>Employee Details Form</title>

</head>


<body style="background-color: darksalmon;">

<header>

<div>

<h1 class="navbar-brand text-center" style="font-size: 30px; margin-left: 26%; margin-top: 2%; font-family: sans-serif;"> <b>Enter Employee's Banking Registration Details</b> </h1>

</div>


<ul class="navbar-nav text-center">

<li><a href="<%=request.getContextPath()%>/display" style="font-size: 25px; font-family: monospace;" class="nav-link"><b>Bank Employee's Record</b></a></li>

</ul>

</header> <br>


<div class="container col-md-5" style="margin-bottom: 3%">

<div class="card" style="background-color: bisque">

<div class="card-body">

<c:if test="${bank != null }">

<form action="/springMvcHibernate2/update" method="get" style="align: center;">

</c:if>

<c:if test="${bank == null }">

<form action="insert" method="post" style="align: center;">

</c:if>


<!-- The caption tag is used to specify the caption of a table -->

<caption>

<h2>

<c:if test="${bank != null }">

Edit Bank Employee

</c:if>

<c:if test="${bank == null }">

Insert Bank Employee

</c:if>

</h2>

</caption>

<c:if test="${bank != null }">

<input type="hidden" name="bid" id="bid" value="<c:out value="${bank.bid}" />" />

</c:if>

<!-- <form action="insert" id="form1" ModelAttribute="bank"  method="post">  -->


<fieldset class="form-group">

<b><label>Employee Name</label></b> 

<input type="text" placeholder="Enter Bank Employee Name" class="form-control" name="name" id="name" value="<c:out value="${bank.name}" />"> 

<span style="color: red" id="s1"></span>

</fieldset>


<fieldset class="form-group">

<b><label>Employee Designation</label></b> 

<input type="text" placeholder="Enter Bank Employee Designation" class="form-control" name="designation" id="designation" value="<c:out value="${bank.designation}" />">

<span style="color: red" id="s2"></span>

</fieldset>


<fieldset class="form-group">

<b><label>Employee Phone Number</label></b> 

<input type="text" placeholder="Enter Bank Employee Phone Number" class="form-control" name="phone" id="phone" value="<c:out value="${bank.phone}" />">

<span style="color: red" id="s3"></span>

</fieldset>


<fieldset class="form-group">

<b><label>Employee Description</label></b>

<textarea placeholder="Enter Bank Employee Description" class="form-control" name="des" id="des"><c:out value="${bank.des}" /></textarea>

<span style="color: red" id="s4"></span>

</fieldset>


<fieldset class="form-group">

<!-- yyyy/mm/dd -->

<b><label>Employee Birthday</label></b> <input type="date" id="bday" name="bday" value="<c:out value="${bank.bday}" />"> &nbsp; &nbsp; <br>

<span style="color: red" id="s5"></span>

</fieldset>


<!-- selection box for city -->

<fieldset class="form-group">

<b><label>Employee City</label><br></b> <select name="city"

id="city" class="required">

<option value="">--Select City--</option>

<option value="rajkot" ${bank.city =='rajkot'?'selected':''}>rajkot</option>

<option value="ahmedabad" ${bank.city =='ahmedabad'?'selected':''}>ahmedabad</option>

<option value="amreli" ${bank.city =='amreli'?'selected':''}>amreli</option>

<option value="surat" ${bank.city =='surat'?'selected':''}>surat</option>

<option value="mahesana" ${bank.city =='mahesana'?'selected':''}>mahesana</option>

</select><br> <span style="color: red" id="s6"></span>

</fieldset>

<!-- check box for hobby -->

<fieldset class="form-group">

<b><label>Employee Hobby</label><br></b>

<input type="checkbox" ${fn:contains(bank.hobby,'gym')?'checked':''} value="gym" name="hobby" id="hobby">  &nbsp;  <label>Gym</label>&nbsp;

<input type="checkbox" ${fn:contains(bank.hobby,'football')?'checked':''} value="football" name="hobby" id="hobby">  &nbsp;  <label>Football</label>&nbsp;

<input type="checkbox" ${fn:contains(bank.hobby,'cricket')?'checked':''} value="cricket" name="hobby" id="hobby">  &nbsp;  <label>Cricket</label>&nbsp;

<input type="checkbox" ${fn:contains(bank.hobby,'volleyball')?'checked':''} value="volleyball" name="hobby" id="hobby">  &nbsp;  <label>Volleyball</label>&nbsp;

<input type="checkbox" ${fn:contains(bank.hobby,'basketball')?'checked':''} value="basketball" name="hobby" id="hobby">  &nbsp;  <label>Basketball</label>&nbsp;

<span style="color: red" id="s7"></span>

</fieldset>


<!-- Radio Button For Gender -->

<fieldset class="form-group">

<b><label>Select Employee Gender</label><br></b> 

<input type="radio" ${bank.gender =='male'?'checked':''} value="male" name="gender" id="mgender"> &nbsp; 

<label>Male</label> 

<input type="radio" ${bank.gender =='female'?'checked':''} value="female" name="gender" id="fgender"> &nbsp; 

<label>Female</label>&nbsp; &nbsp; <br> 

<span style="color: red" id="s8"></span>

</fieldset>


<button class="btn btn-primary" type="submit"> <b>Submit</b> </button> &nbsp;&nbsp;

<button class="btn btn-success" type="reset"> <b>Reset</b> </button>


</form>

</div>

</div>

</div>


</body>

</html>


File 1 : bank-list.jsp

CODE : 

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

    pageEncoding="ISO-8859-1"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%@page isELIgnored="false" %>


<html>

<head>

<meta charset="ISO-8859-1">

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<title>Bank Employee List</title>

</head>


<body style="background-color: ffccb3;">

<header>

<div>

<nav class="navbar navbar-expand-md navbar-dark" style="background-color:teal;">

<ul class="navbar-nav">

<li><a href="${pageContext.servletContext.contextPath}" style="font-size: 22px" class="nav-link"><b>Add New Bank Employee</b></a></li>

</ul>

</nav>

</div>

</header><br>

<div class="row">

<div class="container-fluid">

<h3 class="text-center"> List Of Bank Employees</h3><hr>

<table class="table table-bordered">

  <thead>

    <tr>

<th>Employee Id</th>

<th>Employee Name</th>

<th>Employee Designation</th>

<th>Employee Phone</th>

<th>Employee Description</th>

<th>Employee Bday</th>

<th>Employee City</th>

<th>Employee Hobby</th>

<th>Employee Gender</th>

<th>Actions</th>

    </tr>

  </thead>

  <tbody>

    <c:forEach var="bank" items="${listBank}">

    <tr>

    <td><c:out value="${bank.bid }"></c:out></td>

    <td><c:out value="${bank.name }"></c:out></td>

    <td><c:out value="${bank.designation }"></c:out></td>

    <td><c:out value="${bank.phone }"></c:out></td>

    <td><c:out value="${bank.des }"></c:out></td>

    <td><c:out value="${bank.bday }"></c:out></td>

    <td><c:out value="${bank.city }"></c:out></td>

    <td><c:out value="${bank.hobby }"></c:out></td>

    <td><c:out value="${bank.gender }"></c:out></td>    

    <td>

    <a href="<%= request.getContextPath() %>/edit/<c:out value="${bank.bid}" />"><i class="fa fa-paint-brush"  style="font-size:24px"></i></a>&nbsp;    

    <a href="<%= request.getContextPath() %>/delete/<c:out value="${bank.bid}" />"><i class="fa fa-trash"  style="font-size:24px"></i></a>

    </td>

    </tr>

    </c:forEach>

  </tbody>

</table>

</div>

</div>

</body>

</html>

SHARE
  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment