if (request.getParameter("search") != null) {
String keyword = request.getParameter("keyword");
if (keyword == null || keyword.length() == 0) {
return new ModelAndView("Error", "message", "Please enter a keyword to search for, then press the search button.");
}
else {
ConfigBean cfg = new ConfigBean();
String indexpath = "";
try
{
indexpath = cfg.getCurIndexPath();
}
catch(Exception ex)
{
return new ModelAndView("Error", "message", "Could not find current index path.");
}
QueryBean qb = new QueryBean("D:/@Tools/jakarta-tomcat-5.0.18/webapps/SiteSearch/WEB-INF/index.0", keyword, "contents");
qb.execute();
HashMap hits = new HashMap(qb.getResults().length);
for(int i =0;i<qb.getResults().length;i++)
{
hits.put("hits", qb.getResults());
}
return new ModelAndView("SearchProducts", hits);
//return new ModelAndView("Error", "message", "QB Total: " + qb.getResults().length + " and hits: " + hits.size());
}
}
else {
String page = request.getParameter("page");
PagedListHolder productList = (PagedListHolder) request.getSession().getAttribute("SearchProductsController_productList");
if ("next".equals(page)) {
productList.nextPage();
}
else if ("previous".equals(page)) {
productList.previousPage();
}
return new ModelAndView("SearchProducts", "productList", productList);
}