0% found this document useful (0 votes)
8 views

Sneha Java

java prac

Uploaded by

pranavopshelke
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Sneha Java

java prac

Uploaded by

pranavopshelke
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 41

<%--

Document : index.jsp

Created on : 30 Aug 2024, 12:59:03 pm

Author : SNEHA BHOJANE

--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE html>

<html>

<head>

<title>Student Registration Form</title>

</head>

<body>

<h2>Student Registration Form</h2>

<h3>Sneha Bhojane KTYBSCIT006</h3>

<form action="second.jsp" method="post">

<label for="name">Name:</label>

<input type="text" name="name" id="name" required><br><br>

<label>Gender:</label>

<input type="radio" name="gender" value="Male" id="male" required>

<label for="male">Male</label>

<input type="radio" name="gender" value="Female" id="female">

<label for="female">Female</label>

<input type="radio" name="gender" value="Others" id="others">

<label for="others">Others</label><br><br>

<label for="address">Address:</label><br>

<textarea name="address" id="address" rows="4" cols="30" required></textarea><br><br>

<label for="place">Place:</label>
<select name="place" id="place" required>

<option value="Mumbai">Mumbai</option>

<option value="Delhi">Delhi</option>

</select><br><br>

<label>Hobbies:</label><br>

<input type="checkbox" name="hobby" value="Painting" id="painting">

<label for="painting">Painting</label><br>

<input type="checkbox" name="hobby" value="Dancing" id="dancing">

<label for="dancing">Dancing</label><br>

<input type="checkbox" name="hobby" value="Music" id="music">

<label for="music">Music</label><br><br>

<input type="submit" value="Submit">

</form>

</body>

</html>

<%--

Document : second

Created on : 31 Aug 2024, 7:41:46 pm

Author : SNEHA BHOJANE

--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE html>

<html>

<head>

<title>Student Information</title>

</head>

<body>

<h2>Student Information</h2>
<h3>Sneha Bhojane 006</h3><br>

<p><strong>Name:</strong> <%= request.getParameter("name") %></p>

<p><strong>Gender:</strong> <%= request.getParameter("gender") %></p>

<p><strong>Address:</strong> <%= request.getParameter("address") %></p>

<p><strong>Place:</strong> <%= request.getParameter("place") %></p>

<p><strong>Hobbies:</strong>

<%

String[] hobbies = request.getParameterValues("hobby");

if (hobbies != null && hobbies.length > 0) {

for (String hobby : hobbies) {

out.print(hobby + " ,");

} else {

out.print("None selected");

%>

</p>

</body>

</html>
<%--

Document : index

Created on : 1 Sep, 2024, 12:21:32 PM

Author : SNEHA BHOJANE

--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE html>

<html>

<head>

<title>Student Registration Form</title>

</head>

<body>

<h2>Student Registration Form</h2>

<h3>Sneha Bhojane KTYBSCIT006</h3>

<form action="second.jsp" method="post">

<label for="name">Name:</label>

<input type="text" name="name" id="name" required><br><br>

<label>Gender:</label>

<input type="radio" name="gender" value="Male" id="male" required>

<label for="male">Male</label>

<input type="radio" name="gender" value="Female" id="female">

<label for="female">Female</label>

<input type="radio" name="gender" value="Others" id="others">

<label for="others">Others</label><br><br>

<label for="address">Address:</label><br>

<textarea name="address" id="address" rows="4" cols="30" required></textarea><br><br>

<label for="place">Place:</label>
<select name="place" id="place" required>

<option value="Mumbai">Mumbai</option>

<option value="Delhi">Delhi</option>

</select><br><br>

<label>Hobbies:</label><br>

<input type="checkbox" name="hobby" value="Painting" id="painting">

<label for="painting">Painting</label><br>

<input type="checkbox" name="hobby" value="Dancing" id="dancing">

<label for="dancing">Dancing</label><br>

<input type="checkbox" name="hobby" value="Music" id="music">

<label for="music">Music</label><br><br>

<input type="submit" value="Submit">

</form>

</body>

</html>

<%--

Document : second

Created on : 1 Sep, 2024, 12:22:25 PM

Author : SNEHA BHOJANE

--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE html>

<html>

<head>

<title>Student Information</title>

</head>

<body>
<%@page import="java.sql.*"%>

<%@page import="java.util.*" %>

<h2>Student Information</h2>

<h3>Sneha Bhojane 006</h3><br>

<%

String name= request.getParameter("name");

String Gender= request.getParameter("gender");

String Address = request.getParameter("address");

String Place= request.getParameter("place") ;

String[] hobbies = request.getParameterValues("hobby");

String hobby= String.join(",", hobbies);

try{

Class.forName("com.mysql.cj.jdbc.Driver");

Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/sneha06",
"root", "Sneha@123");

String sql="Insert into student_info(name,Address,gender,place,hobbies)values(?,?,?,?,?)";

PreparedStatement stmt= conn.prepareStatement(sql);

stmt.setString(1,name);

stmt.setString(2, Address);

stmt.setString(3, Gender);

stmt.setString(4, Place);

stmt.setString(5, hobby);

int rowsInserted=stmt.executeUpdate();

if (rowsInserted > 0) {

out.println("<p>Record inserted successfully!</p>");

} else {

out.println("<p>Error inserting record!</p>");

}
catch(Exception e){

e.printStackTrace();

out.println("<p>Error: " + e.getMessage() + "</p>");

%>

</body>

</html>

JSF

INSERT

Index.xhtml

<?xml version='1.0' encoding='UTF-8' ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"

xmlns:h="http://xmlns.jcp.org/jsf/html"

xmlns:f="http://xmlns.jcp.org/jsf/core">

<h:head>
<title>Facelet Title</title>

</h:head>

<h:body>

<h:form>

<h3>Sneha Bhojane 006</h3>

<h3>Enter Student Details</h3>

<h:outputLabel for="id" value="ID: " />

<h:inputText id="id" value="#{jsfinsert.id}" />

<br/><br/>

<h:outputLabel for="name" value="Name: " />

<h:inputText id="name" value="#{jsfinsert.name}" />

<br/><br/>

<h:commandButton value="Save" action="#{jsfinsert.save}" />

</h:form>

</h:body>

</html>

Response.xhtml

<?xml version='1.0' encoding='UTF-8' ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"

xmlns:h="http://xmlns.jcp.org/jsf/html">

<h:head>

<title>Facelet Title</title>
</h:head>

<h:body>

<h3>Insertion Results</h3>

<p><h:outputText value="#{jsfinsert.message}" /></p>

<h:form>

<h:commandLink value="Back to Form" action="index.xhtml" />

</h:form>

</h:body>

</html>

Jsfinsert.java

package mypack;

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

import javax.faces.bean.ManagedBean;

import javax.faces.bean.RequestScoped;

import java.sql.*;

/**

* @author rushd

*/

@ManagedBean

@RequestScoped

public class jsfinsert {


String name;

String id;

private String message;

public jsfinsert() {

public String getName() {

return name;

public void setName(String name) {

this.name = name;

public String getId() {

return id;

public void setId(String id) {

this.id = id;

public String getMessage() {

return message;

public String save() {

try {
Class.forName("com.mysql.jdbc.Driver");

Connection connection =
DriverManager.getConnection("jdbc:mysql://localhost:3306/student_jsf?", "root", "Sneha@123");

String sql = "INSERT INTO student (stud_id, stud_name) VALUES (?, ?)";

PreparedStatement statement = connection.prepareStatement(sql);

statement.setString(1, id);

statement.setString(2, name);

int rs = statement.executeUpdate();

if (rs > 0) {

message = "Student inserted successfully!";

else {

message = "Failed to save student.";

catch (Exception e) {

e.printStackTrace();

message = "An error occurred: " + e.getMessage();

return "response"; // Navigate to response.xhtml

}
UPDATE
Index.xhtml

<?xml version='1.0' encoding='UTF-8' ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"

xmlns:h="http://xmlns.jcp.org/jsf/html"

xmlns:f="http://xmlns.jcp.org/jsf/core">

<h:head>
<title>Facelet Title</title>

</h:head>

<h:body>

<h:form>

<h3>Sneha Bhojane 006</h3>

<h3>Enter Student Details</h3>

<h:outputLabel for="id" value="ID: " />

<h:inputText id="id" value="#{jsfupdate.id}" />

<br/><br/>

<h:outputLabel for="name" value="Name: " />

<h:inputText id="name" value="#{jsfupdate.name}" />

<br/><br/>

<h:commandButton value="Update" action="#{jsfupdate.update}" />

</h:form>

</h:body>

</html>

Response.xhtml

<?xml version='1.0' encoding='UTF-8' ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"

xmlns:h="http://xmlns.jcp.org/jsf/html">

<h:head>

<title>Facelet Title</title>
</h:head>

<h:body>

<h3>Update Result</h3>

<p><h:outputText value="#{jsfupdate.message}" /></p>

<h:form>

<h:commandLink value="Back to Update Form" action="index.xhtml" />

</h:form>

</h:body>

</html>

Jsfupdate.java

package mypack;

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

import javax.faces.bean.ManagedBean;

import javax.faces.bean.RequestScoped;

import java.sql.*;

import java.sql.DriverManager;

import java.sql.Connection;

/**

* @author rushd

*/
@ManagedBean

@RequestScoped

public class jsfupdate {

String name;

String id;

private String message;

public jsfupdate() {

public String getName() {

return name;

public void setName(String name) {

this.name = name;

public String getId() {

return id;

public void setId(String id) {

this.id = id;

public String getMessage() {

return message;

}
public String update() {

try {

Class.forName("com.mysql.jdbc.Driver");

Connection connection =
DriverManager.getConnection("jdbc:mysql://localhost:3306/student_jsf?", "root", "Sneha@123");

String sql = "UPDATE student SET stud_name=? WHERE stud_id=?";

PreparedStatement statement = connection.prepareStatement(sql);

statement.setString(1, name);

statement.setString(2, id);

int rs = statement.executeUpdate();

if (rs > 0) {

message = "Student inserted successfully!";

else {

message = "Failed to save student.";

catch (Exception e) {

e.printStackTrace();

message = "An error occurred: " + e.getMessage();

return "response"; // Navigate to response.xhtml

DELETE
Index.xhtml

<?xml version='1.0' encoding='UTF-8' ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"

xmlns:h="http://xmlns.jcp.org/jsf/html"

xmlns:f="http://xmlns.jcp.org/jsf/core">

<h:head>

<title>Facelet Title</title>

</h:head>

<h:body>

<h:form>

<h3>Sneha Bhojane 006</h3>

<h3>Enter Student Details</h3>

<h:outputLabel for="id" value="ID: " />

<h:inputText id="id" value="#{jsfdelete.id}" />

<br/><br/>

<h:commandButton value="Deletee" action="#{jsfdelete.update}" />

</h:form>

</h:body>

</html>

Response.xhtml

<?xml version='1.0' encoding='UTF-8' ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"

xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>

<title>Facelet Title</title>

</h:head>

<h:body>

<h3>Update Result</h3>

<p><h:outputText value="#{jsfdelete.message}" /></p>

<h:form>

<h:commandLink value="Back to Delete Form" action="index.xhtml" />

</h:form>

</h:body>

</html>

Jsfupdate.java

package mypack;

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

import javax.faces.bean.ManagedBean;

import javax.faces.bean.RequestScoped;

import java.sql.*;

import java.sql.DriverManager;

import java.sql.Connection;

/**

*
* @author rushd

*/

@ManagedBean

@RequestScoped

public class jsfdelete {

String name;

String id;

private String message;

public jsfdelete() {

/**public String getName() {

return name;

public void setName(String name) {

this.name = name;

}**/

public String getId() {

return id;

public void setId(String id) {

this.id = id;

public String getMessage() {

return message;
}

public String update() {

try {

Class.forName("com.mysql.jdbc.Driver");

Connection connection =
DriverManager.getConnection("jdbc:mysql://localhost:3306/student_jsf?", "root", "Sneha@123");

String sql = "DELETE from student where stud_id=?";

PreparedStatement statement = connection.prepareStatement(sql);

statement.setString(1, id);

int rs = statement.executeUpdate();

if (rs > 0) {

message = "Student deleted successfully!";

else {

message = "Failed to save student.";

catch (Exception e) {

e.printStackTrace();

message = "An error occurred: " + e.getMessage();

return "response"; // Navigate to response.xhtml

}
<?xml version='1.0' encoding='UTF-8' ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"

xmlns:h="http://xmlns.jcp.org/jsf/html"

xmlns:f="http://xmlns.jcp.org/jsf/core">

<h:head>

<title>Facelet Title</title>

</h:head>

<h:body>

<h:form>

<h3>Sneha Bhojane 006</h3>

<h3>Enter Student ID to view Details</h3>

<h:outputLabel for="id" value="ID: " />

<h:inputText id="id" value="#{jsfselect.id}" />

<br/><br/>

<h:commandButton value="Select" action="#{jsfselect.select}" />

</h:form>
</h:body>

</html>

<?xml version='1.0' encoding='UTF-8' ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"

xmlns:h="http://xmlns.jcp.org/jsf/html">

<h:head>

<title>Facelet Title</title>

</h:head>

<h:body>

<h3>Stident_details</h3>

<p><h:outputText value="ID:#{jsfselect.id}"/></p>

<p><h:outputText value="Name:#{jsfselect.name}"/></p>

<h:form>

<h:commandLink value="Back to Delete Form" action="index.xhtml" />

</h:form>

<p><h:outputText value="#{jsfselect.message}" /></p>

</h:body>

</html>
package mypack;

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

import javax.faces.bean.ManagedBean;

import javax.faces.bean.RequestScoped;

import java.sql.*;

import java.sql.DriverManager;

import java.sql.Connection;

/**

* @author rushd

*/

@ManagedBean

@RequestScoped

public class jsfselect {

String name;

String id;

private String message;

public jsfselect() {

public String getName() {

return name;
}

public void setName(String name) {

this.name = name;

public String getId() {

return id;

public void setId(String id) {

this.id = id;

public String getMessage() {

return message;

public String select() {

try {

Class.forName("com.mysql.jdbc.Driver");

Connection connection =
DriverManager.getConnection("jdbc:mysql://localhost:3306/student_jsf?", "root", "Sneha@123");

String sql = "SELECT * from student where stud_id=?";

PreparedStatement statement = connection.prepareStatement(sql);

statement.setString(1, id);

ResultSet resultSet = statement.executeQuery();


if (resultSet.next()) {

this.id=resultSet.getString("stud_id");

this.name=resultSet.getString("stud_name");

else {

message = "Failed to save student.";

catch (Exception e) {

e.printStackTrace();

message = "An error occurred: " + e.getMessage();

return "response"; // Navigate to response.xhtml

}
JSTL

1.

<%--

Document : index

Created on : 2 Sep, 2024, 11:41:23 AM

Author : SNEHA BHOJANE

--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>JSP Page</title>

</head>

<body>

<h1>Core Tags</h1>

<c:out value="${'ALL CORE TAGS'}" ></c:out>

<c:set var="name" value="Sneha"></c:set>

<p>Name:${name}</p>

<c:set var="rollno" value="006"></c:set>

<c:out value="Roll No:${rollno}"></c:out>

<c:remove var="rollno"></c:remove>

<c:if test="${name=='Sneha'}">

<p>Hello ${name}</p>

</c:if>

<c:choose>
<c:when test="${name=='Sneha'}">

<p>Welcome!! ${name}</p>

</c:when>

<c:otherwise>

<p>Welcome!! Guest</p>

</c:otherwise>

</c:choose>

<c:set var="items" value="${['red','green','yellow','pink']}"></c:set>

<c:out value="Values are:"></c:out>

<c:forEach var="items" items="${items}">

<p>${items}</p>

</c:forEach>

<c:set var="str" value="java,C,python,android" />

<p>Languages:</p>

<c:forTokens var="token" items="${str}" delims=",">

<p>${token}</p>

</c:forTokens>

</body>

</html>
<%--

Document : index

Created on : 2 Sep, 2024, 11:41:23 AM

Author : SNEHA BHOJANE

--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>JSP Page</title>

</head>

<body>

<h3>Sneha Bhojane 006</h3>

<h3>All Function Tags </h3>

<c:set var="str" value="HII!! Sneha Bhojane!" />

<c:out value="String: ${str}"></c:out>

<c:if test="${fn:contains(str, 'HII')}">

<p>Found hii string<p>

</c:if>

<c:if test="${fn:containsIgnoreCase(str, 'HII')}">

<p>Found hii string<p>

</c:if>

<c:if test="${fn:endsWith(str, 'Bhojane')}">

<p>String ends with Bhojane!<p>

</c:if>

<c:if test="${fn:startsWith(str, 'HII!!')}">

<p>String starts with HII!!<p>


</c:if>

<p>Length of string: <c:out value="${fn:length(str)}" /></p>

<p>Substring (start at 7, end at 11): <c:out value="${fn:substring(str, 7, 11)}" /></p

<c:set var="xmlStr" value="It is <abc>second String</abc>" />

<p>Escaped XML: <c:out value="${fn:escapeXml(xmlStr)}" /></p>

<p>Index of 'Sneha' in string: <c:out value="${fn:indexOf(str, 'Sneha')}" /></p>

<p>Replace 'Sneha' with 'Shreya': <c:out value="${fn:replace(str, 'Sneha', 'Shreya')}" /></p>

<p>Uppercase string: <c:out value="${fn:toUpperCase(str)}" /></p>

<p>Lowercase string: <c:out value="${fn:toLowerCase(str)}" /></p>

<c:set var="str" value="java programming" />

<c:set var="str1" value="${fn:split(str,' ')}" />

<c:out value="${fn:join(str1,'-')}" />

</body>

</html>
<%--

Document : index

Created on : 2 Sep, 2024, 11:41:23 AM

Author : SNEHA BHOJANE

--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>JSP Page</title>
</head>

<body>

<h3>Sneha Bhojane 006</h3>

<h3>All SQL Tags </h3>

<sql:setDataSource var="db" driver="com.mysql.jdbc.Driver"


url="jdbc:mysql://localhost:3306/student_jsf?"

user="root" password="Sneha@123" />

<sql:query var="result" dataSource="${db}">

SELECT * FROM student

</sql:query>

<table border="1">

<thead>

<tr>

<th>ID</th>

<th>Name</th>

</tr>

</thead>

<tbody>

<c:forEach var="row" items="${result.rows}">

<tr>

<td>${row.stud_id}</td>

<td>${row.stud_name}</td>

</tr>

</c:forEach>

</tbody>

</table>
<sql:update var="updateResult" dataSource="${db}">

UPDATE student SET stud_name =? WHERE stud_id = ?;

<sql:param>sne</sql:param>

<sql:param>1</sql:param>

</sql:update>

<c:if test="${updateResult==1}">

Update Successfully!

</c:if>

<sql:transaction dataSource="${db}">

<sql:update var="rs">

Insert into student values(?,?);

<sql:param>2</sql:param>

<sql:param>shreya</sql:param>

</sql:update>

</sql:transaction>

<sql:query var="result" dataSource="${db}">

SELECT * FROM student

</sql:query>

<table border="1">

<thead>

<tr>

<th>ID</th>

<th>Name</th>

</tr>

</thead>

<tbody>
<c:forEach var="row" items="${result.rows}">

<tr>

<td>${row.stud_id}</td>

<td>${row.stud_name}</td>

</tr>

</c:forEach>

</tbody>

</table>

</body>

</html>

Index.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>JSP Page</title>

</head>

<body>

<h3>Rushda Khan, KSBSCIT022</h3>

<h3>Enter Dimensions</h3>
<form action="result.jsp" method="post">

<label for="length">Length of Rectangle:</label>

<input type="number" id="length" name="length" step="0.01" required>

<br><br>

<label for="width">Width of Rectangle:</label>

<input type="number" id="width" name="width" step="0.01" required>

<br><br>

<label for="radius">Radius of Circle:</label>

<input type="number" id="radius" name="radius" step="0.01" required>

<br><br>

<input type="submit" value="Calculate">

</form>

</body>

</html>

Result.jsp

<%--

Document : result

Created on : 4 Sep, 2024, 7:53:08 PM

Author : SNEHA BHOJANE

--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>JSP Page</title>

</head>

<body>

<h3> Results:</h3>
<c:set var="length" value="${param.length}" />

<c:set var="width" value="${param.width}" />

<c:set var="radius" value="${param.radius}" />

<c:set var="arearect" value="${length * width}" />

<c:set var="areacircle" value="${3.14159 * radius * radius}" />

<h3>Area of Rectangle</h3>

<p>Length: <c:out value="${length}" /> units</p>

<p>Width: <c:out value="${width}" /> units</p>

<p>Area: <c:out value="${arearect}" /> square units</p>

<h3>Area of Circle</h3>

<p>Radius: <c:out value="${radius}" /> units</p>

<p>Area: <c:out value="${areacircle}" /> square units</p>

</body>

</html>

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>JSP Page</title>

</head>

<body>

<h3>Sneha Bhojane006</h3>

<h3>All Formatting Tags </h3>

<c:set var="number" value="123" />

<c:set var="date" value="<%= new java.util.Date() %>" />

<c:set var="currencyValue" value="123.567" />

<p>Formatted Number (Default):

<fmt:formatNumber value="${number}" />

</p>

<p>Formatted Number (Integer):

<fmt:formatNumber value="${number}" type="number" maxFractionDigits="0" />

</p>

<p>Formatted Number (Currency):

<fmt:formatNumber value="${currencyValue}" type="currency" />

</p>

<p>Formatted Date (Default):

<fmt:formatDate value="${date}" type="date" />

</p>

<p>Formatted Time (Default):


<fmt:formatDate value="${date}" type="time" />

</p>

<p>Formatted Date and Time:

<fmt:formatDate value="${date}" type="both" />

</p>

</body>

</html>

You might also like