Protecting your website with a login page

By: aathishankaran Emailed: 1698 times Printed: 2203 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

Protecting your website with a login page

Some sites require that all users log-in using a username and password, before being able to visit any page.

 This can be done using JSP sessions or servlets, and in fact this was a common technique for a while.  But starting with a new release of Servlets specifications from Sun, this feature is now very simple to implement.  

 It is no longer necessary to use JSP techniques to provide login/password protection, but it is still a very common requirement of web sites, therefore a brief overview is provided here.

 

To password-protect your site, you just need to design a login page.  This page can be as simple or complicated as you need it to be.  It must contain a <FORM> tag, with the METHOD set to POST and the ACTION set to "j_security_check".

 

<FORM METHOD=POST ACTION=j_security_check>

 

The target j_security_check is provided by the application server, and does not need to be coded.

 

The form must contain two <INPUT> fields, named j_username and j_password respectively for the username and password.  Typically, the username field will be a TEXT input field, and the password field will be a PASSWORD input field.

 

After this, you must tell your application server to password protect your pages using the login page you have provided.  The details will vary from server to server, but a good implementation will provide you hook that you can use, for example, to match usernames and passwords against a database.  (E.g., in a website you can supply an implementation of the interface desisoft.deploy.AuthCheck to check usernames and passwords against a database or other sources.)


JSP Home | All JSP Tutorials | Latest JSP Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(0)


Be the first one to add a comment

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by aathishankaran
Web Security Issues
The Web User's Perspective
Server-side plug-Ins
The best way to avoid security vulnerabilities with new server
JavaScript Security
Window Object
Working with Status Bar Messages
Retrieving a Portion of a String
Referencing Windows
Math Object
Frame Object
Document Object
Closing Windows
Built-in Object in Javascript
Textarea Object

More Tutorials in JSP
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: `java.net.BindException: Permission denied <null>:80
JSP Alert Example
JSP CheckBox Example
Uploading an Image to a Database using JSP
Uploading a file to a server using JSP
A JSP page that gets properties from a bean
The page Directive in JSP
The taglib, tag, include, attribute and the variable Directive in JSP
Declarations in JSP
Scriptlets and Expressions in JSP
Tag Libraries in JSP
The Request Object in JSP
The Response Object in JSP
The Out Object in JSP
The Session Object in JSP

More Latest News
Most Viewed Articles (in JSP )
JSP CheckBox Example
JSP Program for display Date
JSP Alert Example
JSP Example to connect to MS SQL database and retrieve records
What are the different scopes in JSP?
Comparison operators in JSP
Uploading an Image to a Database using JSP
Syntax For JSP Declaratives
Retrieving a Portion of a String
Sending Email using JSP
Uploading a file to a server using JSP
Embedding java codes in jsp sciptlets
Example Using Initialization Parameters
JSP Tags for SQL to connect to a database
Calling JSP from a batch file
Most Emailed Articles (in JSP)
Scriptlets and Expressions in JSP
Tag Libraries in JSP
What is JSP?
The JSP Program running first Time.
Scriptlets
Embedding java codes in jsp sciptlets
JSP Example to connect to MS SQL database and retrieve records
The Response Object in JSP
Cookies using JSP or Java Bean
Click to Activate and Use this control
Declaring variable in JSP
Sessions in JSP
Tag libraries
Basic Servlet Structure
NetworkClient