0% found this document useful (0 votes)
3 views6 pages

Java Lab Bablu

The document outlines several experiments involving JSP and HTML forms. It includes code examples for displaying 'Hello World', calculating the factorial of a number, summing two numbers, and displaying the current date and time. Each experiment provides the aim, code, and expected output format.

Uploaded by

noreply0msr
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views6 pages

Java Lab Bablu

The document outlines several experiments involving JSP and HTML forms. It includes code examples for displaying 'Hello World', calculating the factorial of a number, summing two numbers, and displaying the current date and time. Each experiment provides the aim, code, and expected output format.

Uploaded by

noreply0msr
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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

You might also like