Sneha Java
Sneha Java
Document : index.jsp
--%>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<label for="name">Name:</label>
<label>Gender:</label>
<label for="male">Male</label>
<label for="female">Female</label>
<label for="others">Others</label><br><br>
<label for="address">Address:</label><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>
<label for="painting">Painting</label><br>
<label for="dancing">Dancing</label><br>
<label for="music">Music</label><br><br>
</form>
</body>
</html>
<%--
Document : second
--%>
<!DOCTYPE html>
<html>
<head>
<title>Student Information</title>
</head>
<body>
<h2>Student Information</h2>
<h3>Sneha Bhojane 006</h3><br>
<p><strong>Hobbies:</strong>
<%
} else {
out.print("None selected");
%>
</p>
</body>
</html>
<%--
Document : index
--%>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<label for="name">Name:</label>
<label>Gender:</label>
<label for="male">Male</label>
<label for="female">Female</label>
<label for="others">Others</label><br><br>
<label for="address">Address:</label><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>
<label for="painting">Painting</label><br>
<label for="dancing">Dancing</label><br>
<label for="music">Music</label><br><br>
</form>
</body>
</html>
<%--
Document : second
--%>
<!DOCTYPE html>
<html>
<head>
<title>Student Information</title>
</head>
<body>
<%@page import="java.sql.*"%>
<h2>Student Information</h2>
<%
try{
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/sneha06",
"root", "Sneha@123");
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) {
} else {
}
catch(Exception e){
e.printStackTrace();
%>
</body>
</html>
JSF
INSERT
Index.xhtml
<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>
<br/><br/>
<br/><br/>
</h:form>
</h:body>
</html>
Response.xhtml
<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>
<h:form>
</h:form>
</h:body>
</html>
Jsfinsert.java
package mypack;
/*
*/
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import java.sql.*;
/**
* @author rushd
*/
@ManagedBean
@RequestScoped
String id;
public jsfinsert() {
return name;
this.name = name;
return id;
this.id = id;
return message;
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 (?, ?)";
statement.setString(1, id);
statement.setString(2, name);
int rs = statement.executeUpdate();
if (rs > 0) {
else {
catch (Exception e) {
e.printStackTrace();
}
UPDATE
Index.xhtml
<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>
<br/><br/>
<br/><br/>
</h:form>
</h:body>
</html>
Response.xhtml
<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>
<h:form>
</h:form>
</h:body>
</html>
Jsfupdate.java
package mypack;
/*
*/
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
String name;
String id;
public jsfupdate() {
return name;
this.name = name;
return id;
this.id = id;
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");
statement.setString(1, name);
statement.setString(2, id);
int rs = statement.executeUpdate();
if (rs > 0) {
else {
catch (Exception e) {
e.printStackTrace();
DELETE
Index.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>
<br/><br/>
</h:form>
</h:body>
</html>
Response.xhtml
<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>
<h:form>
</h:form>
</h:body>
</html>
Jsfupdate.java
package mypack;
/*
*/
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
String name;
String id;
public jsfdelete() {
return name;
this.name = name;
}**/
return id;
this.id = id;
return message;
}
try {
Class.forName("com.mysql.jdbc.Driver");
Connection connection =
DriverManager.getConnection("jdbc:mysql://localhost:3306/student_jsf?", "root", "Sneha@123");
statement.setString(1, id);
int rs = statement.executeUpdate();
if (rs > 0) {
else {
catch (Exception e) {
e.printStackTrace();
}
<?xml version='1.0' encoding='UTF-8' ?>
<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>
<br/><br/>
</h:form>
</h:body>
</html>
<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:form>
</h:body>
</html>
package mypack;
/*
*/
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
String name;
String id;
public jsfselect() {
return name;
}
this.name = name;
return id;
this.id = id;
return message;
try {
Class.forName("com.mysql.jdbc.Driver");
Connection connection =
DriverManager.getConnection("jdbc:mysql://localhost:3306/student_jsf?", "root", "Sneha@123");
statement.setString(1, id);
this.id=resultSet.getString("stud_id");
this.name=resultSet.getString("stud_name");
else {
catch (Exception e) {
e.printStackTrace();
}
JSTL
1.
<%--
Document : index
--%>
<!DOCTYPE html>
<html>
<head>
<title>JSP Page</title>
</head>
<body>
<h1>Core Tags</h1>
<p>Name:${name}</p>
<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>
<p>${items}</p>
</c:forEach>
<p>Languages:</p>
<p>${token}</p>
</c:forTokens>
</body>
</html>
<%--
Document : index
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>JSP Page</title>
</head>
<body>
</c:if>
</c:if>
</c:if>
</body>
</html>
<%--
Document : index
--%>
<!DOCTYPE html>
<html>
<head>
<title>JSP Page</title>
</head>
<body>
</sql:query>
<table border="1">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr>
<td>${row.stud_id}</td>
<td>${row.stud_name}</td>
</tr>
</c:forEach>
</tbody>
</table>
<sql:update var="updateResult" dataSource="${db}">
<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">
<sql:param>2</sql:param>
<sql:param>shreya</sql:param>
</sql:update>
</sql:transaction>
</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
<!DOCTYPE html>
<html>
<head>
<title>JSP Page</title>
</head>
<body>
<h3>Enter Dimensions</h3>
<form action="result.jsp" method="post">
<br><br>
<br><br>
<br><br>
</form>
</body>
</html>
Result.jsp
<%--
Document : result
--%>
<!DOCTYPE html>
<html>
<head>
<title>JSP Page</title>
</head>
<body>
<h3> Results:</h3>
<c:set var="length" value="${param.length}" />
<h3>Area of Rectangle</h3>
<h3>Area of Circle</h3>
</body>
</html>
<html>
<head>
<title>JSP Page</title>
</head>
<body>
<h3>Sneha Bhojane006</h3>
</p>
</p>
</p>
</p>
</p>
</p>
</body>
</html>