ID Verification using JSP
If you are developing site
for a simple departmental store or
if you are lucky enough to be developing
one for NASA, you will still be asked
to give the User Verification functionality. This is the most important
demand of the client.
Have no fear, as you have come to the
right place at the right time.
Together we will make few pages and code
which will cover your basic needs.
For this example I have used Tomcat server. Though it hardly matters if you
use any other one. You will just have to
place JSP pages and the java class
in some other folder.
Ok, enough formal talk. Let's get to business. First part is to make the Login page.
This page will have a
password field. Users will see
it when they will come to your awesome
Here's the code.
I call this page
Copy this code and save it as either
an HTML or JSP page in your server.
If you are using TOMCAT it would be
Now we will come to the very important
question - who to let in to your site and who to refuse? For this we will make a
database. I am using MS Access. Here make
a table, call it Registration and register it with ODBC Data Source Administrator in your control panel.
Make two columns
as I would be using them in my code.
Done? Good,lets move forward.
See the Action part of the Form tag
in the above code. After the user enters
his/her username and password, it takes
process2.jsp. This is our controller
JSP. It decides which page to take
the user to, depending upon the input.
It uses a java bean to do that. Confused? Don't worry, a bean is just a
little java code we use in JSP to make things very easy.
Here's the controller JSP page (called process2.jsp). Save it into the same directory you did
the Login page.
Here's the bean code which the controller JSP uses to verify the username and password.
Complie this code and place the class
file in the
Create a new foo folder if necessary.
Before getting to the final stages of
the application, let's make two
more pages. One will be
and other will be
retry.jsp. Copy them
to the corresponding directory of your server.
Now get your webserver starting.
As I am using Tomcat I would write the
Here you will enter the user name
Let's see, I have got the following entry
in the databse
If I enter the above combination,
I will go through to the site, otherwise
I will be shown the retry page, which
will just say buddy! try again.
Though this is very simple application,
I hope you can see that it could be enhanced
How do I make this code better?
Just throw me a line at