enter image description here我有一个JSP,我在其中调用导航页面以显示顶部的导航。 现在,当我想将列表中的值打印到页面时,它会自动打印在页面顶部,导航将关闭。 有没有办法控制JSP页面中java代码和HTML代码的执行?
<%@page import="com.DB.Config.TimeSheetData" import="java.util.List"
import="com.DB.Config.Timesheet"%>
<%@ 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="HomePage.jsp" />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="css/style.css" />
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<title>Weekly generated Tme Sheet</title>
</head>
<body>
<style>
.TimeSheetForm {
margin-top: 100px;
}
</style>
<%
HttpSession sessions = request.getSession();
String UserName = "", Password = "";
TimeSheetData timeSheetData = new TimeSheetData();
try {
UserName = sessions.getAttribute("UserName").toString();
Password = sessions.getAttribute("Password").toString();
System.out.println("UserName : " + UserName + " and password is : " + Password);
System.out.println(UserName + " user entered the TimeSheet Approval page");
} catch (NullPointerException ne) {
System.out.println("This is coz User Details are null at time sheet page");
}
List<Timesheet> TIMESHEET = timeSheetData.getTimeSheet(UserName);
for (Timesheet TS : TIMESHEET) {
System.out.println(TS.getUserName() + " " + TS.getAttendence() + " " + TS.getWorkingime() + " "
+ TS.getActualWorkingTime() + " " + TS.getBreakTime() + " " + TS.getDate());
}
%>
<form class="TimeSheetForm">
<h4>Time Sheet</h4>
<table align="center">
<tr></tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr>
<td><h5 style="text-align: center; color: white;">WEEK OF
THE YEAR</h5></td>
<td></td>
<td></td>
<td style="text-align: center; color: white;">MONDAY</td>
<td></td>
<td></td>
<td style="text-align: center; color: white;">TUESDAY</td>
<td></td>
<td></td>
<td style="text-align: center; color: white;">WEDNESDAY</td>
<td></td>
<td></td>
<td style="text-align: center; color: white;">THURSDAY</td>
<td></td>
<td></td>
<td style="text-align: center; color: white;">FRIDAY</td>
<td></td>
<td></td>
<td style="text-align: center; color: white;">SATURSDAY</td>
<td></td>
<td></td>
<td style="text-align: center; color: white;">SUNDAY</td>
<td></td>
<td></td>
</tr>
<tr>
<td><h5 style="text-align: center; color: white;">Value</h5></td>
<td></td>
<td></td>
<td><input type="text" name="Moday"
style="width: 120px; height: 20px; text-align: center; border-radius: 10px" /></td>
<td></td>
<td></td>
<td><input type="text" name="Tuesday"
style="width: 120px; height: 20px; text-align: center; border-radius: 10px" /></td>
<td></td>
<td></td>
<td><input type="text" name="Wednesday"
style="width: 120px; height: 20px; text-align: center; border-radius: 10px" /></td>
<td></td>
<td></td>
<td><input type="text" name="Thursday"
style="width: 120px; height: 20px; text-align: center; border-radius: 10px" /></td>
<td></td>
<td></td>
<td><input type="text" name="Friday"
style="width: 120px; height: 20px; text-align: center; border-radius: 10px" /></td>
<td></td>
<td></td>
<td><input type="text" name="Saturday"
style="width: 120px; height: 20px; text-align: center; border-radius: 10px" /></td>
<td></td>
<td></td>
<td><input type="text" name="Sunday"
style="width: 120px; height: 20px; text-align: center; border-radius: 10px" /></td>
<td></td>
<td></td>
</tr>
</table>
<br> <br>
<table align="center">
<tr>
<td><input type="button" name="Submit" value="Submit"
class="buttons"></td>
<td><input type="button" name="Copy" value="Copy"
class="buttons"></td>
</tr>
</table>
</form>
<%int count = 0;
response.getWriter().print("<div>");
for (Timesheet TS : TIMESHEET) {
if (count == 0) {
response.getWriter().print(
"<select style=\"width: 300px; text-align: center;position:fixed;top:400px;left:533px;\">");
}
response.getWriter().print("<option value=" + TS.getDate() + ">" + TS.getDate() + "</option>");
count++;
if (count == TIMESHEET.size()) {
response.getWriter().print("</select>");
}
}
response.getWriter().print("</div>");
%>
<%
response.getWriter().print("<form>");
response.getWriter().print("<table align=\"center\" width=\"80%\">");
response.getWriter().print("<tr>");
response.getWriter().print("<td width=\"20%\"><h5>Date</h5></td>");
response.getWriter().print("<td width=\"20%\"><h5>Working Time</h5></td>");
response.getWriter().print("<td width=\"20%\"><h5>Actual Working Time</h5></td>");
response.getWriter().print("<td width=\"20%\"><h5>Break</h5></td>");
response.getWriter().print("<td width=\"20%\"><h5>Attendence</h5></td>");
response.getWriter().print("</tr>");
response.getWriter().print("<tr>");
response.getWriter().print("<td width=\"20%\"></td>");
response.getWriter().print("</tr></table></form>");
%>
</body>
</html>