Lucene项目的jsp

index.jsp


Java代码
1.<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
2.<%
3.String path = request.getContextPath();
4.String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
5.%>
6.
7.<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
8.<html>
9. <head>
10. <base href="<%=basePath%>">
11.
12. <title>My JSP 'left.jsp' starting page</title>
13.
14. <meta http-equiv="pragma" content="no-cache">
15. <meta http-equiv="cache-control" content="no-cache">
16. <meta http-equiv="expires" content="0">
17. <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
18. <meta http-equiv="description" content="This is my page">
19. <!--
20. <link rel="stylesheet" type="text/css" href="styles.css">
21. -->
22.
23. </head>
24.
25. <body bgcolor=f1f1f1 style="border-right:#000000 1px solid">
26. <a href="searchForm.jsp" target="main">搜索</a><br>
27. <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
28. </body>
29.</html>
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'left.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>

<body bgcolor=f1f1f1 style="border-right:#000000 1px solid">
<a href="searchForm.jsp" target="main">搜索</a><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</body>
</html>

left.jsp


Java代码
1.<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
2.<%
3.String path = request.getContextPath();
4.String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
5.%>
6.
7.<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
8.<html>
9. <head>
10. <base href="<%=basePath%>">
11.
12. <title>My JSP 'left.jsp' starting page</title>
13.
14. <meta http-equiv="pragma" content="no-cache">
15. <meta http-equiv="cache-control" content="no-cache">
16. <meta http-equiv="expires" content="0">
17. <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
18. <meta http-equiv="description" content="This is my page">
19. <!--
20. <link rel="stylesheet" type="text/css" href="styles.css">
21. -->
22.
23. </head>
24.
25. <body bgcolor=f1f1f1 style="border-right:#000000 1px solid">
26. <a href="searchForm.jsp" target="main">搜索</a><br>
27. <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
28. </body>
29.</html>
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'left.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>

<body bgcolor=f1f1f1 style="border-right:#000000 1px solid">
<a href="searchForm.jsp" target="main">搜索</a><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</body>
</html>

top.jsp


Java代码
1.<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
2.<%
3.String path = request.getContextPath();
4.String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
5.%>
6.
7.<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
8.<html>
9. <head>
10. <base href="<%=basePath%>">
11.
12. <title>My JSP 'top.jsp' starting page</title>
13.
14. <meta http-equiv="pragma" content="no-cache">
15. <meta http-equiv="cache-control" content="no-cache">
16. <meta http-equiv="expires" content="0">
17. <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
18. <meta http-equiv="description" content="This is my page">
19. <!--
20. <link rel="stylesheet" type="text/css" href="styles.css">
21. -->
22.
23. </head>
24.
25. <body bgcolor="green">
26. 搜索系统 V 11.0<br>
27. </body>
28.</html>
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'top.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>

<body bgcolor="green">
搜索系统 V 11.0<br>
</body>
</html>


readme.jsp


Java代码
1.<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
2.<%
3.String path = request.getContextPath();
4.String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
5.%>
6.
7.<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
8.<html>
9. <head>
10. <base href="<%=basePath%>">
11.
12. <title>My JSP 'readme.jsp' starting page</title>
13.
14. <meta http-equiv="pragma" content="no-cache">
15. <meta http-equiv="cache-control" content="no-cache">
16. <meta http-equiv="expires" content="0">
17. <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
18. <meta http-equiv="description" content="This is my page">
19. <!--
20. <link rel="stylesheet" type="text/css" href="styles.css">
21. -->
22.
23. </head>
24.
25. <body>
26. 欢迎使用本系统 <br>
27. </body>
28.</html>
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'readme.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>

<body>
欢迎使用本系统 <br>
</body>
</html>

searchForm.jsp


Java代码
1.<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
2.<%
3.String path = request.getContextPath();
4.String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
5.%>
6.
7.<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
8.<html>
9. <head>
10. <base href="<%=basePath%>">
11.
12. <title>My JSP 'searchForm.jsp' starting page</title>
13.
14. <meta http-equiv="pragma" content="no-cache">
15. <meta http-equiv="cache-control" content="no-cache">
16. <meta http-equiv="expires" content="0">
17. <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
18. <meta http-equiv="description" content="This is my page">
19. <!--
20. <link rel="stylesheet" type="text/css" href="styles.css">
21. -->
22.
23. </head>
24. <script type="text/javascript">
25. function check(){
26. if(document.forms[0].key.value==""){
27. alert("关键词不能为空");
28. return false;
29. }
30. return true;
31. }
32. </script>
33. <body>
34. <form action="results.jsp" method="get" onSubmit="return check();">
35. 关键词:<input name=key >
36.
37.
38. <input type=submit value="搜索">
39. </form>
40.
41.
42. <br>
43. </body>
44.</html>
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'searchForm.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>
<script type="text/javascript">
function check(){
if(document.forms[0].key.value==""){
alert("关键词不能为空");
return false;
}
return true;
}
</script>
<body>
<form action="results.jsp" method="get" onSubmit="return check();">
关键词:<input name=key >


<input type=submit value="搜索">
</form>


<br>
</body>
</html>

result.jsp


Java代码
1.<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
2.
3.<%@ page import="java.io.IOException"%>
4.<%@ page import="org.apache.lucene.document.Document"%>
5.<%@ page import="org.apache.lucene.index.CorruptIndexException"%>
6.<%@ page import="org.apache.lucene.index.Term"%>
7.<%@ page import="org.apache.lucene.search.Hits"%>
8.<%@ page import="org.apache.lucene.search.IndexSearcher"%>
9.<%@ page import="org.apache.lucene.search.Query"%>
10.<%@ page import="org.apache.lucene.search.TermQuery"%>
11.<%@ page import="com.bjsxt.lucene.util.*"%>
12.
13.<%
14.String path = request.getContextPath();
15.String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
16.
17.int start = 0;
18.try{
19.start = Integer.parseInt(request.getParameter("start"));
20.}catch(Exception e){}
21.int max = 10;
22.%>
23.
24.<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
25.
26.
27.<html>
28. <head>
29. <base href="<%=basePath%>">
30.
31. <title>My JSP 'results.jsp' starting page</title>
32.
33. <meta http-equiv="pragma" content="no-cache">
34. <meta http-equiv="cache-control" content="no-cache">
35. <meta http-equiv="expires" content="0">
36. <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
37. <meta http-equiv="description" content="This is my page">
38.
39. <link rel="stylesheet" type="text/css" href="styles.css">
40.
41.
42. </head>
43. <script type="text/javascript">
44. function check(){
45. if(document.forms[0].key.value==""){
46. alert("关键词不能为空");
47. return false;
48. }
49. return true;
50. }
51. </script>
52. <body>
53.
54.<%
55. String index = "D:\\share\\0400_Servlet_JSP\\soft\\apache-tomcat-5.5.17\\apache-tomcat-5.5.17\\index_cn";
56. IndexSearcher searcher=null;
57. searcher = new IndexSearcher(index);
58. Query query = new TermQuery(new Term("title",request.getParameter("key")));
59. Hits hits = searcher.search(query);
60. System.out.println(hits.length());
61. if(hits.length()>0){
62.
63. %>
64. <form action="results.jsp" method="get" name=searchForm onSubmit="return check()">
65. 关键词:<input name=key value="<%=request.getParameter("key") %>">
66. <input name=start value="<%=start%>">
67. <input type=submit value="搜索">
68. </form>
69. 一共找到了<%=hits.length() %>条结果
70. <div id=gridData>
71. <table border=0 cellpadding="3" cellspacing="1">
72. <tr>
73. <td>序号</td>
74. <td>标题</td>
75. <!-- <td>摘要</td> -->
76. </tr>
77. <%
78.
79. for (int i = start; i < start+max; i++) {
80. if(i>=hits.length()){
81. break;
82. }
83. Document doc = hits.doc(i);
84. String _title = doc.get("title");
85. String _summary = doc.get("summary");
86. String _path = doc.get("path");
87. //D:\share\0100_J2SE\soft\html_zh_CN\html\zh_CN\api\java\lang\String.html
88. //http://127.0.0.1/api/java/lang/String.html
89.
90.
91. _path = _path.replaceAll("D:\\\\share\\\\0100_J2SE\\\\soft\\\\html_zh_CN\\\\html\\\\zh_CN\\\\","");
92. _path = _path.replace('\\','/');
93. _path = "http://127.0.0.1/"+_path;
94. System.out.println(_path);
95.
96.%>
97. <tr>
98. <td><%=i+1 %></td>
99. <td><a href="<%=_path %>"><%=_title %></a></td>
100. <!-- <td><%=com.bjsxt.lucene.util.DataFilter.getHTML(_summary)%></td> -->
101. </tr>
102.
103.<% }
104. searcher.close();
105.
106. %>
107.
108.
109.
110. </table>
111.<a href="javascript:first();">首页</a>
112.<%if(start-max>=0){ %>
113. <a href="javascript:previous();">上一页</a>
114.<%}else{ %>
115. 上一页
116.<%} %>
117.<%if(start+max<hits.length()){ %>
118. <a href="javascript:next();">下一页</a>
119.<%}else{ %>
120. 下一页
121.<%} %>
122.<a href="javascript:last();">尾页</a>
123.</div>
124.
125.<script type="text/javascript">
126.function first(){
127. searchForm.start.value=0;
128. searchForm.submit();
129.}
130.function previous(){
131. searchForm.start.value=<%=start-max%>;
132. searchForm.submit();
133.}
134.function next(){
135. searchForm.start.value=<%=start+max%>;
136. searchForm.submit();
137.}
138.function last(){
139. searchForm.start.value=<%=hits.length()/max*max%>;
140. searchForm.submit();
141.}
142.
143.</script>
144.<%}else{ %>
145.
146. 对不起没找到结果,请重新设定搜索条件<a href=javascript:history.back()>返回</a>
147.
148.<%} %>
149. <br>
150. </body>
151.</html>
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>

<%@ page import="java.io.IOException"%>
<%@ page import="org.apache.lucene.document.Document"%>
<%@ page import="org.apache.lucene.index.CorruptIndexException"%>
<%@ page import="org.apache.lucene.index.Term"%>
<%@ page import="org.apache.lucene.search.Hits"%>
<%@ page import="org.apache.lucene.search.IndexSearcher"%>
<%@ page import="org.apache.lucene.search.Query"%>
<%@ page import="org.apache.lucene.search.TermQuery"%>
<%@ page import="com.bjsxt.lucene.util.*"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

int start = 0;
try{
start = Integer.parseInt(request.getParameter("start"));
}catch(Exception e){}
int max = 10;
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">


<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'results.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<link rel="stylesheet" type="text/css" href="styles.css">


</head>
<script type="text/javascript">
function check(){
if(document.forms[0].key.value==""){
alert("关键词不能为空");
return false;
}
return true;
}
</script>
<body>

<%
String index = "D:\\share\\0400_Servlet_JSP\\soft\\apache-tomcat-5.5.17\\apache-tomcat-5.5.17\\index_cn";
IndexSearcher searcher=null;
searcher = new IndexSearcher(index);
Query query = new TermQuery(new Term("title",request.getParameter("key")));
Hits hits = searcher.search(query);
System.out.println(hits.length());
if(hits.length()>0){

%>
<form action="results.jsp" method="get" name=searchForm onSubmit="return check()">
关键词:<input name=key value="<%=request.getParameter("key") %>">
<input name=start value="<%=start%>">
<input type=submit value="搜索">
</form>
一共找到了<%=hits.length() %>条结果
<div id=gridData>
<table border=0 cellpadding="3" cellspacing="1">
<tr>
<td>序号</td>
<td>标题</td>
<!-- <td>摘要</td> -->
</tr>
<%

for (int i = start; i < start+max; i++) {
if(i>=hits.length()){
break;
}
Document doc = hits.doc(i);
String _title = doc.get("title");
String _summary = doc.get("summary");
String _path = doc.get("path");
//D:\share\0100_J2SE\soft\html_zh_CN\html\zh_CN\api\java\lang\String.html
//http://127.0.0.1/api/java/lang/String.html


_path = _path.replaceAll("D:\\\\share\\\\0100_J2SE\\\\soft\\\\html_zh_CN\\\\html\\\\zh_CN\\\\","");
_path = _path.replace('\\','/');
_path = "http://127.0.0.1/"+_path;
System.out.println(_path);

%>
<tr>
<td><%=i+1 %></td>
<td><a href="<%=_path %>"><%=_title %></a></td>
<!-- <td><%=com.bjsxt.lucene.util.DataFilter.getHTML(_summary)%></td> -->
</tr>

<% }
searcher.close();

%>



</table>
<a href="javascript:first();">首页</a>
<%if(start-max>=0){ %>
<a href="javascript:previous();">上一页</a>
<%}else{ %>
上一页
<%} %>
<%if(start+max<hits.length()){ %>
<a href="javascript:next();">下一页</a>
<%}else{ %>
下一页
<%} %>
<a href="javascript:last();">尾页</a>
</div>

<script type="text/javascript">
function first(){
searchForm.start.value=0;
searchForm.submit();
}
function previous(){
searchForm.start.value=<%=start-max%>;
searchForm.submit();
}
function next(){
searchForm.start.value=<%=start+max%>;
searchForm.submit();
}
function last(){
searchForm.start.value=<%=hits.length()/max*max%>;
searchForm.submit();
}

</script>
<%}else{ %>

对不起没找到结果,请重新设定搜索条件<a href=javascript:history.back()>返回</a>

<%} %>
<br>
</body>
</html>

styles.css


Java代码
1.BODY{
2. FONT-SIZE: 9pt;
3. line-height: 150%;
4. margin-top:10px;
5. margin-bottom:0px;
6. margin-left:10px;
7. margin- right:0px;
8. scrollbar-face-color: #f6f6f6;
9. scrollbar-highlight-color: #ffffff;
10. scrollbar-shadow-color: #cccccc;
11. scrollbar-3dlight-color: #cccccc;
12. scrollbar-arrow-color: #330000;
13. scrollbar-track-color: #f6f6f6;
14. scrollbar-darkshadow-color: #ffffff;
15.}
16.input{
17. BORDER-TOP-WIDTH: 1px;
18. PADDING-RIGHT: 1px;
19. PADDING-LEFT: 1px;
20. BORDER-LEFT-WIDTH: 1px;
21. FONT-SIZE: 9pt;
22. BORDER-LEFT-COLOR: #cccccc;
23. BORDER-BOTTOM-WIDTH: 1px;
24. BORDER-BOTTOM-COLOR: #cccccc;
25. PADDING-BOTTOM: 1px;
26. BORDER-TOP-COLOR: #cccccc;
27. PADDING-TOP: 1px;
28. BORDER-RIGHT-WIDTH: 1px;
29. BORDER-RIGHT-COLOR: #cccccc;
30. font-family: "????", "Arial", "Helvetica", "sans-serif";
31. font-size:12px;
32.}
33.
34.a:link { FONT-SIZE: 12px;color:#4020a0;text-decoration:none}
35.a:visited { FONT-SIZE: 12px;color:#4020a0;text-decoration:none}
36.a:hover { FONT-SIZE: 12px;color:#FF0000; text-decoration:underline; }
37.
38.td {
39. font-size: 12px;
40.}
41.
42.
43.#gridData{
44. margin-left:2px;
45. margin-top:2px;
46. padding-top:5px;
47. padding-bottom:5px;
48. background-color:#E2F0FE;
49. width: 100%;
50. align:center;
51.}
52.#gridData table {
53. background-color:#7C9CCB;
54. align:center;
55. margin: 5px;
56. width: 98%;
57.}
58.#gridData table tr{
59. font-size: 12px;
60. background-color:#F2F8FE;
61.
62.}
63.#gridData table td{
64. font-size: 12px;
65. AAAAAbackground-color:#F2F8FE;
66.
67.}
68.
69..listtable{
70. WIDTH: 95%;
71.}
72..listtable td{
73. border-top: 1px solid #ffffff;
74. border-bottom: 1px solid #dddddd;
75.
76.}
77..listtabletitle{
78. color:"#4020a0";
79. font-weight:bold;
80. FONT-SIZE: 12px;
81.}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值