Hi Ilya,

I was looking at my local directory sorry about that.

I am just going to attach what I have since it has a dependency on a
property file which I haven't create yet.

This is a servlet which you will have to have your JSP/Servlet engine load
at startup.

Put the code in your web.xml class for your local app.

    <servlet>
        <servlet-name>Lucene Index Loader</servlet-name>
   <servlet-class>org.apache.lucene.servlet.IndexLoader.java</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

I hope this helps.

--Peter

On 7/5/02 5:58 AM, "Ilya Khandamirov" <[EMAIL PROTECTED]> wrote:

> Hi Peter,
> 
>> there is a sample servlet in the servelet directory of the SearchBean
> contribution
> 
> Are you sure? This directory (servlet) is empty:
> http://cvs.apache.org/viewcvs/jakarta-lucene-sandbox/contributions/searc
> hbean/src/java/org/apache/lucene/servlet/
> 
> Could you please provide me with the sample servlet?
> 
> Thank you.
> 
> Regards,
> Ilya
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 
> 

Attachment: IndexLoader.java
Description: application/applefile

/*
 * FirstQueryLoad.java
 *
 * Created on January 2, 2002, 4:46 PM
 * Used to load indexes into memory
 */

package org.apache.lucene.servlet;

import javax.servlet.*;
import javax.servlet.http.*;

import java.util.Properties;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import org.apache.lucene.index.IndexReader;
import org.apache.lucene.document.Document;
import org.apache.lucene.beans.SortedField;


/**
 *
 * @author  Peter Carlson
 * @version
 */
public class IndexLoader extends HttpServlet {
        
    /** Initializes the servlet.
     */
    public void init(ServletConfig config) throws ServletException {
        super.init(config);
        ServletContext sc = config.getServletContext();
        String realPath = sc.getRealPath("/");

        
        try{
            FileInputStream fis = new FileInputStream 
(realPath+"/WEB-INF/"+"lucene.properties");
            Properties props = new Properties();
            props.load(fis);
            
            long first = System.currentTimeMillis();
            String indexPath = realPath+props.getProperty("articlesIndexPath");
            
            SortedField.addField("pubDate",indexPath);
        }
        catch (FileNotFoundException fnfe) {
           // logger.fatal("FileNotFoundException, cannot find startup properties");
           // logger.fatal(fnfe.getMessage());
        }
        catch (IOException ioe){
           // logger.fatal("IOException, loading startup properties");
           // logger.fatal(ioe.getMessage());
        }
        
    }
    
    /** Destroys the servlet.
     */
    public void destroy() {
        
    }
    
    /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> 
methods.
     * @param request servlet request
     * @param response servlet response
     */
    protected void processRequest
    (HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
        response.setContentType("text/html");
        java.io.PrintWriter out = response.getWriter();
        /* output your page here
        out.println("<html>");
        out.println("<head>");
        out.println("<title>Servlet</title>");
        out.println("</head>");
        out.println("<body>");
         
        out.println("</body>");
        out.println("</html>");
         */
        out.close();
    }
    
    /** Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
        processRequest(request, response);
    }
    
    /** Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
        processRequest(request, response);
    }
    
    /** Returns a short description of the servlet.
     */
    public String getServletInfo() {
        return "Startup servlet";
    }
    
}
--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to