Reader Level:
ARTICLE

Performing Calculation in JSP

Posted by Vikas Mishra Articles | JSP January 11, 2012
In this article, I am going to describe an application of how to perform a calculation in JSP.
  • 0
  • 0
  • 9734
Download Files:
 

In this article, I am going to describe an application through netbeans to perform a calculation in JSP. This article will help you to understand the concept of basic JSP.To develop this application we use the following steps.

Step 1 : Create a New Project.

In this step we select New Project option from file menu.

create new project.jpg


Step 2: Choose Project.

In this step we select web application from Java web option and then click on the next button.

select new web application.jpg

Step 3: Name and Location.

In this step we given it a specific name and set a specific location and click on the next button.

name and location.jpg
 

Step 4: Server and Setting.

We select a specific server for this application and click on the next button.

server and setting.jpg

Step 5 : Select Framework.

There is no need to select any framework for this application; just click on the finish button.

selectframework.jpg

Step 6 : Create JSP file.

We create one JSP file for this application.

create new jsp file.jpg

add.jsp

<%@ page contentType="text/html" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>
JSP calculation</title>
</head>
<body bgcolor="cyan">
<h1>Calculation through JSP is as </h1>
1 + 2 + 3<c:out value="${1 + 2 + 3}"/>
</body>
</html>

mul.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>
Multiplication Examples</title>
</head>
<body bgcolor="cyan">
<h3>Out Example</h3>
10 * 45 =
<c:out value="${10*45}" />
<br />
</body>
</html>


Step 7:
Compile and Run the application.

Now we compile the application and then run it on the server and find the following output.

Output

add.jsp

add.jsp.jpg

mul.jsp

mul.jsp.jpg

Resources related to this topic

COMMENT USING