Вы находитесь на странице: 1из 3

Servlet –Exercise

#1 Program
Create a JSP form to accept your name and print the below message inside the Servlet
“Hi [your name] welcome to hotcourses india private limited, Chennai

#2 Program
Create a JSP form that accept the below field, Using the Servlet program print the result in another JSP
in the table format along with the total and average.
Student ID Textbox Should be a number
Student name Textbox
About Students Textarea
Age Textbox Should be a number
Gender Dropdown
English mark Textbox Should be a number
Tamil mark Textbox Should be a number
Maths mark Textbox Should be a number
Science mark Textbox Should be a number
Social mark Textbox Should be a number

#3 Program:
Create a JSP form that accept 2 numbers and a dropdown along with a submit button. Raise the error if
the given value is not number. Raise error if the first number is greater than the second number.
Values in dropdown
AE Add even numbers between 2 values
AM Amstrong numbers between 2 values
PM Prime numbers between 2 values
PD Print the numbers that divide by 2 and 5

On clicking the submit button, Using Servlet program it has to print the result in separate JSP for each
action based on selected dropdown value

# 4 Program:
Create a JSP form that accept a numbers and a submit button. Raise the error if the given value is not
number.
On clicking on the button, using the servlet program it takes to another JSP which contains the below
dropdown values. Preselect the dropdown with the entered value in the First JSP

CODE NAME
100 The given color is Red
200 The given color is Blue
300 The given color is Green
400 The given color is Yellow
500 The given color is Orange
600 The given color is Black
700 The given color is White
800 The given color is Brown
900 The given color is Pink
1000 The given color is Grey
Servlet –Exercise

Table name: java_employees

Table structure:

Connection details
JDBC_DRIVER = "oracle.jdbc.driver.OracleDriver"
DB_URL = "jdbc:oracle:thin:@192.168.1.12:1521:edukdev"
USER_NAME = "HOT_ACADEMY" ; PASSWORD = "ha11marks"

#5 Program
Create a JSP which contains a link, on clicking the link using the servlet program access the table
“Java_employees” and display all the columns in another JSP inside the table with respective headings

Query : select * from java_employees

#6 Program
Create a JSP which contains a link, on clicking on the link using the servlet program access the table
“Java_employees” and load the Employee_ID and Email to the HASH MAP and display the results in
another JSP in table format with respective headings.

Query : select employee_id, email from java_employees

#7 Program:
Create a JSP form that accept 2 numbers and a dropdown along with a submit button, Raise the error if
the given value is not number also raise error if dropdown not selected

Values in dropdown
Please select option
AD Add the 2 numbers using DB
MU Multiply 2 numbers using DB
DIV Divide 2 numbers using DB
MOD Mod of 2 numbers using DB

On clicking on submit button, using the Servlet program access the below procedure and display the
result in another JSP

Procedure details: JAVA_ACADEMY.PROCESS_REQUEST_PRC ( p_number1 IN NUMBER ,


p_number2 IN NUMBER ,
p_type IN VARCHAR,
l_results OUT NUMBER
);
Servlet –Exercise

#8 Program:
Create a JSP form that accept a employee_id with a submit button, Raise the error if the given value is
not number.
On clicking on submit button, using the Servlet program access the below procedure and display the
result in another JSP in the table format.
If there is no result for the given employee_id then takes to the same input page and display the below
message in RED
“Oops!... sorry the employee id ([EMPLOYEE_ID]) not exists in the database.”

Procedure details: JAVA_ACADEMY.GET_EMPLOYEE_INFO_PRC (


p_employee_id IN NUMBER ,
lc_employee_info OUT SYS_REFCURSOR
);
Cursor values
employee_id
first_name
last_name
email
phone_number
hire_date
job_id
salary
commission_pct
manager_id
department_id

#9 Program:
Create a JSP form that accept the below details along with a submit button, Raise the error if there is no
data given against the fields, and also validate number if the field required number.

EMPLOYEE_ID NUMBER(6),
FIRST_NAME VARCHAR2(20 BYTE),
LAST_NAME VARCHAR2(25 BYTE) NOT NULL,
EMAIL VARCHAR2(25 BYTE) NOT NULL,
PHONE_NUMBER VARCHAR2(20 BYTE),
JOB_ID VARCHAR2(10 BYTE) NOT NULL,
SALARY NUMBER(8,2),
COMMISSION_PCT NUMBER(2,2),
MANAGER_ID NUMBER(6),
DEPARTMENT_ID NUMBER(4)

On clicking on submit button, using the Servlet program read the above data and insert into the table
and print the success message in the “Adding screen” once the data updated successfully

Query : Insert into JAVA_EMPLOYEES


(EMPLOYEE_ID, FIRST_NAME, LAST_NAME, EMAIL, PHONE_NUMBER, HIRE_DATE, JOB_ID,
SALARY, COMMISSION_PCT, MANAGER_ID, DEPARTMENT_ID)
Values (?....);

Вам также может понравиться