title: Importing classes from External JAR files in JSP
body: <p>To search in the Lucene index I caught the query of an user by a Web User Interface in JSP. In JSP, I have written  short JAVA code to parse the query and  call the Lucene index searcher to search for the query. But the problem is that it is repeatedly giving compilation error as "Query cannot be resolved, MultiFieldQueryParser cannot be resolved ...". So none of the Lucene classes are getting resolved. The code is as follows:</p>
  
  <p>File name : result.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.util.*,java.io.*,org.apache.lucene.*" %&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;%! String query; %&gt;
  &lt;%
      query=request.getParameter("myQuery");
  %&gt;
  &lt;form name="frm" method="post" action="result.jsp"&gt;
  &lt;table width="100%" border="0" cellspacing="0" cellpadding="0"&gt;
  &lt;tr&gt;
  &lt;td width="22%"&gt;&amp;nbsp;&lt;/td&gt;
  &lt;td width="78%"&gt;&amp;nbsp;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;&amp;nbsp; &lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="myQuery" placeholder="Type here"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;&amp;nbsp;&lt;/td&gt;
  &lt;td&gt;&lt;input type="submit" name="submit" value="Submit"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;&amp;nbsp;&lt;/td&gt;
  &lt;td&gt;&amp;nbsp;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/form&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;%
    Directory dir=new FSDirectory.open(new File(path of index directory));
    QueryParser parser=new MultiFieldQueryParser(Version.LUCENE_30, new String[] 
    {"title","address","city"},new BooleanClause.Occur[]{BooleanClause.Occur.MUST,
    BooleanClause.Occur.SHOULD, BooleanCaluse.Occur.SHOULD},new StandardAnalyzer());
    Query query=parser.parse(query);
    IndexSearcher searcher=new Indexsearcher(dir,true);
    TopDocs hits=searcher.search(query,20);
    searcher.close();
    dir.close();
  %&gt;
  &lt;p&gt;Query phrase is : &lt;%=query%&gt;&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I cannot understand why any of the classes of Lucene are not getting resolved even after importing Lucene above. So I am asking whether anyone can please help me to fix the above code. Thank you.</p>