Question 1:
(2.5 points)
You are given a NetBeans template project.
Your tasks
• Edit index.html to create a web page
Your tasks: Assume that users fill your full name into the textfield
1. When users click “RESET” button, set value of textfield is empty. (0.5 point)
2. When users click CHECK” button, the browser makes a request to /check using Post method
(The Servlet is configured in web.xml) (0.5 point):
a. If the user enters the name format incorrectly (each word is separated by 1 space, the
first letter is capitalized, there is no space at the beginning or end of the string), the error
message "You entered incorrectly" will be displayed on the servlet. If not, make a request
b. (0.5 point)
b. Count the number of 'a' characters in the string and display the number of 'a'
characters on the web. (0.5 point)
Question 2:
(2.5 points)
Your tasks
• Add q2.jsp to create a web page (0.5 point)
• Assume that users fill an integer into the textfield, when users click “COUNT” button, the
browser makes a request to /count using Post method (The Servlet is configured in web.xml) (0.5
point):
a. Check input: If users input the number that is not an even number > 0, show the error
text "You must input an odd number > 0". (0.5 point)
Otherwise, make the request b.
b. Count the perfect number from 1 to n-1 and output the result to JSP file as following.
(1.0 point)
Question 3: (5.0point)
IMPORTANT – before you start doing your solution, MUST do the following steps:
1. Create your MS SQL database named workshop2 by running code in script workshop2.sql.
2. You MUST use DBContext.java for your all database connection.
You are given a database script, execute the script to get the database as shown in below figure:
Note: Use given DbContext class to access the database, ONLY MODIFY the url,
username, and password inside the DbContext. 0 will be given to the work that tries to
restructured the DbContext.
Your task is to create a web page to allow users adding new Students:
• Url to access your page: /add (0 given for a wrong URL)
• The page should be displayed as follows:
New
student info
Existing
students
• Departments are loaded from [Department] table (1 point)
• All existing Student are loaded to the table (1.5 points)
• When a user clicks [add] button, if the user enters to all field of new student info,
the system inserts new student to the database (1.5 points)
• If new student added to database successful, it immediately is shown to the table
(current page still be kept, DO NOT CHANGE PAGE URL) (1 point)