Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

redirecting to another servlet with an if statement?

Status
Not open for further replies.

cram81

Technical User
Dec 27, 2003
29
GB
hi
i currently have a bunch of servlets that i am using for a user authentication system:

seeAccounts - gives user some questions
choosePic - lets user choose identify their picture
chooseSound - lets user identify thier sound
FinishServlet - gathers parameters and determines if all were true

Now at each stage i pass a parameter in the url to the next servlet indicating whether the previous authentication was true or not...

now when i reach my final servlet if i recieve 3 true's then the user has been successfully authenticated ....

but if i recieve a false then i want to redirect the user back to the seeAcconts servlet to give them another attempt...

now i was thinking of doing this via an if statements like this:

Code:
 if(qTest.compareTo("true")==0 && pTest.compareTo("true")==0 && sTest.compareTo(rs.getString("sound_text"))==0)
                        {
                         out.println(&quot;Congratulations You Have Completed Your Credential Recovery Successfully <BR>&quot;);
                        } else {
                               [b] //REDIRECT TO SeeAccounts  
                                   // Attempts ++[/b]
                               }        
                     }
Is this possible to do? if not is there an alternative architecture i could use for this problem of redirecting the user to a new page....? any help or suggestions will be much appreciated
thanks

mark
 
Code:
RequestDispatcher rd = getServletContext().getRequestDispatcher(url);
rd.forward(request, response);

I would also use String.equalsIgnoreCase() rather than compareTo().
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top