title: JSP not finding a JDBC driver present in my WEB-INF/lib and in the build path
body: <p>Good Morning,</p>
  
  <p>Here is my JSP code (note, it is just a slightly modified source from the Oracle Sample Application page here: <a href="http://docs.oracle.com/cd/A97336_01/buslog.102/a83726/sampapp2.htm" rel="nofollow">http://docs.oracle.com/cd/A97336_01/buslog.102/a83726/sampapp2.htm</a>)</p>
  
  <pre><code>&lt;%@ page import="java.sql.*" %&gt;
  
  &lt;HTML&gt;
  &lt;HEAD&gt; &lt;TITLE&gt; The JDBCQuery JSP  &lt;/TITLE&gt; &lt;/HEAD&gt;
  &lt;BODY BGCOLOR=white&gt;
  
  &lt;% String searchCondition = request.getParameter("cond"); 
  if (searchCondition != null) { %&gt;
    &lt;H3&gt; Search results for : &lt;I&gt; &lt;%= searchCondition %&gt; &lt;/I&gt; &lt;/H3&gt;
    &lt;%= runQuery(searchCondition) %&gt;
    &lt;HR&gt;&lt;BR&gt;
    &lt;% }  %&gt;
  
  &lt;B&gt;Enter a search condition:&lt;/B&gt;
  &lt;FORM METHOD=get&gt; 
  &lt;INPUT TYPE="text" NAME="cond" SIZE=30&gt;
  &lt;INPUT TYPE="submit" VALUE="Ask Oracle"&gt;
  &lt;/FORM&gt;
  &lt;/BODY&gt;
  &lt;/HTML&gt;
  &lt;%! 
   private String runQuery(String cond) throws SQLException {
  Connection conn = null; 
   Statement stmt = null; 
   ResultSet rset = null; 
   try {
      DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
      conn = DriverManager.getConnection((String)session.getAttribute  ("url"),
                                               "username", "pw");
            stmt = conn.createStatement();
            rset = stmt.executeQuery ("SELECT ename, sal FROM scott.emp "+ 
                                      (cond.equals("") ? "" : "WHERE " + cond ));
           return (formatResult(rset));
        } catch (SQLException e) { 
            return ("&lt;P&gt; SQL error: &lt;PRE&gt; " + e + " &lt;/PRE&gt; &lt;/P&gt;\n");
        } finally {
                 if (rset!= null) rset.close(); 
                 if (stmt!= null) stmt.close();
                 if (conn!= null) conn.close();
        }
          }
  
     private String formatResult(ResultSet rset) throws SQLException {
       StringBuffer sb = new StringBuffer();
       if (!rset.next())      
         sb.append("&lt;P&gt; No matching rows.&lt;P&gt;\n");
       else {  sb.append("&lt;UL&gt;&lt;B&gt;"); 
            do {  sb.append("&lt;LI&gt;" + rset.getString(1) + 
                               " earns $ " + rset.getInt(2) + ".&lt;/LI&gt;\n");
               } while (rset.next());
            sb.append("&lt;/B&gt;&lt;/UL&gt;"); 
       }
       return sb.toString();
     }
   %&gt;
  </code></pre>
  
  <p>The error occurs on lines:</p>
  
  <pre><code>    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
      conn = DriverManager.getConnection((String)session.getAttribute("url"),
                                               "username", "pw");
  </code></pre>
  
  <p>where session throws an exception. Note that in the oracle code getValue is used instead of getAttribute, but get Value is depreciated. I've tried using a Class.forName() statement; however, this does not seem to solve the problem. Is there anything I have overlooked in this code? Any help would be greatly appreciated. Im using ojdbc14.jar package.</p>
  
  <p>Edited to include error:</p>
  
  <pre><code>org.apache.jasper.JasperException: Unable to compile class for JSP: 
  
  An error occurred at line: 28 in the jsp file: /PGS/JDBCQuery.jsp
  session cannot be resolved
   25:      ResultSet rset = null; 
   26:      try {
   27:         DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
   28:      conn = DriverManager.getConnection((String)session.getAttribute       ("url"),
   29:                                            "username", "pw");
   30:         stmt = conn.createStatement();
   31:         rset = stmt.executeQuery ("SELECT ename, sal FROM scott.emp"+ 
  </code></pre>