NullPointerException IMPOSSIVEL!

Caros amigos, tenho um problema aqui e gostaria que vcs me ajudassem.Estou fazendo um programa simples de cadastro de imóveis(coisa de facu) cujo código é bem parecido com outro que deu certo(na verdade mudei poucas coisas).No entanto o programa insiste em acusar uma NullPointerException que NÃO CONSIGO DESCOBRIR ONDE ESTÁ.Vou mandar o código do programa e o do BD(POSTGRES)
Agradeceria se alguem me ajudasse!!!



import java.sql.*;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * Servlet implementation class questao2bd
 */
public class CadastroImovel extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
	private int codigo=0;
	private double valor=0.00;
	private String descricao="";
	private String nome="";
	private String tipo="";
	
    public CadastroImovel() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		  
	}
	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");//configuração da linguagem: HTML
        PrintWriter out = response.getWriter();
        
    out.println("<HTML><BODY><h2>");
    out.println("Cadastro de Imóveis");
	out.println("</span></h2><BODY><HTML>");

    String url    = "jdbc:postgresql://localhost:5432/imoveis";
	String driver = "org.postgresql.Driver"; //variáveis usadas na conexao com postgres!
	Connection con=null; //objeto da clasee Connection usado na conexao!
	
	try {
		//para conexao com BD deve-se sempre usar um try.
		    Class.forName(driver);//método Class.forname(driver a ser utilizado: MySql ou Postgres)
		    con = DriverManager.getConnection(url,"postgres","postgres");//parâmetros do metodo getConnection(url,user,password)
		}catch(SQLException ex){
			//excessões da clasee java.sql.*;
		}
		catch(java.lang.Exception ex){
			//excessões da classe java.lang.*;
		}
	
	try{//inserindo dados no Banco de Dados
		
	 codigo= Integer.parseInt(request.getParameter("codigo"));
	 nome= request.getParameter("nome");
     valor=Double.parseDouble(request.getParameter("valor"));
     descricao= request.getParameter("descricao");
     tipo= request.getParameter("tipo");
     
        out.println("<h1>DADOS DO IMÓVEL</h1><br>");
    
	    out.println("<table border='1' cellpadding='1' cellspacing='1' bgcolor='#808080' width='800'>");
        out.println("<tr>");
        out.println("<td><font color='#FFFFFF' face='Verdana'><strong>CÓDIGO</strong></font></td>");
        out.println("<td><font color='#FFFFFF' face='Verdana'><strong>NOME</strong></font></td>");
        out.println("<td><font color='#FFFFFF' face='Verdana'><strong>VALOR</strong></font></td>");
        out.println("<td><font color='#FFFFFF' face='Verdana'><strong>DESCRIÇÃO</strong></font></td>");
        out.println("<td><font color='#FFFFFF' face='Verdana'><strong>TIPO</strong></font></td>");
        out.println("</tr>");
        
	   //parte dinâmica do html
          out.println("<tr>");
	   	  out.println("<td><font face='Verdana'>"+codigo+"</td>");
          out.println("<td><font face='Verdana'>"+nome+"</td>");
          out.println("<td><font face='Verdana'>R$"+valor+"</td>");
          out.println("<td><font face='Verdana'>"+descricao+"</td>");
          out.println("<td><font face='Verdana'>"+tipo+"</td>");
          out.println("</tr>");
        
  	 Statement statement = con.createStatement();//cria um objeto statement para a conexao
  	 
	 ResultSet result = statement.executeQuery("select * from imovel where codigo =" + codigo);
	 
	 if(result.next() == true){//se houver um ra já cadastrado com mesmo número,volta para a página inicial
		 out.println("CÓDIGO JÁ CADASTRADO! DIGITE OUTRO CÓDIGO!");
		 out.println("<p><a href=index.jsp><strong>Início</strong></a></p>");
	 }else{
	 
        boolean res = statement.execute("INSERT INTO imovel  (codigo,nome,valor, descricao,tipo) VALUES ("+codigo+",'"+nome+"',"+ valor +",'"+descricao+"','"+tipo+"')");
        statement.close();//excute é para usar em objetos BOOLEAN 
          con.close(); // Fecha a conexão com o Banco de Dados
                    
          out.println("<br>Dados Cadastrados com Sucesso<br><br>");
          
          out.println("<p><a href=index.jsp><strong>Início</strong></a></p>");
          out.println("<p><a href=RemoveImovel.jsp><strong>Excluir</strong></a></p>");
         //getServletContext().getRequestDispatcher(response.encodeURL("/questao2.jsp")).forward(request, response);
    
	}
	}catch(SQLException ex){
	  out.println("<p><h3 align = CENTER>Problemas com o banco de Dados!</h3></p>");
	  out.println(ex);
		}catch(NumberFormatException ex){
			//excessões da classe java.lang.*;
			out.println("<p><h3 align = CENTER>Problemas com o formato de Dados!</h3></p>");
			out.println(ex);
		}catch(java.lang.Exception	ex){
			//excessões da classe java.lang.*;
			out.println("<p><h3 align = CENTER>Problemas com o formato de Dados!</h3></p>");
			out.println(ex);
	}finally {
        out.close();
    }
	
	}
		

}

Banco de Dados IMOVEIS E TABELA IMOVEL

[code]
CREATE DATABASE IMOVEIS

CREATE TABLE imovel
(
codigo integer NOT NULL,
nome character varying(30) NOT NULL,
valor numeric(10,2) NOT NULL,
descricao character varying(100) NOT NULL,
tipo character varying(20) NOT NULL,
CONSTRAINT imovel_pkey PRIMARY KEY (codigo)
)[/code]

Todos os campos do JSP referente estão certos e com os formatos certos!! AJUDEM!!

manda a stacktrace… fica mais fácil

Putz cara, desculpa mas nao sei como mandar a stacktrace…vc pode me ajudar?

quando dá o erro aparece um bloco no seu console, mostrando a exceção que foi lançada…

copia ela do console e joga aqui :slight_smile: tem informações valiosas ali hehehe

30/03/2012 23:21:53 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre6\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:/Program Files/Java/jre6/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\WIDCOMM\Bluetooth Software;D:\Meus Documentos\FACU\SOFTWARES\ECLIPSE\eclipse;;.
30/03/2012 23:21:54 org.apache.tomcat.util.digester.SetPropertiesRule begin
AVISO: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ‘source’ to ‘org.eclipse.jst.jee.server:aula5’ did not find a matching property.
30/03/2012 23:21:54 org.apache.tomcat.util.digester.SetPropertiesRule begin
AVISO: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ‘source’ to ‘org.eclipse.jst.jee.server:Atividade_webN1’ did not find a matching property.
30/03/2012 23:21:54 org.apache.tomcat.util.digester.SetPropertiesRule begin
AVISO: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ‘source’ to ‘org.eclipse.jst.jee.server:UsuarioLoginSimples’ did not find a matching property.
30/03/2012 23:21:54 org.apache.tomcat.util.digester.SetPropertiesRule begin
AVISO: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ‘source’ to ‘org.eclipse.jst.jee.server:HTML_CSS’ did not find a matching property.
30/03/2012 23:21:54 org.apache.tomcat.util.digester.SetPropertiesRule begin
AVISO: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ‘source’ to ‘org.eclipse.jst.jee.server:Atividade2_webN1’ did not find a matching property.
30/03/2012 23:21:54 org.apache.tomcat.util.digester.SetPropertiesRule begin
AVISO: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ‘source’ to ‘org.eclipse.jst.jee.server:site1’ did not find a matching property.
30/03/2012 23:21:54 org.apache.tomcat.util.digester.SetPropertiesRule begin
AVISO: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ‘source’ to ‘org.eclipse.jst.jee.server:JSP_COM_BD’ did not find a matching property.
30/03/2012 23:21:54 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
30/03/2012 23:21:54 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1887 ms
30/03/2012 23:21:54 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
30/03/2012 23:21:54 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.33
30/03/2012 23:21:56 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
30/03/2012 23:21:56 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
30/03/2012 23:21:56 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/96 config=null
30/03/2012 23:21:56 org.apache.catalina.startup.Catalina start
INFO: Server startup in 2080 ms

Não parece mostrar erro…

Aonde você viu que está sendo lançada uma NullPointerException?

Camarada, só acusa o NullPointerException quando compila e dá o resultado…eu queria postar o print da tela mas não consigo, como faço? acho q ficaria melhor.

Tu mando o stacktrace da inicialização da aplicação…

Afinal… onde aparece ou teu “NullPointerException” …
Pois e for realmente um NullPointerException ele aparecerá no stacktrace da aplicação…
Agora…se for outra coisa…aí já muda a questão

Cara…ta dificil pq nao acusa no stacktrace,como disse so quando mostra os dados na tabela resultado que ele acusa…se eu puder botar o print vc poderia ver…posse te mandar por email se vc quiser.

try { //para conexao com BD deve-se sempre usar um try. Class.forName(driver);//método Class.forname(driver a ser utilizado: MySql ou Postgres) con = DriverManager.getConnection(url,"postgres","postgres");//parâmetros do metodo getConnection(url,user,password) }catch(SQLException ex){ //excessões da clasee java.sql.*; } catch(java.lang.Exception ex){ //excessões da classe java.lang.*; }

esse ponto seu é perigoso, se estiver dando uma exceção, não vai carregar o con, e dará nullpointerexception em pontos que vc usar o con, tente pelo menos exibir a stack no com o
comando abaixo

try { //para conexao com BD deve-se sempre usar um try. Class.forName(driver);//método Class.forname(driver a ser utilizado: MySql ou Postgres) con = DriverManager.getConnection(url,"postgres","postgres");//parâmetros do metodo getConnection(url,user,password) }catch(SQLException ex){ //excessões da clasee java.sql.*; ex.printStackTrace(); } catch(java.lang.Exception ex){ ex.printStackTrace(); }