Me ajudem a descobrir porque essa página JSP não está funcionando.
Na linha:
<td width=“84%”><input type=“text” name=“tfcodContrato” size=“20” value="<%= codigo %>"></td>
NÃO APARECE O VALOR DA VARIÁVEL CODIGO!!!
Segue abaixo:
[code]<%@ page import="java.sql.*" %>
<%@ page import="java.lang.String" %>
<html>
<body>
<%
Connection con = null;
Statement st = null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (Exception e){
System.out.println("Erro" + e);
}
try{
con = DriverManager.getConnection("jdbc:odbc:Controle_Contratos","","");
}
catch(SQLException k){
System.out.println("Erro" + k);
}
try{
st = con.createStatement();
int codigo;
ResultSet rs = st.executeQuery("select max(codContrato)as codigo from tbContratos");
codigo = rs.getInt("codigo")+1;
st.close();
con.close();
}catch(Exception s){
System.out.println("Erro:" + s);
}
finally{
try{
if(st != null)
st.close();
} catch (SQLException a){}
try{
if(con!= null)
con.close();
}catch(SQLException a){}
}%>
<form method="POST" action="incluirContrato.jsp">
<table>
<tr>
<td width="16%">Código Contrato:</td>
<td width="84%"><input type="text" name="tfcodContrato" size="20" value="<%= codigo %>"></td>
</tr>
<tr>
<td width="16%">Número Contrato:</td>
<td width="84%"><input type="text" name="tfNumContrato" size="20"></td>
</tr>
<tr>
<td width="16%">Fornecedor:</td>
<td width="84%"><input type="text" name="tfFornecedor" size="20"></td>
</tr>
<tr>
<td>Assunto</td>
<td><input type="text" name="tfAssunto" size="20"></td>
</tr>
</table>
<p><input type="submit" value="Enviar" name="btEnviar"><input type="reset" value="Limpar" name="btLimpar"></p>
</form>
</body>
</html>
[/code]Obrigada
[color="#009900"]Alterado para conter o BBCode - CODE[/color]