Protecting your website with a login page

By: aathishankaran Emailed: 1609 times Printed: 2079 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 )
What is JSP?
Cookies using JSP or Java Bean
JSP Example to connect to MS SQL database and retrieve records
JSP Alert Example
What are the different scopes in JSP?
JSP CheckBox Example
Comparison operators in JSP
Sending Email using JSP
JSP Program for display Date
Uploading an Image to a Database using JSP
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: `java.net.BindException: Permission denied <null>:80
Embedding java codes in jsp sciptlets
Arithmetic Evaluation Using the Expression Language in JSP
Using a DataSource from WebLogic in a JSP
Embedding MP3 audio file in a JSP
Most Emailed Articles (in JSP)
Embedding java codes in jsp sciptlets
Packaging Servlets
Server-side plug-Ins
What are the different scopes in JSP?
The taglib, tag, include, attribute and the variable Directive in JSP
The Advantages of JSP
Retrieving a Portion of a String
Sessions in JSP
A JSP page that gets properties from a bean
JSP Alert Example
The Advantages of Servlets Over “Traditional” CGI
The Out Object in JSP
Document Object
Web Security Issues
The Response Object in JSP