Below is the part of code from my jsp page, when I am printing the rs.getString(1)is printing perfectly but as soon as i put the rs.getString(1) in if block it shows the null pointer exception. Please help
String nam=request.getParameter("n");
String query = "select name from ques where username='"+userid+"'";
Statement st=con.prepareStatement(query);
ResultSet rs = st.executeQuery(query);
while(rs.next()){
out.println(rs.getString(1));
if(rs.getString(1).equals(nam)){
out.print("hello");
}
}