EXPERIMENT No.
– 8
AIM: Create a JSP page that displays the message “Hello World” in the browser.
CODE:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-
8"%>
<!DOCTYPE html>
<html>
<head>
<title>Hello World JSP</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
OUTPUT:
Bablu Prashad_24SCSE2030039
EXPERIMENT No. 9
AIM: Create an HTML form to accept an integer number and a JSP page that
calculates and displays its factorial.
CODE:
HTML Form ([Link]):
<!DOCTYPE html>
<html>
<head>
<title>Factorial Form</title>
</head>
<body>
<form action="[Link]" method="post">
Enter a number: <input type="number" name="num" required>
<button type="submit">Calculate</button>
</form>
</body>
</html>
JSP Program ([Link]):
<%@ page import="[Link].*" %>
<!DOCTYPE html>
<html>
<head>
<title>Factorial Result</title>
</head>
<body>
<%
int n = [Link]([Link]("num"));
long fact = 1;
for (int i = 1; i <= n; i++) {
fact *= i;
}
%>
<h2>Factorial of <%= n %> is: <%= fact %></h2>
Bablu Prashad_24SCSE2030039
</body>
</html>
OUTPUT:
Bablu Prashad_24SCSE2030039
EXPERIMENT No. 10
AIM: Create a JSP program that takes two numbers from an HTML form and
displays their sum.
CODE:
HTML Form ([Link]):
<!DOCTYPE html>
<html>
<head><title>Sum Form</title></head>
<body>
<form action="[Link]" method="post">
Number 1: <input type="number" name="a" required><br>
Number 2: <input type="number" name="b" required><br>
<button type="submit">Find Sum</button>
</form>
</body>
</html>
JSP Program ([Link]):
<!DOCTYPE html>
<html>
<head><title>Sum Result</title></head>
<body>
<%
int x = [Link]([Link]("a"));
int y = [Link]([Link]("b"));
int sum = x + y;
%>
<h2>Sum of <%= x %> and <%= y %> is: <%= sum %></h2>
</body>
</html>
Bablu Prashad_24SCSE2030039
OUTPUT:
Bablu Prashad_24SCSE2030039
EXPERIMENT No. 11
AIM: Create a JSP program that takes two numbers from an HTML form and
displays their sum.
CODE:
JSP Program ([Link])
<%@ page import="[Link].*" %>
<!DOCTYPE html>
<html>
<head><title>Current Date and Time</title></head>
<body>
<%
LocalDateTime now = [Link]();
%>
<h2>Current Date and Time: <%= now %></h2>
</body>
</html>
OUTPUT:
Bablu Prashad_24SCSE2030039