473,386 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Response.sendRedirect not redirecting

26
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

Expand|Select|Wrap|Line Numbers
  1.  
  2. protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
  3.     {
  4.         try
  5.        {
  6.            boolean success_register = authenticate_register(request.getParameter("first_name"),
  7. request.getParameter("last_name"),request.getParameter("realDob"));
  8.  
  9. /*
  10. autheticate_register( ) is a straight forward implementation of opening 
  11. a connection, retrieving from database values where name="first_name" 
  12. and so, and checking if the retrieved values are null.
  13.  
  14. If they are null,  I return "true", meaning they don't exist in the DB already.
  15. Else, I return "false"
  16. */
  17.      if(success_register)
  18.      {
  19.                 response.sendRedirect("SuccessLogin.jsp");
  20.                 /* Followed by code to actually write the first name,
  21. last name and DoB into the DB.*/
  22.      }
  23.      else
  24.      {
  25.                 response.sendRedirect("Welcome.jsp");
  26.  
  27.      }
  28.    }//End-try
  29.    catch(Exception e) { }
  30.  
  31. }//End doPost()
  32.  
Now, the problem is weird.

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

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

A System.out.print( ) on the values of success_register shows "true" even if the value showed by the expression being returned within authenticate_register( ) is "false".

I am stumped. What's going on??
Dec 19 '09 #1
0 1646

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jim Flath | last post by:
I have a situation when I need to set the response status code to a non 200 and then serve up a generic error page (html page not a jsp). I can successfully call response.setStatus(...
7
by: Fawke101 | last post by:
Hi there, I have a ASP/SQL 7.0 Application and i have a page (page1.asp) that has 2 ways of accessing it. 1 is through a hyperlink on another page (page2.asp), that inserts a value into a...
8
by: Daniel | last post by:
Hello, I have an old asp page that was used to redirect users called redirect.asp: <code1> <% Option Explicit If Request.QueryString("url") <> "" Then Response.Redirect ...
5
by: john | last post by:
Hello, One our thrid page for some reason the response.redirect isn't working on the live server. It works fine on the development machine but when we move the code to the live server it doesn't...
4
by: Marty U. | last post by:
I have a Session variable I need to check the value of. If it is value a then redirect to some page. I need to implement this in a user control that is on all the relevent pages. I placed the if...
1
by: Sean Wolfe | last post by:
I have this wierd bizarrre problem that I'm experienceing with the Response.Redirect() method. I have a site where the users are on a particular page in SSL. When they post the data back, and...
5
by: venner | last post by:
I'm having an issue with an ASP.NET website after upgrading to ASP.NET 2.0. The website makes use of a central authentication service (CAS) provided at the university I work for. Each page checks...
0
by: ponvijaya | last post by:
Hi all, I have one requirement in my project. I need to download a file from the server tot the client machine. And after downloading it , it should be redirected to another jsp file. The...
5
by: cmrhema | last post by:
Hi, I have been noticing one absurd thing far the past couple of days in my workplace, I am redirecting to another form, but while redirecting an unusual thing takes place, it redirects and goes...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.