How to make a simple Login page using Servlet & Session in NetBeans IDE



How to make a simple Login page using Servlet & Session in NetBeans IDE

1. Open NetBeans IDE

2. Make a new Project as:

   2.1 File~NewProject~Java Web~WebApplication

3. Make a servlet(say First.java) as:

   3.1 RightClick on Source Package~New~Other~Web~Servlet
   3.2 Name your Servlet
   3.3 Check Add Information to deployment descriptor(web.xml file)

4. Make another servlet(say Second.java).

5. Make an HTML file as:

   5.1 RC on Web Pages folder and select New~Other~Web~HTML
   5.2 Design a simple form in HTML
   5.3 Give the url-pattern of First Servlet in the 'action' attribute(say '/First')

6. Write code for First.java to authenticate the user
  
   6.1 In this servlet set the session attribute with a 'key' and its 'value'.

7. Write code for Second.java to view the profile

   7.1 In this get the attribute of session.

8. Run the Project(let server is Tomcat).

9. Finish.

Facebook

Comments

Popular posts from this blog

How to Perform DES Encryption and Decryption of TXT file in JAVA with NetBeansIDE

How to Detect CapsLock key using Java in NetBeansIDE.

How to insert Image in MySQL Database with Java in NetBeansIDE