Practical List
Practical List
Practical List
studentinfo.jsp Code:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-
8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
String roll1=request.getParameter("roll");
String sname1=request.getParameter("sname");
String city1=request.getParameter("city");
out.println("<h1>Roll="+roll1+"</h1>");
out.println("<h1>SName="+sname1+"</h1>");
out.println("<h1>City="+city1+"</h1>");
%>
</body>
</html>
2) Write a Java Bean program which accept two numbers in textbox and print addition of numbers
on next page.
Form.html Code:
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="result.jsp"" method="post""">
<center>
<h1>calculator</h1>
No1<input type="text" name="no1">
No2<input type="text" name="no2">
<input type="submit" value="Submit">
</center>
</form>
</body>
</html>
Result.jsp Code:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
String no1=request.getParameter("no1");
String no2=request.getParameter("no2");
int res=Integer.parseInt(no1)+Integer.parseInt(no2);
out.println("Addition ="+res);
%>
</body>
</html>
3) Write a JSP page, which accepts user name in a text box and greets the user according to the time
on server machine.
Form.html Code:
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
</body>
</html>
Greetmsg.jsp Code:
<%@page import="java.util.Calendar"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
</body>
</html>
4) Write a JSP program to calculate sum of first and last digit of a given number & display sum in
Red Color with font size 18.
Form.html Code:
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
</body>
</html>
Displaysum.jsp Code:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
if(n<10)
{
out.println("Sum of first and last digit is ");
%><font size=18 color=red><%= n %>
<%
else
rem=n%10;
do
{
r=n%10;
n=n/10;
}while(n>0);
n=rem+r;
out.println("Sum of first and last digit is ");
%><font size=18 color=red><%= n %>
<%
}
%>
</body>
</html>
5) Write a java program to design a following GUI (Use JSP).
Guidelines:
For this practical, you should design the web page (i.e. html page) with basic tags in html and
whatever information is entered by user that should be displayed on your jsp page.