Labs work: Servlet & JSP
Excercise 1
Purpose : hello world applictions
Hello World Servlet




Servlet that produce nice Html




Hello World JSP :printing current date and time
Exercise-2
Purpose: form processing
Collecting three parameters




Job entry form




Show request header
Exercise-3

Purpose :form processing
Customer Registration




Vote application




Exercise-4

Purpose: Connection pooling jdbc programming
Purpose: Connection pooling jdbc programming using Listner for loading driver and stroing connection

Step1: create an mysql database exp121
CREATE TABLE BOOKS
(
      ISBN VARCHAR(20) NOT NULL ,
      TITLE VARCHAR(70) NULL ,
      AUTHOR VARCHAR(50) NULL ,
      PRICE FLOAT NULL ,
      PRIMARY KEY (ISBN)
);


INSERT INTO books VALUES ('123', 'JAVA', 'foo', 2500.00);
INSERT INTO books VALUES ('456', 'SOA', 'bar ', 3000.00) ;

Step2: create an html form
Step3: Put connection pooling information in context.xml




Mention connection pooling infromation in web.xml of project




Step 4:create AddBookServlet.java servlet
Note: Don’t forget to put mysql connector jar in lib of tomcat

Exercise-5
Purpose: Understanding Session Mgt
HttpSession Object
        Cookies
        UrlRewriting
Simplest shopping cart
       Cookies approach
       Url ReWriting approach




Excercise 6

Purpose: Understanding MVC




Add two no program using mvc
Book Advice Application Using MVC




Example 3: Simple bank application




Exercise 7

Purpose : Understanding Filters
Filter for basic security

Exercise 8
Purpose : understanding scriptlet, expression and decleration tag

Simple login application
Exercise 9
Purpose : understanding useBean tags




Excercise 10
Purpose : Understanding EL and JSTL

Forcing scriptless jsp pages




Demo EL
Using database JSTL




Excercise 12
Simple Book Shopping cart application

Exercise 13
Simple bank application
Excercise 11
Purpose : Understanding Custom tag
What if I want to print “I love india” ten times?
What about this approach:-




We need custom tag……….

Steps:
         1. Create tag class NameTagHandler ie extends SimpleTagSupport
         2. Override doTag method accordingly
         3. Create tld file ….




Case study:
Create an dynamic web application using servlet jsp such as book management system or employee mgt system etc.
Application must use:
    1. MVC 2 model
    2. Connection pooling
    3. Filter for security
Scriptlet should not to be used at any cost,use JSTL and EL

Lab work servlets and jsp

  • 1.
    Labs work: Servlet& JSP Excercise 1 Purpose : hello world applictions Hello World Servlet Servlet that produce nice Html Hello World JSP :printing current date and time
  • 2.
    Exercise-2 Purpose: form processing Collectingthree parameters Job entry form Show request header
  • 3.
    Exercise-3 Purpose :form processing CustomerRegistration Vote application Exercise-4 Purpose: Connection pooling jdbc programming Purpose: Connection pooling jdbc programming using Listner for loading driver and stroing connection Step1: create an mysql database exp121 CREATE TABLE BOOKS ( ISBN VARCHAR(20) NOT NULL , TITLE VARCHAR(70) NULL , AUTHOR VARCHAR(50) NULL , PRICE FLOAT NULL , PRIMARY KEY (ISBN) ); INSERT INTO books VALUES ('123', 'JAVA', 'foo', 2500.00); INSERT INTO books VALUES ('456', 'SOA', 'bar ', 3000.00) ; Step2: create an html form
  • 4.
    Step3: Put connectionpooling information in context.xml Mention connection pooling infromation in web.xml of project Step 4:create AddBookServlet.java servlet Note: Don’t forget to put mysql connector jar in lib of tomcat Exercise-5 Purpose: Understanding Session Mgt HttpSession Object Cookies UrlRewriting
  • 5.
    Simplest shopping cart Cookies approach Url ReWriting approach Excercise 6 Purpose: Understanding MVC Add two no program using mvc
  • 6.
    Book Advice ApplicationUsing MVC Example 3: Simple bank application Exercise 7 Purpose : Understanding Filters Filter for basic security Exercise 8 Purpose : understanding scriptlet, expression and decleration tag Simple login application
  • 7.
    Exercise 9 Purpose :understanding useBean tags Excercise 10 Purpose : Understanding EL and JSTL Forcing scriptless jsp pages Demo EL
  • 8.
    Using database JSTL Excercise12 Simple Book Shopping cart application Exercise 13 Simple bank application
  • 9.
    Excercise 11 Purpose :Understanding Custom tag What if I want to print “I love india” ten times? What about this approach:- We need custom tag………. Steps: 1. Create tag class NameTagHandler ie extends SimpleTagSupport 2. Override doTag method accordingly 3. Create tld file …. Case study: Create an dynamic web application using servlet jsp such as book management system or employee mgt system etc. Application must use: 1. MVC 2 model 2. Connection pooling 3. Filter for security Scriptlet should not to be used at any cost,use JSTL and EL