<%@page import="com.vvt.samplprojectcode.utilities.Message"%>
<%@page import="com.vvt.samplprojectcode.utilities.LocationDetailsUtilities"%>
<%@page import="com.vvt.samplprojectcode.dto.LocationDetails"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:include page="/pages/template.jsp">
<jsp:param value="<div id='ch'/>" name="content" />
</jsp:include>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Location Details</title>
<script type="text/javascript">
function editLocation(slno) {
window.location.href = "locationdetails.jsp?slno=" + slno + "&type=displayData";
}
function deleteLocation(slno) {
swal({
title: "Are you sure?",
text: "Do you want to delete the selected location?",
icon: "warning",
buttons: true,
dangerMode: true,
}).then((willDelete) => {
if (willDelete) {
window.location.href = "locationdetails.jsp?slno=" + slno + "&type=deleteData";
}
});
}
</script>
</head>
<body>
<%
if (session.getAttribute("username") == null) {
response.sendRedirect("login.jsp?" + Message.session_logout);
} else {
try {
LocationDetailsUtilities locationDetails = new LocationDetailsUtilities();
LocationDetails roleDetailsModal = new LocationDetails();
int slno = 0;
String type = request.getParameter("type");
if (type != null && type.equalsIgnoreCase("saveData")) {
locationDetails.setLocationname(request.getParameter("LocationName"));
String message = LocationDetailsController.saveLocationDetails(locationDetails);
response.sendRedirect("fileupload.jsp?" + message);
}
%>
<div class="right_col" role="main">
<div class="">
<div class="clearfix"></div>
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h2>Location Details (Upload File)</h2>
<div style="float: right">
<a href="${pageContext.request.contextPath}/ExcelTemplate/locationdetails.xlsx">
Location details <i class="fa fa-download"></i>
</a>
</div>
<div class="clearfix"></div>
</div>
<form action="bulkUploadData.jsp?type=locationDetails"
class="form-horizontal form-label-left" method="post"
enctype="multipart/form-data">
<div class="form-group">
<label class="control-label col-md-2">
Select File:<span style="color: red">*</span>
</label>
<div class="col-md-4">
<input type="file" name="file" class="form-control">
</div>
<div>
<button type="reset" class="btn btn-primary">Reset</button>
<input type="submit" value="Submit" class="btn btn-success" />
</div>
</div>
</form>
<form action="fileupload.jsp?type=saveData" method="post"
class="form-horizontal form-label-left">
<div class="form-group">
<label class="control-label col-md-2">
Location Name:<span style="color: red">*</span>
</label>
<div class="col-md-4">
<input type="text" name="locationName" class="form-control"
placeholder="Enter Location Name" required>
</div>
<div>
<button type="reset" class="btn btn-primary">Reset</button>
<input type="submit" value="Submit" class="btn btn-success" />
</div>
</div>
</form>
</div>
<div class="x_panel">
<table class="table" id="datatable">
<thead>
<tr>
<th>Slno</th>
<th>Location Name</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<%
int count = 0;
LocationDetailsUtilities locationDetailsUtilities = new LocationDetailsUtilities();
for (LocationDetails display : locationDetailsUtilities.getLocationDetails()) {
count++;
%>
<tr>
<td><%= count %></td>
<td><%= display.getLocationname() %></td>
<td><button onclick="editLocation('<%=display.getSlno()%>')" class="btn edit" title="Edit">
<i class="fa fa-pencil"></i>
</button></td>
<td><button type="button" onclick="deleteLocation('<%=display.getSlno()%>')" class="btn delete" title="Delete">
<i class="fa fa-trash-o fa-lg"></i>
</button></td>
</tr>
<% } %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<%
} catch (Exception e) {
e.printStackTrace();
response.sendRedirect("login.jsp?" + Message.session_logout);
}
}
%>
</body>
</html>
In this code i want to add a manual locationname and that will be store on ui table and mysql table please suggest the corrected code
Posted by Salman (1) at 2025-05-06T13:57:42Z
Caught for
Low Length