Important Announcement
PubHTML5 Scheduled Server Maintenance on (GMT) Sunday, June 26th, 2:00 am - 8:00 am.
PubHTML5 site will be inoperative during the times indicated!

Home Explore JEE Technologies Lab Manual

JEE Technologies Lab Manual

Published by Teamlease Edtech Ltd (Amita Chitroda), 2022-08-30 10:42:56

Description: JEE Technologies Lab Manual

Search

Read the Text Version

JAVA JEE Technologies FULL STACK DEVELOPMENT

Objectives of this Lab Manual This lab manual includes - Exercises for hands on practice Guidelines to complete the exercise Learning Outcome

Addition of two numbers using JSP

Problem What will you do? Statement Write a program to add two pre-defined numbers and read the session value using JSP.

Solution What will be the steps Steps to get the output? • Step 1: Use the HTML tags, mention a title and start with the body. • Step 2: Declare the variables along with some random values, for eg 10 and 20. • Step 3: Use the operator and enter the print command for the desired output. • Step 4: Set a sum output to a session. • Step 5: Get the session value and enter the print command for the same.

Code <html> <head> <title>JSP Test Page</title> </head> <body> <%@ page session = \"true\" %> <% int i = 10; int j = 20; int sum = i + j; out.println(\"Sum of i and j will be: \"+sum);

Code session.setAttribute(\"SUMSESSION\",sum); // setting the sum output to a session, SUM is the name of the session variable session.getAttribute(\"SUM\"); // getting the session value out.println(\"<br>Reading session value: \"+ session.getAttribute(\"SUMSESSION\")); %> </body> </html>

Output Output for the Adedxetercxitsheewreil:l- be :- Sum of i and j will be: 30 Reading session value: 30

Learning Outcome After Performing this Add teExxt ehrecries:e- You will be able to write any program using JSP.

Happy Learning!


Like this book? You can publish your book online for free in a few minutes!
Create your own flipbook