title: Configure Tomcat so that I can connect a JSP page to MySQL
body: <p>I need to connect to a MySQL database from a JSP page by using the <code>DriverManager.getConnection()</code> method. I have placed the MySQL Connector-J JAR file in the Tomcat lib. I have run the same code as a normal Java application and it works, which makes me think that there is an issue with Tomcat. I am getting many exceptions, the first one being <code>ClassNotFoundException</code>, followd by many <code>JasperException</code>.</p>
  
  <p>Could you tell me the steps I will need to follow in configuring the servlet to interact with MySQL from JSP page?</p>
  
  <hr>
  
  <p><strong>Update</strong>: I have tried putting in the lib folder of Tomcat install root as well as the <code>/WEB-INF/lib</code>, but the problem persists. The jar file name is <code>mysql-connector-java-5.1.13-bin.jar</code>. Is this the right one?</p>
  
  <p>Here is the exception I am getting</p>
  
  <pre><code>java.lang.ClassNotFoundException: com.mysql.jdbc.driver
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
      at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:128)
      at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:169)
      at org.apache.jsp.index_jsp._jspService(index_jsp.java:75)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
      at java.lang.Thread.run(Thread.java:619)
  </code></pre>