0% found this document useful (0 votes)
4 views5 pages

JSP PGMS

The document provides examples of JSP (JavaServer Pages) code for various tasks. It includes a JSP that prints 'Hello World' with different styles, another that displays the current date and time, and a third that adds two numbers from user input. Additionally, it mentions a login module JSP without providing the code for it.

Uploaded by

bcamsccs2015
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)
4 views5 pages

JSP PGMS

The document provides examples of JSP (JavaServer Pages) code for various tasks. It includes a JSP that prints 'Hello World' with different styles, another that displays the current date and time, and a third that adds two numbers from user input. Additionally, it mentions a login module JSP without providing the code for it.

Uploaded by

bcamsccs2015
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
You are on page 1/ 5

1. Create a jsp that prints hello world.

<%@page language="java" contentType="text\html" pageEncoding= "ISO-8859-1"%>

<!DOCTYPE html>

<html>

<head>

<title>JSP FILE</title>

<style>

body{

background-color:lightblue;

</style>

</head>

<body>

<center> <h1 style="color:tomato;border:3px solid brown;">Hello world!</h1> </center>

<center> <h1 style="color:green;border:2px solid burlywood;">Hello world!</h1> </center>

<center> <h1 style="color: blue;border:2px solid violet;">Hello world!</h1> </center>

</body>

</html>

OUTPUT:
2. Create jsp that prints current date and time.

<%@page import="java.io.*,java.util.*,javax.servlet.*"%>

<!DOCTYPE html>

<html>

<head>

<title>display current date & time </title>

</head>

<body>

<center> <h3>display current date & time </h3> </center>

<%

Date date =new Date();

out.print("<h4 align=\"center\">"+date.toString()+"</h4>");

%>

</body>

</html>

OUTPUT:
3. Create a jsp that add and subtract two numbers.

index.html

<html>

<head>
<title>Enter two numbers to add up</title>

</head>

<body>

<form action="./add.jsp">

First number: <input type="text" name="t1"/>


Second number: <input type="text" name="t2"/>

<input type="submit" value="SUBMIT" />

</form>

</body>

</html>

ADD.JSP
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title> enter two numbers to add up</title>

</head>

<body>

<%= "<h1> the sum


is"+(Integer.parseInt(request.getParameter("t1"))+Integer.parseInt(request.getParameter("t2")))+
"</h1>"%>

</body>

</html>

OUTPUT:

4. Create a jsp for login module.

You might also like