I'm trying to create a web application and want to use java and html. Well after all set up and ready for a little connection test the following error occurs:
Fev 09, 2016 1:28:02 PM org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: Servlet.service() for servlet [jsp] in context with path [/TesteTemplateImport] threw exception [java.lang.NullPointerException] with root cause
java.lang.NullPointerException
at org.apache.jsp.main_jsp._jspService(main_jsp.java:190)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1526)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1482)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
I'm a beginner and have never created a web application, here's my algorithm for connecting to the bank:
package teste;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class Conexao {
static final String JDBC_DRIVER = "org.firebirdsql.jdbc.FBDriver";
static final String DB_URL = "jdbc:firebirdsql:192.168.1.225/3050:D:/Dados/Suporte/Sisplan/Base/Belfast.GDB?sql_dialect=3";
static final String USER = "SYSDBA";
static final String PASS = "masterkey";
public static Connection getConexao() throws SQLException {
try {
Class.forName(JDBC_DRIVER);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return DriverManager.getConnection(DB_URL, USER, PASS);
}
}
It has a small detail that I believe I should mention, this error occurs not the moment I start the server. It starts the application running in eclipse, I go to the web browser I type the address of the server, it opens the page but when I run a select ai yes the error log appears.
This is my code inside the html page:
<%@ page import="teste.Conexao" %>
<%@ page import="teste.UsuarioDao" %>
<%@ page import="teste.Usuario" %>
<%
UsuarioDao udao = new UsuarioDao();
Usuario usuario = (Usuario) udao.buscar("12345678");
out.print(usuario.getNome());
%>
Here is my select:
public Usuario buscar(String rg) {
conectar();
String sql = "SELECT nome FROM ENTIDADE_001 WHERE CODCLI = " + rg;
try {
ResultSet rs = st.executeQuery(sql);
while (rs.next()) {
String rG = rs.getString("rg");
String nome = rs.getString("nome");
pessoa = new Usuario(rG, nome);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
desconectar();
}
return pessoa;
}
And yes. I already added the correct .jar with the same version of my jdk and my environment variable HAVA_HOME has no blanks and is pointing correctly to my jdk folder.