response.sendRedirect not working
- by Amar
response.sendRedirect method is not working in my program.
String id="java";
try {
query = "select Id from Users where Id= ?";
ps =Database.getConnection().prepareStatement(query);
ps.setString(1, id);
rs = ps.executeQuery();
if(rs.next()){
out.println(rs.getString(1));
}else {
//out.println("wrong user");
response.sendRedirect("www.google.com");
}
rs.close();
}catch(Exception e){
//e.printStackTrace();
System.out.print(e);
}
form the above i commented "out.println("wrong user");". when i remove this comment it works. but no redirect to the google page.
Any answers?