2 Licensed to the Apache Software Foundation (ASF) under one or more
3 contributor license agreements. See the NOTICE file distributed with
4 this work for additional information regarding copyright ownership.
5 The ASF licenses this file to You under the Apache License, Version 2.0
6 the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
17 <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
18 import="org.apache.lucene.search.*,org.apache.lucene.document.*"
19 pageEncoding="ISO-8859-1"%>
20 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
23 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
24 <link rel="stylesheet" type="text/css" href="stylesheet.css">
25 <title>XML Query Parser demo</title>
30 // Load form variables
31 String description=request.getParameter("description");
32 String type=request.getParameter("type");
33 String salaryRange=request.getParameter("salaryRange");
35 <form method="POST" action="FormBasedXmlQueryDemo">
38 <th class="formHeader">Description</th>
40 <input name="description" value="<%=description==null?"":description%>"/>
44 <th class="formHeader">Type</th>
47 <option value="" <%=type==null?"selected":""%>>Any</option>
48 <option value="Contract" <%="Contract".equals(type)?"selected":""%>>Contract</option>
49 <option value="Permanent" <%="Permanent".equals(type)?"selected":""%>>Permanent</option>
54 <th class="formHeader">Salary</th>
56 <select name="salaryRange">
57 <option value="" <%=salaryRange==null?"selected":""%>>Any</option>
59 String ranges[]={"20","30","40", "50","60","70","80","90","100","110","120","150","200"};
60 for(int i=1;i<ranges.length;i++)
62 String rangeText=ranges[i-1]+"-"+ranges[i];
64 <option value="<%=rangeText%>" <%=rangeText.equals(salaryRange)?"selected":""%>><%=ranges[i-1]%> to <%=ranges[i]%>k</option>
73 <th class="formHeader">Locations</th>
76 String locs[]={"South","North","East","West"};
77 boolean allLocsBlank=true;
78 for(int i=0;i<locs.length;i++)
80 if(request.getParameter(locs[i])!=null)
85 for(int i=0;i<locs.length;i++)
88 <input id='cb<%=locs[i]%>'
91 if((allLocsBlank)||("on".equals(request.getParameter(locs[i])))) {
97 <label for="cb<%=locs[i]%>"><%=locs[i]%></label>
107 <input type="submit" value="search"/>
113 Document[] results=(Document[])request.getAttribute("results");
119 <th class="resultsHeader">Type</th>
120 <th class="resultsHeader">Location</th>
121 <th class="resultsHeader">Salary</th>
122 <th class="resultsHeader">Description</th>
125 for (int i = 0; i < results.length; i++)
127 Document doc = results[i];
129 <tr class="resultsRow">
130 <td><%=doc.get("type")%></td>
131 <td><%=doc.get("location")%></td>
132 <td class="resultNum"><%=doc.get("salary")%>,000</td>
133 <td><%=doc.get("description")%></td>
142 }//end if has results