Sunday, May 29, 2016

Celsius To Fahrenheit Converter in JSTL

A simple program that I wrote using JSTL or Java Server Pages Standard Tag Library that will ask the user to give a temperature in Celsius and then it will convert in Fahrenheit temperature. The code is very simple and easy to understand.

 Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360



Sample Program Output


Program Listing

celsius.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
<title> Celsius To Fahrenheit Converter in JSTL</title>
</head>
<style>
body 
{
font-family:arial;
font-weight:bold; 
size:12px;
color:blue;
}
</style>
<body>
  <h2> Celsius To Fahrenheit Converter in JSTL</h2>
  <br>
  <form method="post">
     Give temperature in Celsius &nbsp; &nbsp;
    <input type="text" name="cel"  size="3" value="<c:out value="${param.cel}"/>" autofocus/><br>
      <br> <br>
     <input type="submit" value="Find Celsius"  title="Click here to findout the temperature in fahrenheit." />
     <br />
    </form>
<c:if test="${pageContext.request.method=='POST'}">
 <c:set var="convert" scope="session" 
 value="${ (9/5) * param.cel  + 32}"/>
 <br>

The Temperatue in Fahrenheit is <fmt:formatNumber value="${convert}" maxFractionDigits="2"/> &degF.
</c:if>
</body>
</html>

No comments:

Post a Comment