Response.sendRedirect not redirecting

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • p vs np
    New Member
    • Mar 2009
    • 26

    Response.sendRedirect not redirecting

    I face a very queer problem. I have written a simple servlet to gather information from a static HTML form and I wish to write to a Database (DB) if the record doesn't exist already.

    In order to do so, I have the following snippet from my servlet, DataEntry.java

    Code:
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
        {
        	try
           {
               boolean success_register = authenticate_register(request.getParameter("first_name"),
    request.getParameter("last_name"),request.getParameter("realDob"));
    
    /*
    autheticate_register( ) is a straight forward implementation of opening 
    a connection, retrieving from database values where name="first_name" 
    and so, and checking if the retrieved values are null.
    
    If they are null,  I return "true", meaning they don't exist in the DB already.
    Else, I return "false"
    */
         if(success_register)
         {
        			response.sendRedirect("SuccessLogin.jsp");
        			/* Followed by code to actually write the first name,
    last name and DoB into the DB.*/
         }
         else
         {
        			response.sendRedirect("Welcome.jsp");
        			
         }
       }//End-try
       catch(Exception e) { }
    
    }//End doPost()
    Now, the problem is weird.

    The redirection is happening only to success.jsp in either case, whether success_registe r is "true" or "false".

    But, the DB values are not entered if authenticate_re gister( ) evaluates to "false", which is what is supposed to happen.

    A System.out.prin t( ) on the values of success_registe r shows "true" even if the value showed by the expression being returned within authenticate_re gister( ) is "false".

    I am stumped. What's going on??
Working...