title: JSP JasperException
body: <p>So I have an SQL query and I want to select data from a database but I am getting a strange exception I do know less about it. Note that I am new to JSPs.</p>
  
  <p>I have this file called selectform.jsp where I want to take data from a database and display it in a table:</p>
  
  <pre><code>&lt;%@ page import="java.io.*,java.util.*,java.sql.*"%&gt;
  &lt;%@ page import="javax.servlet.http.*,javax.servlet.*"%&gt;
  &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%&gt;
  &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%&gt;
  &lt;%@ page extends="proiect.Database"%&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Select&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;%
          String query = "SELECT * FROM arhiva ORDER BY id";
          try {
              Statement stmt = con.createStatement();
              ResultSet rs = stmt.executeQuery(query);
      %&gt;
  
      &lt;table border=1&gt;
          &lt;tbody&gt;
              &lt;tr&gt;
                  &lt;th&gt;ID&lt;/th&gt;
                  &lt;th&gt;Nume&lt;/th&gt;
                  &lt;th&gt;Prenume&lt;/th&gt;
              &lt;/tr&gt;
              &lt;%
                  while (rs.next()) {
              %&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;%=rs.getString("id")%&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;%=rs.getString("nume")%&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;%=rs.getString("prenume")%&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;%
                  }
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
              %&gt;
  
          &lt;/tbody&gt;
      &lt;/table&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Note that I am taking stuff from a Database.java file in the proiect package with the following line "&lt;%@ page extends="proiect.Database"%>".
  That file looks like:</p>
  
  <pre><code>package proiect;
  
  import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.PreparedStatement;
  import java.sql.ResultSet;
  
  import javax.servlet.ServletConfig;
  import javax.servlet.ServletException;
  import javax.servlet.UnavailableException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.jsp.HttpJspPage;
  
  public abstract class Database extends HttpServlet implements HttpJspPage {
      private static final long serialVersionUID = 1L;
  
      protected Connection con;
      protected String driver = "org.postgresql.Driver";
      protected String url = "jdbc:postgresql://localhost:5200/postgres";
      protected String user = "postgres";
      protected String pass = "test";
      Connection connection = null;
      ResultSet resultSet = null;
      PreparedStatement preparedStatement = null;
      String query = null;
  
      public void init(ServletConfig config) throws ServletException {
          super.init(config);
          try {
              Class.forName(driver);
              con = DriverManager.getConnection(url, user, pass);
          } catch (Exception e) {
              throw new UnavailableException(e.getMessage());
          }
  
          jspInit();
      }
  
  }
  </code></pre>
  
  <p>And when I try to run that selectform.jsp, I get the following stacktrace:</p>
  
  <pre><code>Jan 12, 2015 11:58:28 AM org.apache.catalina.core.StandardWrapperValve invoke
  SEVERE: Servlet.service() for servlet [jsp] in context with path [/Project] threw exception [Unable to compile class for JSP: 
  
  An error occurred at line: [20] in the generated java file: [E:\Eclipse\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\Project\org\apache\jsp\selectform_jsp.java]
  The type selectform_jsp must implement the inherited abstract method JspPage.jspInit()
  
  An error occurred at line: [20] in the generated java file: [E:\Eclipse\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\Project\org\apache\jsp\selectform_jsp.java]
  The type selectform_jsp must implement the inherited abstract method JspPage.jspDestroy()
  
  Stacktrace:] with root cause
  org.apache.jasper.JasperException: Unable to compile class for JSP: 
  
  An error occurred at line: [20] in the generated java file: [E:\Eclipse\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\Project\org\apache\jsp\selectform_jsp.java]
  The type selectform_jsp must implement the inherited abstract method JspPage.jspInit()
  
  An error occurred at line: [20] in the generated java file: [E:\Eclipse\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\Project\org\apache\jsp\selectform_jsp.java]
  The type selectform_jsp must implement the inherited abstract method JspPage.jspDestroy()
  
  Stacktrace:
      at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
      at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:366)
      at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:485)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:379)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:341)
      at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:657)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>selectform_jsp.java:</p>
  
  <pre><code>/*
   * Generated by the Jasper component of Apache Tomcat
   * Version: Apache Tomcat/7.0.56
   * Generated at: 2015-01-12 09:58:28 UTC
   * Note: The last modified time of this file was set to
   *       the last modified time of the source file after
   *       generation to assist with modification tracking.
   */
  package org.apache.jsp;
  
  import javax.servlet.*;
  import javax.servlet.http.*;
  import javax.servlet.jsp.*;
  import java.io.*;
  import java.util.*;
  import java.sql.*;
  import javax.servlet.http.*;
  import javax.servlet.*;
  
  public final class selectform_jsp extends proiect.Database
      implements org.apache.jasper.runtime.JspSourceDependent {
  
    private static final javax.servlet.jsp.JspFactory _jspxFactory =
            javax.servlet.jsp.JspFactory.getDefaultFactory();
  
    private static java.util.Map&lt;java.lang.String,java.lang.Long&gt; _jspx_dependants;
  
    private javax.el.ExpressionFactory _el_expressionfactory;
    private org.apache.tomcat.InstanceManager _jsp_instancemanager;
  
    public java.util.Map&lt;java.lang.String,java.lang.Long&gt; getDependants() {
      return _jspx_dependants;
    }
  
    public void _jspInit() {
      _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
      _jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig());
    }
  
    public void _jspDestroy() {
    }
  
    public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)
          throws java.io.IOException, javax.servlet.ServletException {
  
      final javax.servlet.jsp.PageContext pageContext;
      javax.servlet.http.HttpSession session = null;
      final javax.servlet.ServletContext application;
      final javax.servlet.ServletConfig config;
      javax.servlet.jsp.JspWriter out = null;
      final java.lang.Object page = this;
      javax.servlet.jsp.JspWriter _jspx_out = null;
      javax.servlet.jsp.PageContext _jspx_page_context = null;
  
  
      try {
        response.setContentType("text/html");
        pageContext = _jspxFactory.getPageContext(this, request, response,
                  null, true, 8192, true);
        _jspx_page_context = pageContext;
        application = pageContext.getServletContext();
        config = pageContext.getServletConfig();
        session = pageContext.getSession();
        out = pageContext.getOut();
        _jspx_out = out;
  
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("&lt;html&gt;\r\n");
        out.write("&lt;head&gt;\r\n");
        out.write("&lt;title&gt;Select&lt;/title&gt;\r\n");
        out.write("&lt;/head&gt;\r\n");
        out.write("&lt;body&gt;\r\n");
        out.write("\t");
  
          String query = "SELECT * FROM arhiva ORDER BY id";
          try {
              Statement stmt = con.createStatement();
              ResultSet rs = stmt.executeQuery(query);
  
        out.write("\r\n");
        out.write("\r\n");
        out.write("\t&lt;table border=1&gt;\r\n");
        out.write("\t\t&lt;tbody&gt;\r\n");
        out.write("\t\t\t&lt;tr&gt;\r\n");
        out.write("\t\t\t\t&lt;th&gt;ID&lt;/th&gt;\r\n");
        out.write("\t\t\t\t&lt;th&gt;Nume&lt;/th&gt;\r\n");
        out.write("\t\t\t\t&lt;th&gt;Prenume&lt;/th&gt;\r\n");
        out.write("\t\t\t&lt;/tr&gt;\r\n");
        out.write("\t\t\t");
  
                  while (rs.next()) {
  
        out.write("\r\n");
        out.write("\t\t\t&lt;tr&gt;\r\n");
        out.write("\t\t\t\t&lt;td&gt;");
        out.print(rs.getString("id"));
        out.write("&lt;/td&gt;\r\n");
        out.write("\t\t\t\t&lt;td&gt;");
        out.print(rs.getString("nume"));
        out.write("&lt;/td&gt;\r\n");
        out.write("\t\t\t\t&lt;td&gt;");
        out.print(rs.getString("prenume"));
        out.write("&lt;/td&gt;\r\n");
        out.write("\t\t\t&lt;/tr&gt;\r\n");
        out.write("\t\t\t");
  
                  }
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
  
        out.write("\r\n");
        out.write("\r\n");
        out.write("\t\t&lt;/tbody&gt;\r\n");
        out.write("\t&lt;/table&gt;\r\n");
        out.write("\r\n");
        out.write("&lt;/body&gt;\r\n");
        out.write("&lt;/html&gt;");
      } catch (java.lang.Throwable t) {
        if (!(t instanceof javax.servlet.jsp.SkipPageException)){
          out = _jspx_out;
          if (out != null &amp;&amp; out.getBufferSize() != 0)
            try {
              if (response.isCommitted()) {
                out.flush();
              } else {
                out.clearBuffer();
              }
            } catch (java.io.IOException e) {}
          if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
          else throw new ServletException(t);
        }
      } finally {
        _jspxFactory.releasePageContext(_jspx_page_context);
      }
    }
  }
  </code></pre>
  
  <p>Where is the issue? I don't understand why I'm getting an error. Thank you in advance, SO!</p>