1 25 package org.snipsnap.net; 26 27 import org.apache.lucene.search.Hits; 28 import org.snipsnap.snip.SnipLink; 29 import org.snipsnap.snip.SnipSpace; 30 import org.snipsnap.snip.SnipSpaceFactory; 31 import org.snipsnap.config.Configuration; 32 import org.snipsnap.app.Application; 33 34 import javax.servlet.RequestDispatcher ; 35 import javax.servlet.ServletException ; 36 import javax.servlet.http.HttpServlet ; 37 import javax.servlet.http.HttpServletRequest ; 38 import javax.servlet.http.HttpServletResponse ; 39 import javax.servlet.http.HttpSession ; 40 import java.io.IOException ; 41 42 47 public class SnipSearchServlet extends HttpServlet { 48 49 public void doPost(HttpServletRequest request, HttpServletResponse response) 50 throws IOException , ServletException { 51 String query = request.getParameter("query"); 52 if (query != null && query.length() > 0) { 53 HttpSession session = request.getSession(); 54 SnipSpace space = SnipSpaceFactory.getInstance(); 55 Hits hits = space.search(query); 56 session.setAttribute("query", query); 57 session.setAttribute("hits", hits); 58 session.setAttribute("startIndex", new Integer (0)); 59 RequestDispatcher dispatcher = request.getRequestDispatcher("/exec/search.jsp"); 60 dispatcher.forward(request, response); 61 return; 62 } 63 64 Configuration config = Application.get().getConfiguration(); 65 response.sendRedirect(config.getUrl()); 66 } 67 68 } 69 | Popular Tags |