⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myservlet.java

📁 关于Ultraseek的一些用法,刚初学,所以都是比较简单
💻 JAVA
字号:
/* -*- mode:java; indent-tabs-mode:nil; c-basic-offset:2 -*- * $RCSFile$ $Revision: 1.9 $ $Date: 2006/02/01 00:20:30 $ * No copyright is asserted for this file. */import java.io.*;import java.net.*;import javax.servlet.*;import javax.servlet.http.*;import com.ultraseek.xpa.search.*;/** * This Servlet demonstrates how to customize the standard * <code>SearchServlet</code> for your site's environment. * <p> * The following UI changes, compared to the standard Servlet, * are implemented in this sample file: * <blockquote> * <table border=1> * <tr><td>What</td><td>Why</td><td>How</td><tr> * <tr><td>Do not display the score for a search hit</td> *     <td>Score isn't all that meaningful.</td> *     <td>Override SearchRequest.ShowOneHitScore</td> * </tr> * <tr><td>Do not display the "score bar" for a search hit</td> *     <td>Less cluttered display.</td> *     <td>Override SearchRequest.ShowOneHitScoreBar</td> * </tr> * </table> * </blockquote> * Additionally, this sample overrides <code>getUltraseekURL</code>  * to determine the network location of the Ultraseek * search server to use for query processing. * <p> * Ultraseek recommends you customize <code>SearchServlet</code> * first via the Ultraseek style editor,  * and then by extending the <code>SearchServlet</code> class  * and overriding methods.  Your customizations * will then more easily migrate to future revisions * of Ultraseek server and XPA. * <p> * If modification of <code>SearchServlet</code> is necessary to * make your customizations, we recommend you submit * your <code>SearchServlet</code> modifications to Ultraseek * support for possible inclusion in future XPA releases. * * @version 2.1 * @since XPA2.1 * @serial exclude */public class MyServlet   extends SearchServlet {  /**   * Returns the URL to access the Ultraseek search server.   * The protocol, hostname, and port are used from the URL   * @see SearchServlet#initUltraseek   */  protected URL getUltraseekURL()     throws ServletException {    // This is a sample implementation.    // These values are coming from Servlet Context init variables,         // set in web.xml file.    // Use your own Servlet Container's approach.     String serverName     = getServletConfig().getInitParameter("ServerName");    String serverPort     = getServletConfig().getInitParameter("ServerPort");    String serverProtocol = getServletConfig().getInitParameter("ServerProtocol");    // For demo purposes, use your local server if no server specified    if (serverName==null)     serverName     = "localhost";    if (serverPort==null)     serverPort     = "8765";    if (serverProtocol==null) serverProtocol = "http";    String where = serverProtocol+"://"+serverName+":"+serverPort;    try {      return new URL(where);    } catch (MalformedURLException e) {      throw new ServletException("Malformed Ultraseek server locator: " + where,                                 e);    }  }  public String getServletInfo() {    return MyServlet.class.getName() +      " based on\n" +      super.getServletInfo();  }  /**   * Handle a single search request.   * One instance of <code>SearchRequest</code> is made for   * each search query received.   * Customization of output can be done by overriding   * the methods defined in <code>SearchRequest</code>   */  class SearchRequest    extends SearchServlet.SearchRequest {    public SearchRequest(HttpServletRequest req, HttpServletResponse resp)      throws IOException {      super(req,resp);    };    /**     * Customize output by NOT showing a search result's score.     * This customization could also be applied using      * the Ultraseek style editor.     */    protected void showOneHitScore(SearchResult sr) {      // Do nothing    }    /**     * Customize output by NOT showing a search result's score bar.     * This customization could also be applied using      * the Ultraseek style editor.     */    protected void showOneHitScoreBar(SearchResult sr) {      // Do nothing    }  }  /**   * Override the standard <code>makeSearchRequest</code>, as   * we've customized methods in <code>SearchRequest</code>.   */  protected SearchServlet.SearchRequest makeSearchRequest(HttpServletRequest req,                                                          HttpServletResponse resp)     throws IOException {    return new MyServlet.SearchRequest(req,resp);  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -