aspose file tools*
The moose likes Servlets and the fly likes How to dynamically remind the user of registration errors? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to dynamically remind the user of registration errors?" Watch "How to dynamically remind the user of registration errors?" New topic
Author

How to dynamically remind the user of registration errors?

Mark Lau
Ranch Hand

Joined: Dec 15, 2001
Posts: 120
Again, my web application requires user registration.
Say, on the registration page, I want to have the user enter the following information to register with my site:
User name:
Password:
Password again:
First name:
Last name:
E-mail:
Phone:
Suppose the user enters a user name that is already taken by somebody, and everything else is acceptable. After the user hits the "Register" button, my servlet detects the user name problem. Then I want to go back to the registration page, with a message in red at the top "The user name has been taken, please try another one."
Or suppose, in addition to the user name problem, the two entries of passwords do not match each other, I want to go back to the registration page with two messages in red at the top "The user name has been taken, please try another one.", "The passwords you enter do not match."
By now, you must have understood my question. It's just something everybody has ever seen.
How do I achieve this? My site is being built using servlet, JSP, JDBC and Java Beans.
Thanks.
arun mahajan
Ranch Hand

Joined: Dec 07, 2001
Posts: 305
Yes this is very much possible. Perhaps this could be achieved by following method:-
1. keep all your fields of registartion in an array i.e. sya regitem[0]=name,regitem[1]=email etc.
2. make a another array with respective fields as boolean.
3. make a query to database whatever user has given. and for every fields make the array yes or no.
4. against this array message put the value of regitems array in different colors. Perhaps this will become more easier if you can use CSS Pages.
regards,
arun
Malhar Barai
Author
Ranch Hand

Joined: Aug 17, 2001
Posts: 399
dear arun
could u please put more light on this, i couldnt understand it properly.
malhar
Syam Veerakumar
Ranch Hand

Joined: Sep 20, 2001
Posts: 49
Its always better to check for the password match in the front end itself using Java Script, so that u may not waste the server time and Network time as well as User's time.
To check the username u can give like this,
userName = request.getParameter("username");
//Check it here using JDBC
If the the name already exists
Populate a vector like
Vector ErrVect = new Vector();
ErrVect.addElement("User Name already exists....etc");
Add this vector to session.
and redirect to Registration page.
In the Registration page check the vector is not null,if the vector is not null,then display its content.
If u cudn't understand this inform me, i'll send u the full code.
[ February 02, 2002: Message edited by: Syam Veerakumar ]

A Quitter Never Wins<br />A Winner Never Quits
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to dynamically remind the user of registration errors?
 
Similar Threads
how to get empty fields when redirecting to previous page
remitting values
Login vs. register
How do we memorize user input at a registration page?
JSP makes me headache