response.sendRedirect not working

Posted by Amar on Stack Overflow See other posts from Stack Overflow or by Amar
Published on 2012-04-05T04:28:57Z Indexed on 2012/04/05 5:29 UTC
Read the original article Hit count: 159

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about jsp

Related posts about jdbc