Java Lab
Java Lab
SOURCE CODE:
public class App {
public static void main(String[] args) throws Exception {
int[][] matrix = new int[][]{{1,2}, {3,4,5}, {1,2,3,4,5}};
LAB 02:
Write a java program to initialize and display 2D array elements with sum of each row.
SOURCE CODE:
public class App {
public static void main(String[] args) throws Exception {
Lab 03:
Write a java program to implement the concepts of multiple inheritances in Java to calculate
the area of a shape and the cost to paint it.
SOURCE CODE:
public class App {
public static void main(String[] args) throws Exception {
Rectangle rect= new Rectangle(23, 7);
[Link]([Link]());
[Link]([Link]([Link]()));
}
}
class Shape{
protected int length,breadth;
Shape(int l, int b){
[Link]=l;
[Link]=b;
}
}
interface PaintCost{
int getCost(int area);
}
class Rectangle extends Shape implements PaintCost {
Rectangle(int l,int b){
super(l, b);
}
public int getArea(){
return length*breadth;
}
@Override
public int getCost(int area){
return (2*(length*breadth));
}
}
Lab 04
Write a java program to implement the concepts of multiple inheritances in Java using
interfaces to calculate the area of a shape and the cost to paint it.
SOURCE CODE:
public class Multiple_Interface {
public static void main(String[] args) {
Rectangles rect= new Rectangles(5, 7);
[Link]([Link]());
[Link]([Link]([Link]()));
}
}
interface CalArea
{
int getArea();
}
interface PaintCost
{
int getCost(int area);
}
class Rectangles implements CalArea, PaintCost
{
int length,breadth;
Rectangles(int l,int b)
{
[Link]=l;
[Link]=b;
}
@Override
public int getArea()
{
return length*breadth;
}
@Override
public int getCost(int area)
{
return (3*(area));
}
}
Lab 05
Write a java program to implement the concepts of multiple inheritances in Java using
abstracts to calculate the area of a shape and the cost to paint it.
SOURCE CODE:
public class Abstract {
public static void main(String[] args) {
Rectangle rect = new Rectangle(7, 30);
[Link]("Area: " + [Link]());
[Link]("Cost: " + [Link]());
}
}
Shape(int l, int b) {
[Link] = l;
[Link] = b;
}
interface PaintCost {
int getCost();
}
Lab 07
Write a function that accepts an array of non-negative integers and returns the second largest
integer in the array [Return -1 if there is no second largest].
SOURCE CODE:
public class App {
public static void main(String[] args) throws Exception {
[Link](a1(new int[]{1, 2, 3, 4}));
[Link](a1(new int[]{4, 1, 2, 3}));
[Link](a1(new int[]{1, 1, 2, 2}));
[Link](a1(new int[]{1, 1}));
[Link](a1(new int[]{1}));
[Link](a1(new int[]{}));
}
static int a1(int[] a)
{
int max1 = -1,max2 = -1;
for (int i=0; i<[Link]; i++){
if (a[i] > max1){
max2 = max1;
max1 = a[i];
}
else if (a[i] != max1 && a[i] > max2)
max2 = a[i];
}
return max2;
}
}
Lab 08
You have given string:
String[] str = new String[]{"a", "b", "c", "a", "a", "d", "c", "f"};
i. Find Repeated Words
ii. Display Non-Repeated Words
iii. Remove All Repeated Words
SOURCE CODE:
import [Link];
public class App {
public static void main(String[] args) throws Exception {
String[] str = new String[]{"a", "b", "c", "a", "a", "d", "c", "f"};
// Repeated Words
[Link]("Repeated Words:");
for (int i = 0; i < [Link]; i++) {
boolean alreadyPrinted = false;
for (int k = 0; k < i; k++) {
if (str[i].equals(str[k])) {
alreadyPrinted = true;
break;
}
}
if (alreadyPrinted) {
continue;
}
for (int j = i + 1; j < [Link]; j++) {
if (str[i].equals(str[j])) {
[Link](str[i]);
break;
}
}
}
SOURCE CODE:
public class App {
public static void main(String[] args) throws Exception {
String[] strings = {"apple", "banana", "apple", "orange", "banana",
"apple","strawberry"};
boolean[] counted = new boolean[[Link]];
[Link]("Word Occurrences:");
for (int i = 0; i < [Link]; i++) {
if (counted[i]) continue; // Skip if already counted
int count = 1;
for (int j = i + 1; j < [Link]; j++) {
if (strings[i].equals(strings[j])) {
count++;
counted[j] = true;
}
}
[Link](strings[i] + ": " + count);
}
}
}
Lab 10
Find the longest word in an array:
strings= {"sun", "moon", "stars", "galaxy"}
SOURCE CODE:
public class App{
public static void main(String[] args) throws Exception{
String[] strings = {"sun", "moon", "stars", "galaxy"};
Lab 11
Find the shortest word in an array:
strings= {"apple", "banana", "cat", "orange"}
SOURCE CODE:
public class App{
public static void main(String[] args) throws Exception{
String[] strings= {"apple", "banana", "cat", "orange"};
// Find the longest word using array indices
int shortestIndex = 0;
for (int i = 1; i < [Link]; i++) {
if (strings[i].length() < strings[shortestIndex].length()) {
shortestIndex = i;
}
}
[Link]("The shortest word is: " + strings[shortestIndex]);
}
}
Lab 12
Write a simple java program to demonstrate how thread priority is handled.
SOURCE CODE:
public class App {
public static void main(String[] args) throws Exception {
TestMultiPriority1 m1= new TestMultiPriority1();
TestMultiPriority1 m2= new TestMultiPriority1();
TestMultiPriority1 m3= new TestMultiPriority1();
[Link](Thread.MIN_PRIORITY);
[Link](Thread.MAX_PRIORITY);
[Link](Thread.NORM_PRIORITY);
[Link]();
[Link]();
[Link]();
}
}
class TestMultiPriority1 extends Thread{
public void run()
{
[Link]([Link]().getPriority());
}
}
Lab 13
Write a java program to demonstrate Multithreading using synchronized method.
SOURCE CODE:
public class App {
public static void main(String[] args) throws Exception {
Table obj=new Table();//only one object
MyThread1 t1=new MyThread1(obj);
MyThread2 t2=new MyThread2(obj);
[Link]();
[Link]();
}
}
class Table{
synchronized void printTable (int n)
{
for(int i=1;i<5;i++)
{
[Link](n*i);
try{
[Link](400);
}catch(Exception e)
{
[Link](e);
}
}
}
}
class MyThread1 extends Thread{
Table t;
MyThread1 (Table t)
{
this.t=t;
}
public void run()
{
[Link](5);
}
}
class MyThread2 extends Thread{
Table t;
MyThread2 (Table t)
{
this.t=t;
}
public void run()
{
[Link](100);
}
}
Lab 14
Write a java program to demonstrate inter-thread communication or Co-operation threading.
SOURCE CODE:
public class App {
public static void main(String[] args) throws Exception {
Customer c=new Customer();
Thread t1= new Thread()
{
public void run()
{
[Link](15000);
}
};
[Link]();
Thread t2=new Thread(){
public void run()
{
[Link](5000);
}
};
[Link]();
}
}
class Customer{
int amount = 10000;
synchronized void withdraw(int amount)
{
[Link]("Going to withdraw...");
if([Link]<amount)
{
[Link]("Less balance. Waiting for deposit...");
try{
wait();
}
catch (Exception e)
{}
}
[Link]-=amount;
[Link]("Withdraw completed...");
}
synchronized void deposit(int amount)
{
[Link]("Going to deposit...");
[Link]+=amount;
[Link]("Deposit completed...");
notify();
}
}
Lab 15
Write a java program to read from file [Link] and write its contents to [Link].
SOURCE CODE:
import [Link];
import [Link];
[Link]:
Lab 16
Write a java program to read from file [Link] and write its contents to [Link].
SOURCE CODE:
import [Link].*;
public class App {
public static void main(String[] args) throws Exception {
FileReader in = null;
FileWriter out = null;
try {
in = new FileReader("[Link]");
out = new FileWriter("[Link]");
int c;
while ((c = [Link]()) != -1) {
[Link](c);
}
} finally {
if (in != null) {
[Link]();
}
if (out != null) {
[Link]();
}
}
}
}
OUTPUT:
Lab 17
Write a java program to demonstrate object serialization and deserialization.
SOURCE CODE:
import [Link].*;
public class App {
public static void main(String[] args) throws Exception {
Student st = new Student();
[Link]=5;
[Link]="Raseek";
[Link]="Bhaktapur";
try{
FileOutputStream out = new FileOutputStream("[Link]");
ObjectOutputStream oboutput= new ObjectOutputStream(out);
[Link](st);
[Link]();
[Link]();
[Link]("Object is serialized");
FileInputStream in = new FileInputStream("[Link]");
ObjectInputStream obinput= new ObjectInputStream(in);
st=(Student)[Link]();
[Link]();
[Link]();
}catch(IOException e){
[Link]();
}
[Link]([Link]+" "+[Link]+" "+[Link]);
}
}
class Student implements Serializable{
public String name,address;
public int id;
}
Lab 18
Write a java program to read, read write using Random Access File.
SOURCE CODE:
import [Link].*;
public class App {
public static void main(String[] args) throws Exception {
String FILEPATH = "[Link]";
try {
[Link](new String(readFromFile(FILEPATH, 0, 18)));
writeToFile(FILEPATH, "Stay [Link] days are on their way.", 8);
[Link](new String(readFromFile(FILEPATH, 0, 100)));
} catch (IOException e) {
[Link]();
}
}
private static byte[] readFromFile(String filepath, int position, int size) throws Exception {
RandomAccessFile file = new RandomAccessFile(filepath, "r");
[Link](position);
byte[] bytes = new byte[size];
[Link](bytes);
[Link]();
return bytes;
}
private static void writeToFile(String filepath, String data, int position) throws Exception {
RandomAccessFile file = new RandomAccessFile(filepath, "rw");
[Link](position);
[Link]([Link]());
[Link]();
}
}
Lab 19
Write a java program to create a GUI form.
SOURCE CODE:
import [Link].*;
public class App {
public static void main(String[] args) throws Exception {
JFrame f = new JFrame();
JTextField nameField;
JTextArea addressArea;
JTextField emailField;
JRadioButton maleButton;
JRadioButton femaleButton;
JRadioButton otherButton;
JComboBox<String> countryComboBox;
JCheckBox hobbyReading;
JCheckBox hobbyTraveling;
JCheckBox hobbySports;
JButton submitButton;
[Link]("User Form");
[Link](450, 450);
[Link](null);
[Link](true);
}
}
Lab 20
Write a java program to use GridLayout.
SOURCE CODE:
import [Link].*;
import [Link].*;
App(){
f= new JFrame();
[Link]("Login Form");
[Link](new GridLayout(4,2,10,10));
userLabel= new JLabel("Username");
[Link]([Link]);
[Link](userLabel);
userText = new JTextField();
[Link](userText);
passwordLabel= new JLabel("Password");
[Link](passwordLabel);
passwordText= new JPasswordField();
[Link](passwordText);
loginButton = new JButton("Login");
[Link](loginButton);
resetButton = new JButton("Reset");
[Link](resetButton);
[Link](250,200);
[Link](true);
}
public static void main(String[] args) throws Exception {
new App();
}
}
Lab 21
Write a java program to use GridBagLayout.
SOURCE CODE:
import [Link].*;
import [Link].*;
public class App {
private JFrame f;
private JLabel userLabel;
private JTextField userText;
private JLabel passwordLabel;
private JPasswordField passwordText;
private JButton loginButton;
private JButton resetButton;
App()
{
f=new JFrame();
[Link]("Login Form");
[Link](new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
[Link]=new Insets(5, 5, 5, 5);
[Link]=[Link];
userLabel=new JLabel("Username");
[Link]=0;
[Link]=0;
[Link](userLabel,gbc);
[Link](250,250);
[Link](true);
}
public static void main(String[] args) throws Exception {
new App();
}
}
Lab 22
Write a program using swing components to add two digits. Use text fields for inputs and
output. The program should display the result when the user presses a button.
SOURCE CODE:
import [Link].*;
import [Link].*;
import [Link].*;
t2 = new JTextField();
[Link](120, 140, 100, 20);
b1 = new JButton("Sum");
[Link](20, 170, 80, 20);
t3 = new JTextField();
[Link](120, 170, 100, 20);
add(l1);
add(t1);
add(l2);
add(t2);
add(b1);
add(t3);
//register listener
[Link](this);//passing current instance
setSize(400,300);
setLayout(null);
setVisible(true);
}
public void actionPerformed(ActionEvent e){
if([Link]()==b1){
}
public static void main(String[] args) throws Exception {
new App();
}
}
Lab23
Write a GUI program using components to find sum and difference of two numbers. Use two
text fields for giving input and a label for output. The program should display sum if user
presses mouse and difference if user release mouse.
SOURCE CODE:
import [Link].*;
import [Link].*;
public class App implements MouseListener{
Label lbloutput;
TextField txtOne;
TextField txtTwo;
App()
{
Frame f=new Frame();
lbloutput = new Label();
[Link](20,50,100,20);
txtOne=new TextField();
[Link](20,80,100,20);
txtTwo=new TextField();
[Link](20,110,100, 20);
[Link](this);
[Link](lbloutput);
[Link](txtOne);
[Link](txtTwo);
[Link](300,300);
[Link](null);
[Link](true);
}
public void mousePressed(MouseEvent e) {
int a=[Link]([Link]());
int b=[Link]([Link]());
int c=a+b;
[Link]([Link](c));
}
public void mouseReleased(MouseEvent e) {
int a=[Link]([Link]());
int b=[Link]([Link]());
int c=a-b;
[Link]([Link](c));
}
public void mouseClicked(MouseEvent e) {
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
Mouse Pressed:
Mouse Released:
Lab 24
Write a java GUI program to calculate square of entered number.
SOURCE CODE:
import [Link].*;
import [Link].*;
import [Link].*;
add(l1);
add(t1);
add(b1);
add(l2);
add(t2);
[Link](this);//passing current instance
setSize(400,300);
setLayout(null);
setVisible(true);
}
public void actionPerformed(ActionEvent e){
int num1 = [Link]([Link]());
if([Link]()==b1){
int square = num1*num1;
[Link]([Link](square));
}
}
public static void main(String[] args) throws Exception {
new App();
}
}
Lab 25
Write a java program to add two digits using RMI.
SOURCE CODE:
[Link]:
import [Link].*;
public interface Adder extends Remote{
public int add(int x, int y)throws RemoteException;
}
[Link]:
import [Link].*;
import [Link].*;
}
}
[Link]:
import [Link].*;
import [Link].*;
import [Link];
public class server extends UnicastRemoteObject implements Adder{
public server() throws RemoteException{
super();
}
public static void main(String[] args) throws RemoteException{
try{
Registry reg=[Link](5000);
[Link]("hi_server", new server());
[Link]("Server is Now Ready..");
}catch(RemoteException e)
{
[Link](e);
}
}
@Override
public int add(int x,int y) throws RemoteException{
return x+y;
}
}
Lab 26
Write a java program to insert five student records and display them all.
SOURCE CODE:
[Link]:
import [Link].*;
[Link]("[Link]");
Connection
con=[Link]("jdbc:mysql://localhost:3306/sevendb?useSSL=false","ro
ot","");
String sql="insert into tblstudents(id,name,address,emailid) values(?,?,?,?)";
PreparedStatement ps = [Link](sql);
[Link](1, id);
[Link](2, name);
[Link](3, email);
[Link](4, gender);
[Link]();
[Link]();
}
catch(Exception e){ [Link](e);}
}
public void DisplayRecord()
{
try {
[Link]("[Link]");
Connection
con=[Link]("jdbc:mysql://localhost:3306/sevendb?useSSL=false","ro
ot","");
Statement stmt=[Link]();
ResultSet rs=[Link]("select * from tblstudents");
while([Link]())
[Link]([Link](1)+" "+[Link](2)+" "+[Link](3)+"
"+[Link](4));
[Link]();
}
catch(Exception e){ [Link](e);}
}
}
Lab 27
Write a simple client and server socket program to read data from client and print in server.
SOURCE CODE:
[Link]:
import [Link].*;
import [Link].*;
public class client{
public static void main(String[] args) throws IOException{
Socket s=new Socket("localhost",4999);
PrintWriter pr=new PrintWriter([Link]());
[Link]("Raseek");
[Link]();
[Link]();
}
}
[Link]:
import [Link].*;
import [Link].*;
public class server {
public static void main(String[] args) throws IOException {
ServerSocket ss=new ServerSocket(4999);
Socket s=[Link]();
[Link]("Client Connected");
InputStreamReader in=new InputStreamReader([Link]());
BufferedReader bf=new BufferedReader(in);
String str=[Link]();
[Link]("Client:"+str);
[Link]();
[Link]();
}
}
Lab 28
Write a java program to split different component of URL from given url:
([Link]
SOURCE CODE:
import [Link].*;
public class App {
public static void main(String[] args) throws MalformedURLException {
URL url1 = new
URL("[Link]
2");
[Link]([Link]());
[Link]();
[Link]("Different components of the given URL:");
[Link]("Protocol: " + [Link]());
[Link]("Hostname: " + [Link]()); [Link]("Default port:- "+
[Link]());
// Retrieving the query part of URL
[Link]("Query: " + [Link]());
// Retrieving the path of URL
[Link]("Path: " + [Link]());
// Retrieving the file name
[Link]("File: " + [Link]());
// Retrieving the reference
[Link]("Reference: " + [Link]());
}
}
Lab 29
Write a
program to
display
source code
of a webpage by URLConnection class.
SOURCE CODE:
import [Link].*;
import [Link].*;
}
}
Lab 30
Write a program to demonstrate lifecycle of servlet.
SOURCE CODE:
[Link]:
<html>
<head>
<title>Lifecycle of Servlet</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form action="LifeCycleServlet">
<input type="submit" value="Invoke Life Cycle Servlet">
</form>
</body>
</html>
[Link]: (Servlet)
import [Link].*;
import [Link].*;
SOURCE CODE:
[Link]:
<html>
<head>
<title>Session Example</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form action="Servlet1" method= "GET" >
User Name: <input type="text" name= "userName" > <br/>
Password:<input type="password" name= "userPassword" > <br/>
<input type="submit" value="Go">
</form>
</body>
</html>
[Link]: (Servlet)
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class Servlet1 extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
[Link]("text/html;charset=UTF-8");
PrintWriter pwriter = [Link]();
String name = [Link]("userName");
String password = [Link]("userPassword");
[Link]("Hello " + name);
HttpSession session = [Link]();//Creating session
[Link]("uname", name);//Adding session with key value
[Link]("upass", password);
[Link]("<br/><a href='welcome'>Click to View details</a>");
[Link]();
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
}
[Link]: (Servlet)
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class Servlet2 extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
[Link]("text/html;charset=UTF-8");
PrintWriter pwriter = [Link]();
HttpSession session = [Link](false);
// The FALSE parameter indicates that you do not want to create a new session if one doesn’t
already exist.
String myName = (String) [Link]("uname");
//retrieving value from session using keyname “uname”
String myPass = (String) [Link]("upass");
[Link]("Name: " + myName + "<br/>Password: " + myPass);
[Link]();
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
}
[Link]:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="6.0" xmlns="[Link]
xmlns:xsi="[Link]
xsi:schemaLocation="[Link]
[Link]
<servlet>
<servlet-name>Servlet1</servlet-name>
<servlet-class>Servlet1</servlet-class>
</servlet>
<servlet>
<servlet-name>Servlet2</servlet-name>
<servlet-class>Servlet2</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Servlet1</servlet-name>
<url-pattern>/login</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Servlet2</servlet-name>
<url-pattern>/welcome</url-pattern>
</servlet-mapping>
</web-app>
Lab 32
Write a program to store, retrieve and delete cookies.
SOURCE CODE:
[Link]:
<html>
<head>
<title>Cookies Example</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form action="Servlet1" method= "POST" >
Name: <input type="text" name= "userName" > <br/>
<input type="submit" value="Go">
</form>
</body>
</html>
[Link]: (Servlet)
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class Servlet1 extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
[Link]("text/html;charset=UTF-8");
try (PrintWriter out = [Link]()) {
String n = [Link]("userName");
// Ensure complete HTML structure
[Link]("<!DOCTYPE html>");
[Link]("<html>");
[Link]("<head>");
[Link]("<title>Welcome Page</title>");
[Link]("</head>");
[Link]("<body>");
// Display welcome message
if (n != null && ![Link]()) {
[Link]("<h1>Welcome, " + n + "!</h1>");
// Create and add cookie
Cookie ck = new Cookie("uname", n);
[Link](ck);
// Add "Go" button
[Link]("<form action='Servlet2' method='GET'>");
[Link]("<input type='submit' value='Go'>");
[Link]("</form>");
} else {
[Link]("<h1>Name is missing! Please go back and try again.</h1>");
}
[Link]("</body>("</html>");
}
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
}
[Link]: (Servlet)
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class Servlet2 extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
[Link]("text/html;charset=UTF-8");
PrintWriter out = [Link]();
Cookie ck[]=[Link]();
[Link]("Hello "+ck[0].getValue());
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
}
[Link]:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="6.0" xmlns="[Link]
xmlns:xsi="[Link]
xsi:schemaLocation="[Link]
[Link]
<servlet>
<servlet-name>Servlet1</servlet-name>
<servlet-class>Servlet1</servlet-class>
</servlet>
<servlet>
<servlet-name>Servlet2</servlet-name>
<servlet-class>Servlet2</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Servlet1</servlet-name>
<url-pattern>/Servlet1</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Servlet2</servlet-name>
<url-pattern>/Servlet2</url-pattern>
</servlet-mapping>
</web-app>
OUTPUTS:
Lab 33
Write a program to a JSP web form to take input of a student and submit it to second JSP file
which may simply print the values of form submission.
SOURCE CODE:
[Link]:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Example</title>
</head>
<body>
<form action="[Link]" method="POST">
Name: <input type="text" name="name"><br><br>
[Link]:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Example</title>
</head>
<body>
<h1>Student Details!</h1>
Name: <%= [Link]("name") %><br>
OUTPUTS: