Use Jstl to show that the code looks more neat than the JSP, and makes the code less
Copy Code code as follows:
<% @page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding=" UTF-8 "%>
<% @taglib prefix= "c" uri = "Http://java.sun.com/jsp/jstl/core"%>
<% @page import= "Java.util.List"%>
<% @page session= "true"%>
<% @page errorpage= "error.jsp"%>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<title> Search </title>
<script type= "Text/javascript" >
function Validate1 () {
var page = Document.forms[0].page.value;
if (page.length <= 0) {
Alert (Please enter the number of pages you want to jump to!) ");
else if (isNaN (page)) {
Alert (Please enter a valid number of pages!) ");
} else {
Document.forms[0].submit ();
}
}
</script>
<body>
Retrieval time: <c:out value= "${result.costtime}"/>
Total records: <c:out value= "${result.total}<br>" escapexml= "false"/>
<c:foreach items= "${result.article}" var= "current" varstatus= "status" >
<br> <c:out value= "${status.count+ (result.pagenum-1) *20}"/> Strip
<br>
Title: <c:out value= "<a href= ' Servletdetail?rid=${current.rowid} ' >${current.title}</a>" escapexml= " False "></c:out>
<br> Date: <c:out value= "${current.date}"/>
</c:forEach>
<table width= "100%" border= "0" align= "center" cellpadding= "0"
cellspacing= "0" bgcolor= "#8C8C8C" >
<tr>
<TD height= "align=" "Center" bgcolor= "#FFFFFF" >
<c:out value= "${result.pagenum} page/"/>
<c:out value= "Total ${result.totalpage} page"/>
<c:out value= "Total ${result.total} records"/>
<c:if test= "${result.pagenum<2}" >
<c:out value= "Home | prev"/>
</c:if>
<c:if test= "${result.pagenum>=2}" >
<c:out value= "<a href= ' Servletsearch?page=${1}&keyword=${keyword} ' > Home </a>" escapexml= "false"/ >
<c:out value= "<a href= ' Servletsearch?page=${result.pagenum-1}&keyword=${keyword} ' > Prev </a>" Escapexml= "false"/>
</c:if>
<c:out value= "|" />
<c:if test= "${(result.totalpage-result.pagenum) <1}" >
<c:out value= "Next page | end"/>
</c:if>
<c:if test= "${(result.totalpage-result.pagenum) >=1}" >
<c:out value= "<a href= ' Servletsearch?page=${result.pagenum+1}&keyword=${keyword} ' > next page </a>" Escapexml= "false"/>
<c:out value= "<a href= ' Servletsearch?page=${result.totalpage}&keyword=${keyword} ' > End </a>" Escapexml= "false"/>
</c:if>
<form action= "Servletsearch" method= "POST" >
<input type= "text" name= "page" ><input type= "hidden" name= "KeyWord" value=${keyword}>
<input type= "button" value= "Jump to" onclick= "validate1 ()" >
</form>
</table>
</body>