codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:



Home » JAVA » Article

ID Verification using JSP

Article by: Nouman Rashid (2/26/2003)
Bookmark us now! Add to Favourites
Email a friend! Tell a friend
Summary: One of the most important parts of web development is to make sure that only authorized users get access to certain areas of the site. This tutorial takes a look at various steps involved in making JSP pages which validate a user ID and password from a MS Access database which contains the username and password.
Viewed: 206205 times Rating (127 votes): 
 4 out of 5
  Rate this Article   Read Comments   Post Comments

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 Username field and a password field. Users will see it when they will come to your awesome site. Here's the code.

I call this page main.jsp

Select All Code


Copy this code and save it as either an HTML or JSP page in your server. If you are using TOMCAT it would be webapps\examples\jsp folder.

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 UserName and password 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 us to 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.

Select All Code


Here's the bean code which the controller JSP uses to verify the username and password.

Select All Code


Complie this code and place the class file in the webapps\examples\web-inf\classes\foo folder. 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 success.jsp 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 url as http://localhost:8080/examples/jsp/main.jsp. Here you will enter the user name and password.

Let's see, I have got the following entry in the databse

UserName nouman
password ceab


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 very easily.

How do I make this code better? Just throw me a line at nouman_rashid@yahoo.com




CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
Rate this article:     Poor Excellent
View highlighted Comments
User Comments on 'ID Verification using JSP'
RELATED ARTICLES
Java MP3 Player
by David Barron
A fully functioning MP3 Player with complete source code available for download
A simple way to JTable
by Kanad Deshpande
Many face trouble while dealing with JTable. Here is simplest way to handle JTable.
ID Verification using JSP
by Nouman Rashid
One of the most important parts of web development is to make sure that only authorized users get access to certain areas of the site. This tutorial takes a look at various steps involved in making JSP pages which validate a user ID and password from a MS Access database which contains the username and password.
Java Native Interface (JNI)
by Kanad Deshpande
Java Native Interface (JNI) is one of the intersting interface by java By using Java Native Interface (JNI) you can operate with other applications and libraries.
Understanding Hibernate ORM for Java/J2EE
by Saritha.S.V
Hibernate is the most popular and most complete open source object/relational mapping solution for Java environments.Hibernate's goal is to relieve the developer from 95 percent of common data persistence related programming tasks.
Login codes with JSP,JavaBean from mySQL database
by Prakash
my problem is can i have the code to login with the username and password using JSP and JavaBean/Servlets from mySQL database.When the user enters the username and password in the login page then it will go to the requested site.How to do it?
Java Speech Synthesizer
by David Barron
Small and simple. Type a sentence and press enter and your computer will speek to you.
simple Java Development Environment
by David Barron
Program in JAVA with ease, using this development environment, or adapt it to your own needs.
Turn EJB components into Web services
by Krunal J Patel
Web services have become the de facto standard for communication among applications. J2EE 1.4 allows stateless Enterprise JavaBeans (EJB) components to be exposed as Web services via a JAX-RPC (Java API for XML Remote Procedure Call) endpoint, allowing EJB applications to be exposed as Web services. This article presents a brief introduction to JAX-RPC, outlines the steps for exposing a stateless session bean as a Web service, and provides the best practices for exposing EJB components as Web services
CORBA Technology
by Krunal Patel
CORBA defines an architecture for distributed objects. The basic CORBA paradigm is that of a request for services of a distributed object. Everything else defined by the OMG is in terms of this basic paradigm.








Recent Forum Threads
•  Game:Colonization based with HTML5 Canvas and JavaScript
•  Pointwise.GridGen.v15.18
•  Global.Mapper.v15.2.3.b060614
•  Geometric_Glovius_Pro_v3.6.1
•  VERO.SurfCAM.v2014
•  Schlumberger.Petrel.V2013.2
•  Petrel.V2013.2
•  Altair.HyperWorks.v12
•  VoluMill.v6.1


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2014