I'm trying this for get the id user and display in a jsp :
public int getId(String user){
Statement st = null;
ResultSet rs = null;
try{
st = getConexion().createStatement();
String consulta = "select idperson from person where nombre='"+user+"'";
rs = st.executeQuery(consult);
if(rs.next()){
int id = rs.getInt("idperson");
retu id;
}
}catch(Exception e)
{
System.err.println("error: "+e);
}
}
This is my code from the jsp:
<%
HttpSession objsesion = request.getSession(false);
String user= (String)objsesion.getAttribute("name");
%>
Then call my function:
<%Consult iduser = new Consult();
iduser.getId(user);%>
