Ajp 7040
Ajp 7040
Ajp 7040
PRACTICAL-1
AIM:- IMPLEMENT TCP SERVER FOR TRANSFERRING FILES USING
SOCKET AND SERVERSOCKET.
Server:
import java.io.*;
import java.net.*;
class P1Server {
public static void main(String args[]) throws Exception {
try (ServerSocket ss = new ServerSocket(7777);
Socket s = ss.accept())
{
System.out.println("connected. ........ ");
FileInputStream fin=new FileInputStream("Send.txt");
DataOutputStream dout=new DataOutputStream(s.getOutputStream());
int r;
while((r=fin.read())!=-1) {
dout.write(r);
}
System.out.println("\nFile tranfer Completed");
}
}
}
Output:
1
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
Client:
import java.io.*;
import java.net.*;
public class P2Client {
public static void main(String[] args) throws Exception {
try (Socket s = new Socket("127.0.0.1",7777)) {
if(s.isConnected()) {
System.out.println("Connected to server");
}
FileOutputStream fout;
fout = new FileOutputStream("S2.txt");
DataInputStream din=new DataInputStream(s.getInputStream());
int r;
while((r=din.read())!=-1) {
fout.write((char)r);
}
}
}
}
2
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
Output:
3
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
PRACTICAL-2
AIM:- IMPLEMENT COOKIES TO STORE FIRSTNAME AND
LASTNAME USING JAVA SERVER PAGES.
index.html
<!DOCTYPE html>
<html>
<head>
<title>Setting Cookies</title>
</head>
<body>
<h1>Setting Cookies</h1>
<form action="main.jsp" method="GET">
First Name: <input type="text" name="first_name"> <br /><br/> Last
Name: <input type="text" name="last_name" /><br/><br/> <input type="submit"
value="Submit" />
</form>
</body>
</html>
main.jsp
<%
// Create cookies for first and last names.
Cookie firstName = new Cookie("first_name", request.getParameter("first_name"));
Cookie lastName = new Cookie("last_name", request.getParameter("last_name"));
// Set expiry date after one hour for both the cookies.
firstName.setMaxAge(60 * 60);
lastName.setMaxAge(60 * 60);
// Add both the cookies in the response header. response.addCookie(firstName);
response.addCookie(lastName);
%>
<html>
<body>
<h1>Setting Cookies</h1>
<ul>
<b>First Name:</b><%=request.getParameter("first_name")%><br /><br/>
<b>Last Name:</b><%=request.getParameter("last_name")%>
</body>
</html>
4
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
Output:
5
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
PRACTICAL -3
AIM:- IMPLEMENT THE SHOPPING CART FOR USERS FOR THE
ONLINE SHOPPING. APPLY THE CONCEPT OF SESSION.
Index.jsp
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Shopping Cart - Login</title>
</head>
<body background="img/bg1.jpg"><center>
<div class="container">
<div class="headbanner">
<h1>
<center>
<img src="img/shopping.png" />[My Shopping Cart] </center>
</h1>
</div>
<div class="mycontent">
<div class="space"><span><a class="formtext">Login</a></span></div>
<div class="formcontent">
<form action="loginval" method="post">
<table border="2px">
<tr>
<td class="formtext">Username :</td>
<td><input id="name" name="uname" type="text" size="30" /></td><td><a>[Any
name]</a></td>
</tr>
<tr>
<td class="formtext">Password :</td>
<td><input id="pas" name="pass" type="password" size="30" /></td><td><a>[Pass
=1234]</a></td>
</tr>
<tr>
<td colspan="3"><center> <input type="submit" value="Submit"/></td></center>
</tr>
</table>
</form>
</div>
</div>
</div>
</center>
</body>
</html>
Shop.jsp
<%@page import="java.util.ArrayList"%>
6
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
<%@ page import="classes.Item" %>
<!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">
<head>
<%
String user = (String) session.getAttribute("user"); if (user == null) {
response.sendRedirect("index.jsp");
}
%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Shopping Cart -
Shop</title>
</head>
<body background="img/bg3.jpg"><center>
<div class="container">
<form action="requesthandle" method="post">
<div class="headbanner">
<h1>
<center>
<img src="img/shopping.png" />[My Shopping Cart] </center>
</h1>
</div>
<div class="mycontent">
<div class="cartof">
<center><a>Cart Of [<% out.print(session.getAttribute("user"));%>]<input
name="logout" type="submit" value="Logout"></input></a></center>
</div>
<div class="cartcontent">
<div class="myitems">
<table width="600px" cellpadding="0" cellspacing="0" border="2px">
<tr>
<th>#id</th>
<th>Item</th>
<th>Price</th>
<th>Action</th>
</tr>
<%if (session.getAttribute("itemlist") != null) {
ArrayList mycart = (ArrayList) session.getAttribute("itemlist"); for (int i = 0; i < mycart.size();
i++) {
Item it = (Item) mycart.get(i); %>
<tr>
<td align="center"><%out.print(i);%></td>
<td align="center"><% out.print(it.name);%></td>
<td align="center"><% out.print(it.price);%></td>
<td align="center"><input name="del" type="submit" value="Delete"
onclick="this.value=<%out.print(i);%>"></input></td>
</tr>
<%}
7
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
}
%>
</table>
</div>
<div class="total">
<a>My Total : $[<% out.print(session.getAttribute("total"));%>]</a><br />
<a>Total Qty: [<% ArrayList il = (ArrayList)
session.getAttribute("itemlist");
out.print(il.size());%>]</a><br />
<input name="chkout" type="submit" value="Checkout" /> </div>
</div>
<div class="items">
<table width="900px" border="2px">
<tr class="border_bottom">
<td>#1</td>
<td>Sunglass</td>
<td>Ray-Ban, Dark Purple Sunglass with the Casing</td>
<td>$34</td>
<td><img src="img/sunglass.jpg" width="90" height="90" /></td>
<td><input name="addtocart1" type="submit" value="Add to Cart" /></td>
</tr>
<tr class="border_bottom">
<td>#2</td>
<td>Wrist Watch</td>
<td>Quartz, Men's wrist watch, Black</td>
<td>$66</td>
<td><img src="img/watch.jpg" width="90" height="90" /></td>
<td><input name="addtocart2" type="submit" value="Add to Cart" /></td>
</tr>
<tr class="border_bottom">
<td>#3</td>
<td>Camera</td>
<td>Lumix, 16x Digital Camera</td>
<td>$167</td>
<td><img src="img/camera.jpg" width="90" height="90" /></td>
<td><input name="addtocart3" type="submit" value="Add to Cart" /></td>
</tr>
<tr class="border_bottom">
<td>#4</td>
<td>Shoes</td>
<td>Bettans, 60 Leather Shoes, Brown</td>
<td>$23</td>
</tr>
<td><img src="img/shoes.jpg" width="90" height="90" /></td>
<td><input name="addtocart4" type="submit" value="Add to Cart" /></td>
</table>
</div>
</div>
8
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
</form>
</div>
</center> </body>
</html>
Error.jsp
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Shopping Cart - Login</title>
<title>Shopping Cart - Login</title>
</head>
<body background="img/bg1.jpg">
<center>
<form action="index.jsp" method="post">
<div class="container">
<div class="headbanner">
<h1><center>
<img src="img/shopping.png" />[My Shopping Cart]
</center></h1>
</div>
<div class="mycontent">
<h3 align="center">Oops! Error<br />Your password is incorrect, Try
Again!<br /><input type="submit" value="Back" /></h3> </div>
</div>
</form>
</center>
</body>
</html>
Checkout.jsp
<%@page import="java.util.ArrayList"%>
<%@ page import="classes.Item" %>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Shopping Cart - Check out</title>
</head>
<body background="img/bg1.jpg"><center>
<form action="purchase" method="post">
<% ArrayList it_list = (ArrayList) session.getAttribute("itemlist"); %>
<div class="container">
<div class="headbanner"> <h1><center>
<img src="img/shopping.png" />[My Shopping Cart]
</center></h1>
9
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
</div>
<div class="mycontent">
<a>Checkout My Cart</a><br />
<table width="500px" border="2px">
<% for (int i = 0; i < it_list.size(); i++) { classes.Item itm = (Item) it_list.get(i); %>
<tr>
<td><%out.print(itm.name);%></td>
<td><%out.print(itm.price);%></td>
</tr>
<% }%>
<tr>
<td>My Total</td><td>$[<%out.print(session.getAttribute("total"));%>]</td>
</tr>
<tr>
<td><input type="submit" value="Purchase" /></td>
</tr>
<tr>
<td><img src="img/paywith.png" width="210" height="80" /></td></tr>
</table>
</div>
</div>
</form>
</center>
</body>
</html>
Success.jsp
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Shopping Cart - Success</title>
</head>
<body background="img/bg1.jpg"><center>
<%if(session.getAttribute("purch")!="true"){response.sendRedirect("index.jsp");
} %>
<form action="shop.jsp" method="post">
<div class="container">
<div class="headbanner"> <h1><center>
<img src="img/shopping.png" />[My Shopping Cart] </center></h1>
</div>
<div class="mycontent">
<h3 align="center">Purchase has been succeeded! Thank You.<br /><input type="submit"
value="Ok" /></h3>
</div>
</div>
10
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
</form>
</center>
</body>
</html>
RequestHandle.java
import classes.Item;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class requesthandle extends HttpServlet
{
protected void processRequest(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
{
response.setContentType("text/html;charset=UTF-8"); PrintWriter out =
response.getWriter();
response.setContentType("text/html;charset=UTF-8");
HttpSession mysession = request.getSession();
ArrayList mycart = (ArrayList) mysession.getAttribute("itemlist"); int value = (Integer)
mysession.getAttribute("total"); String i1 = request.getParameter("addtocart1");
String i2 = request.getParameter("addtocart2");
String i3 = request.getParameter("addtocart3");
String i4 = request.getParameter("addtocart4"); String chk =
request.getParameter("chkout");
String logout = request.getParameter("logout");
String pressdel = request.getParameter("del");
if (i1 != null)
{
Item myitem = new Item("#1", "Sunglass", 34);
value = value + 34;
mycart.add(myitem);
mysession.setAttribute("itemlist", mycart);
mysession.setAttribute("total", value);
response.sendRedirect("shop.jsp");
}
else if (i2 != null)
{
Item myitem = new Item("#2", "Wrist Watch", 66);
value = value + 66;
mycart.add(myitem);
mysession.setAttribute("itemlist", mycart);
mysession.setAttribute("total", value);
11
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
response.sendRedirect("shop.jsp");
}
else if (i3 != null)
{
Item myitem = new Item("#3", "Camera", 167); value = value + 167;
mycart.add(myitem);
mysession.setAttribute("itemlist", mycart); mysession.setAttribute("total", value);
response.sendRedirect("shop.jsp");
}
else if (i4 != null)
{
Item myitem = new Item("#4", "Shoes", 23); value = value + 23;
mycart.add(myitem);
mysession.setAttribute("itemlist", mycart); mysession.setAttribute("total", value);
response.sendRedirect("shop.jsp");
}
else if (chk != null)
{
mysession.setAttribute("chk", chk);
response.sendRedirect("checkout.jsp");
}
else if (logout != null)
{
mysession.invalidate();
response.sendRedirect("index.jsp");
}
else if (pressdel != null)
{
Item item_to_Delete = (Item) mycart.get(Integer.parseInt(pressdel));
value = value - item_to_Delete.price;
mysession.setAttribute("total", value);
mycart.remove(Integer.parseInt(pressdel));
mysession.setAttribute("tod", pressdel);
response.sendRedirect("shop.jsp");
}
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
processRequest(request, response);
}
@Override
public String getServletInfo() { return "Short description";
12
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
}// </editor-fold>
}
Loginval.java
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import javax.jms.Session;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.xml.ws.Dispatch;
public class loginval extends HttpServlet
{
protected void processRequest(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
{
}
Else
{
}
}
String username = (String) request.getParameter("uname"); String password =
(String) request.getParameter("pass"); if (password.equals("1234")) { ArrayList
cart = new ArrayList(); int totalcost = 0;
HttpSession mysession = request.getSession(); mysession.setAttribute("user",
username); mysession.setAttribute("itemlist", cart);
mysession.setAttribute("total", totalcost); response.sendRedirect("shop.jsp");
response.sendRedirect("error.jsp");
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
{
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
{
processRequest(request, response);
}
@Override
public String getServletInfo()
{
return "Short description";
}// </editor-fold>
13
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
}
Addtocart.java
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class addtocart extends HttpServlet
{
protected void processRequest(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
{
processRequest(request, response);
}
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
processRequest(request, response);
}
@Override
public String getServletInfo() { return "Short description";
}// </editor-fold>
}
Purchase.java
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class purchase extends HttpServlet
{
protected void processRequest(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
{
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter(); ArrayList newlist = new ArrayList();
14
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
int newval = 0;
HttpSession mysession = request.getSession();
}
@Override
mysession.setAttribute("purch", "true"); mysession.setAttribute("itemlist",
newlist); mysession.setAttribute("total", newval);
response.sendRedirect("success.jsp");
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
{
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
{
processRequest(request, response);
}
@Override
public String getServletInfo()
{
return "Short description";
}// </editor-fold>
}
Item.java
package classes;
public class Item
{
public String id;
public String name;
public int price;
public Item(String a, String b, int c)
{
this.id = a; this.name = b; this.price = c;
}
}
Output:
• Login Page
15
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
• Shopping Page for User1 where User1 can Add the Product to Cart as well as Delete the
Product from the Cart and Also Checkout with Selected Product and Can also Logout.
16
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
17
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
PRACTICAL -4
AIM:- IMPLEMENT STUDENT REGISTRATION FORM WITH
ENROLLMENT NUMBER, FIRST NAME, LAST NAME, SEMESTER,
CONTACT NUMBER. STORE THE DETAILS IN DATABASE. ALSO
IMPLEMENT SEARCH, DELETE AND MODIFY FACILITY FOR
STUDENT RECORDS.
Index.html
<html>
<head>
<title>Students Details</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<center>
<h1><b>Perform Following Operation</b></h1>
<table border="">
<tr><td><a href="insert.html" with="100"
height="100">REGISTRATION</a></td></tr>
<tr><td><a href="search.html" with="100"
height="100">SEARCH</a></td></tr>
<tr><td><a href="update.html" with="100"
height="100">UPDATE</a></td></tr>
<tr><td><a href="delete.html" with="100"
height="100">DELETE</a></td></tr> </table>
</center>
</body>
</html>
Insert.html
<html>
<head>
<title>Student Details</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<center>
<form action="Servlet1">
<h1><b>REGISTRATION FORM</b></h1>
<table border="">
<tr><td>First Name:</td><td><input type="text" name="fname"
value=""></td></tr>
<tr><td>Last Name:</td><td><input type="text" name="lname" value=""></td></tr>
<tr><td>Semester:</td><td><input type="number" name="sem" value=""></td></tr>
<tr><td>Contact No:</td><td><input type="text" name="contact"
value=""></td></tr>
18
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
<tr><td>Enrollment:</td><td><input type="text" name="enroll" value=""></td></tr>
</table>
<table border="">
<br>
<tr><td><input type="submit" name="Save" value="Save"></td></tr> </table>
</form>
</center>
</body>
</html>
Search.html
<html>
<head>
<title>Student Details</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<center>
<form action="Servlet4">
<h1><b>SEARCH RECORD</b></h1>
<table border="">
<tr><td>Enter Name You want to search a record :</td><td><input type="text"
name="fname" value=""></td></tr>
</table>
<table border="">
<br>
<tr><td><input type="Submit" name="Save" value="Search"></td></tr> </table>
</form>
</center>
</body>
</html>
Update.html
<html>
<head>
<title>Student Details</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<center>
<form action="Servlet2">
<h1><b>UPDATE RECORD</b></h1>
<table border="">
<tr><td>Enter Enrollment You want to update a record :</td><td><input type="text"
name="enroll" value=""></td></tr>
<tr><td>Enter Name of your Enrollment You want to update a
19
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
record :</td><td><input type="text" name="fname" value=""></td></tr> </table>
<table border="">
<br>
<tr><td><input type="Submit" name="Save" value="UPDATE"></td></tr>
</table>
</form>
</center>
</body>
</html>
Delete.html
<html>
<head>
<title>Student Details</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<center>
<form action="Servlet3">
<h1><b>DELETE RECORD</b></h1>
<table border="">
<tr><td>Enter Name You want to delete record :</td><td><input type="text"
name="fname" value=""></td></tr>
</table>
<table border="">
<br>
<tr><td><input type="Submit" name="Save" value="DELETE"></td></tr> </table>
</form>
</center>
</body>
</html>
Servlet1.java
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Servlet1 extends HttpServlet
{
Statement st=null; Connection con=null;
static final String DB_URL="jdbc:mysql://localhost:3306/students"; static
final String USER="root"; static final String PASS="";
20
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
protected void processRequest(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
{
response.setContentType("text/html;charset=UTF-8"); try (PrintWriter out =
response.getWriter())
{
String s1,s2,s3,s4,s5,sql;
s1=request.getParameter("fname");
s2=request.getParameter("lname");
s3=request.getParameter("sem");
s4=request.getParameter("contact");
s5=request.getParameter("enroll");
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet Data Insertion</title>");
out.println("</head>");
out.println("<body>");
out.println("<h3>First Name: " + s1 + "</h3>");
out.println("<h3>Last Name: " + s2 + "</h3>");
out.println("<h3>Semester: " + s3 + "</h3>");
out.println("<h3>Contact: " + s4 + "</h3>");
out.println("<h3>Enrollment: " + s5 + "</h3>");
out.println("</body>");
out.println("</html>");
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(DB_URL,USER,PASS); st =
con.createStatement();
sql=" insert into student_18(fname,lname,enroll,contact,sem)
values('"+s1+"','"+s2+"','"+s5+"','"+s4+"', '"+s3+"')";
st.executeUpdate(sql);
System.out.println("Record Inserted Sucessfuly...");
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
21
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
processRequest(request, response);
}
@Override
public String getServletInfo()
{
return "Short description";
}
}
Servlet2.java
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Servlet2 extends HttpServlet
{
Statement st=null;
Connection con=null;
ResultSet rs; static final String DB_URL="jdbc:mysql://localhost:3306/students";
static final String USER="root"; static final String PASS="";
protected void processRequest(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
{
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter())
{
String s1,s2,sql;
s1=request.getParameter("fname");
s2=request.getParameter("enroll");
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Record Updation</title>");
out.println("</head>");
out.println("<body>");
out.println("<h3>Name Changed Succesfully </h3>");
out.println("</body>");
out.println("</html>");
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(DB_URL,USER,PASS);
st = con.createStatement();
sql=" update student_18 set fname= '"+s1+"' where enroll='"+s2+"' ";
22
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
st.executeUpdate(sql);
System.out.println("Record Updated Sucessfuly...");
rs = st.executeQuery("select * from student_18 where fname='"+s1+"'");
while(rs.next())
{
out.println("<h5>First Name:-"+rs.getString(1)+ "</h5>");
out.println("<h5>Last Name:-"+rs.getString(2)+ "</h5>");
out.println("<h5>Enrollment:-"+rs.getString(3)+ "</h5>");
out.println("<h5>Contact No:-"+rs.getString(4)+ "</h5>");
out.println("<h5>Sem:-"+rs.getString(5)+ "</h5>");
}
out.println("</body>");
out.println("</html>");
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
processRequest(request, response);
}
@Override
public String getServletInfo()
{
return "Short description";
}// </editor-fold>}
Servlet3.java
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Servlet3 extends HttpServlet
23
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
{
Statement st=null; Connection con=null;
static final String DB_URL="jdbc:mysql://localhost:3306/students"; static final String
USER="root"; static final String PASS="";
protected void processRequest(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8"); try (PrintWriter out =
response.getWriter())
{
String s1,sql;
s1=request.getParameter("fname");
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>"); .
out.println("<title>Record Updation</title>");
out.println("</head>"); out.println("<body>");
out.println("<h3>Record Deleted of name: " + s1 + "</h3>");
out.println("</body>"); out.println("</html>");
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(DB_URL,USER,PASS);
st = con.createStatement();
sql=" delete from student_18 where fname='"+s1+"' "; st.executeUpdate(sql);
System.out.println("Record Deleted Sucessfuly...");
}
catch(Exception e)
{
System.out.println(e.toString());}
}
void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
{
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
processRequest(request, response);
}
@Override
public String getServletInfo()
{
return "Short description";
}
}
Servlet4.java
import java.io.IOException;
24
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Servlet4 extends HttpServlet
{
Statement st=null; Connection con=null;
static final String DB_URL="jdbc:mysql://localhost:3306/students"; static final String
USER="root"; static final String PASS="";
protected void processRequest(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
{
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter())
{
String s1,sql;
s1=request.getParameter("fname");
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Record Updation</title>");
out.println("</head>");
out.println("<body>");
out.println("<h3>Record Searched Value of name: " + s1 + "</h3>");
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(DB_URL,USER,PASS); st =
con.createStatement();
System.out.println("Record Search Sucessfuly...");
ResultSet rs; rs = st.executeQuery("select * from student_18 where fname='"+s1+"'");
while(rs.next())
{
out.println("<h5>First Name:-"+rs.getString(1)+ "</h5>");
out.println("<h5>Last Name:-"+rs.getString(2)+ "</h5>");
out.println("<h5>Enrollment:-"+rs.getString(3)+ "</h5>");
out.println("<h5>Contact No:-"+rs.getString(4)+ "</h5>");
out.println("<h5>Sem:-"+rs.getString(5)+ "</h5>"); }
out.println("</body>");
out.println("</html>");
}
catch(Exception e)
{
System.out.println(e.toString());
}
25
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
processRequest(request, response);
}
@Override
public String getServletInfo()
{
return "Short description";
}
}
Output:
• Insert Record
26
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
• Search Record
• Update Record
27
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
• Delete Record
28
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
PRACTICAL -5
AIM: WRITE A SERVLET PROGRAM TO PRINT SYSTEM DATE AND
TIME.
index.html
<!DOCTYPE html>
<!-- Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to
change this license Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/Html.html to
edit this template-->
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<a href="pra5">click here</a>
</body>
</html>
pra5.java
import java.io.*;
import java.util.Date;
import jakarta.servlet.*;
import jakarta.servlet.http.*;
public class pra5 extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
{
response.setContentType("text/html"); PrintWriter out = response.getWriter(); Date
date = new Date();
out.println("<h1>Current Date and Time is:"+date.toString()+"</h1>"); out.close();
}
}
Output:
29
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
PRACTICAL -6
AIM:- DESIGN A WEB PAGE THAT TAKES THE USERNAME FROM
USER AND IF IT IS A VALID USERNAME PRINTS “WELCOME
USERNAME”, USE JSF TO IMPLEMENT.
Index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="loginPage" method="Post">
User Name:<input type="text" name="uname"/><br/><br>
Password:<input type="password" name="upass"/><br/><br>
<input type="submit" value="SUBMIT"/>
</form>
</body>
</html>
Login.java
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/loginPage")
public class Login extends HttpServlet {
private static final long serialVersionUID = 1L;
public Login() {
super();
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws
ServletException, IOException
{
//response.getWriter().append("Served at: ").append(request.getContextPath());
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws
ServletException, IOException
{
30
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
response.setContentType("text/html");
PrintWriter pwriter = response.getWriter();
String name=request.getParameter("uname");
String pass=request.getParameter("upass");
if(name.equals("Admin") &&
pass.equals("root"))
{
RequestDispatcher dis=request.getRequestDispatcher("welcome");
dis.forward(request, response);
}
else
{
pwriter.print("Username or password is incorrect!");
RequestDispatcher dis=request.getRequestDispatcher("index.html");
dis.include(request, response);
}
}
}
Welcome.java
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/welcome")
public class Welcome extends HttpServlet
{
private static final long serialVersionUID = 1L;
public Welcome()
{
super();
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws
ServletException, IOException
{
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
String name=request.getParameter("uname");
pw.print("Welcome "+name+"!<br>");
}
}
Web.xml
31
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
<web-app>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Login</servlet-name>
<servlet-class>Login</servlet-class>
</servlet>
<servlet>
<servlet-name>Welcome</servlet-name>
<servlet-class>Welcome</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Login</servlet-name>
<url-pattern>/loginPage</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Welcome</servlet-name>
<url-pattern>/welcome</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
Output:
32
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
33
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
PRACTICAL-7
AIM - WRITE HIBERNATE APPLICATION TO STORE CUSTOMER
RECORDS AND RETRIEVE THE CUSTOMER RECORD INCLUDING
NAME, CONTACTNUMBER, ADDRESS.
Customer.java
public class Customer
{
private int id;
private String firstName;
private String lastName;
private String c_number;
private String address;
public Customer()
{
}
public Customer(String fname, String lname, String c_number,String address)
{
this.firstName = fname;
this.lastName = lname;
this.c_number = c_number;
this.address = address;
}
public int getId()
{
return id;
}
public void setId( int id )
{
this.id = id;
}
public String getFirstName()
{
return firstName;
}
public void setFirstName( String first_name )
{
this.firstName = first_name;
}
public String getLastName()
{
return lastName;
}
public void setLastName( String last_name )
{
this.lastName = last_name;
}
public String getc_number()
34
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
{
return c_number;
}
public void setc_number( String c_number )
{
this.c_number = c_number;
}
public String getAddress()
{
return address;
}
public void setAddress( String address )
{
this.address = address;
}
}
Customers.hbm.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping>
<class name = "Customer" table = "customer">
<meta attribute = "class-description">
This class contains the students detail.
</meta>
<id name = "id" type = "int" column = "id">
<generator class="native"/>
</id>
<property name = "firstName" column = "first_name" type = "string"/>
<property name = "lastName" column = "last_name" type = "string"/>
<property name = "c_number" column = "c_number" type = "string"/>
<property name = "address" column = "address" type = "string"/> </class>
</hibernate-mapping>
ManageCustomer.java
import java.util.List;
import java.util.Date;
import java.util.Iterator;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class ManageCustomer
{
private static SessionFactory factory;
public static void main(String[] args) {
35
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
try {
factory = new Configuration().configure().buildSessionFactory();
}
catch (HibernateException ex)
{
System.err.println("Failed to create sessionFactory object." + ex); throw new
ExceptionInInitializerError(ex);
}
ManageCustomer ME = new ManageCustomer();
Integer stdID1 = ME.addCustomer("Arjav","Desai","4564787098","surat");
Integer stdID2 = ME.addCustomer("Tulsi", "Patel", "4564787098","navsari");
Integer stdID3 = ME.addCustomer("Parva", "Gurav", "4564787098","bardoli");
Integer stdID4 = ME.addCustomer("Darshit", "Desai", "4564787098","navsari");
Integer stdID5 = ME.addCustomer("Tejas", "Patel", "4564787098","surat");
ME.listCustomer();
ME.deleteCustomer(stdID2);
ME.listCustomer(); }
public Integer addCustomer(String fname, String lname, String c_number,String
address)
{
Session session = factory.openSession();
Transaction tx = null; Integer CustomerID = null;
try {
tx = session.beginTransaction();
Customer Customer = new Customer(fname, lname, c_number, address); CustomerID
= (Integer) session.save(Customer); tx.commit();
} catch (HibernateException e) { if (tx!=null) tx.rollback(); e.printStackTrace();
} finally { session.close();
} return CustomerID;
}
public void listCustomer( ){
Session session = factory.openSession(); Transaction tx = null; try {
tx = session.beginTransaction();
List Customer = session.createQuery("FROM Customer").list(); for (Iterator iterator =
Customer.iterator(); iterator.hasNext();){ Customer Customer1 = (Customer)
iterator.next();
System.out.print("First Name: " + Customer1.getFirstName());
System.out.print(" Last Name: " + Customer1.getLastName());
System.out.println(" Contact Number: " + Customer1.getc_number());
System.out.println(" Address:- " + Customer1.getAddress());
} tx.commit();
} catch (HibernateException e) {
if (tx!=null) tx.rollback(); e.printStackTrace();
} finally { session.close();
}
}
public void deleteCustomer(Integer CustomerID){
Session session = factory.openSession(); Transaction tx = null; try {
36
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
tx = session.beginTransaction();
Customer Customer = (Customer)session.get(Customer.class, CustomerID);
session.delete(Customer); tx.commit();
} catch (HibernateException e) { if (tx!=null) tx.rollback(); e.printStackTrace();
} finally { session.close();
}
}
}
Hibernate.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration
DTD
3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property
name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property
name="hibernate.connection.url">jdbc:mysql://localhost:3306/customers</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">india</property>
<mapping resource="Customers.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Output:
37
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
PRACTICAL-8
AIM:- WRITE AN APPLICATION TO KEEP RECORD AND RETRIEVE
RECORD OF STUDENT. THE RECORD INCLUDES STUDENT ID,
ENROLLMENT NO, SEMESTER, SPI. USE MVC ARCHITECTURE.
Index.html
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!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://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO8859-
1" /> <title>Index</title>
</head>
<h:body>
<f:view>
<h3>Enter Details</h3>
<h:form>
<table> <tr>
<td>ID:</td><td><h:inputText value="#{bean.id}"/></td>
</tr>
<tr>
<td>Enrollment Number:</td><td><h:inputText value="#{bean.en}"/></td>
</tr>
<tr>
<td>Semester:</td><td><h:inputText value="#{bean.sem}"/></td>
</tr>
<tr>
<td>SPI:</td><td><h:inputText value="#{bean.spi}"/></td> </tr> </table>
<h:commandButton value="Submit" action="#{bean.submit}"/>
</h:form>
<br></br>
<h:outputText value="#{bean.data}" escape="false" />
</f:view>
</h:body>
</html>
Bean.java
package jsfpackage;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import java.sql.*;
@ManagedBean
public class bean implements Serializable
{
private static final long serialVersionUID = 6529685098267757690L;
private int id;
38
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
private String en;
private int sem;
private float spi;
private String data = "";
public String submit() throws SQLException, ClassNotFoundException
{
Class.forName("com.mysql.jdbc.Driver");
Connection con =
DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/test?charact
erEncoding=utf8&u seSSL=false&useUnicode=true","root","root");
PreparedStatement st = con.prepareStatement("insert into student values(?,?,?,?)");
st.setInt(1, getId());
st.setString(2, getEn());
st.setInt(3, getSem());
st.setFloat(4, getSpi());
st.execute();
Statement stt = con.createStatement();
ResultSet rs = stt.executeQuery("select * from student");
this.data = "<table style=\"width:50%\" bgcolor=\"cyan\" border=\"1px\"><tr
bgcolor=\"teal\"><th>Id</th><th>Enrollment</th><th>Semester</th><t
h>SPI</th></tr>"; while(rs.next())
{
int i = rs.getInt(1);
String en = rs.getString(2);
int sm = rs.getInt(3);
float sp = rs.getFloat(4);
this.data +=
"<tr><td>"+i+"</td><td>"+en+"</td><td>"+sm+"</td><td>"+sp+"</td></tr
>";
}
this.data += "</table>"; con.close();
return "index.xhtml";
}
public String getData()
{
return this.data;
}
public int getId()
{
return id;
}
public void setId(int id)
{
this.id = id;
}
public String getEn()
{
return en;
39
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
}
public void setEn(String en)
{
this.en = en;
}
public int getSem()
{
return sem;
}
public void setSem(int sem)
{
this.sem = sem;
}
public float getSpi()
{
return spi;
}
public void setSpi(float spi)
{
this.spi = spi;
}
}
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
;http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID"
version="3.1">
<display-name>P11 JSF</display-name>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-onstartup>1</load-on-
startup> </servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<context-param>
40
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
<description>State saving method: 'client' or 'server' (=default). See JSF Specification
2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<paramname>javax.servlet.jsp.jstl.fmt.localizationContext</paramname>
<param-value>resources.application</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
</web-app>
Faces-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
;http://xmlns.jcp.org/xml/ns/javaee/webfacesconfig_2_2.xsd" version="2.2">
<navigation-rule>
<from-view-id>/index.xhtml</from-view-id>
<navigation-case>
<from-outcome>index</from-outcome>
<to-view-id>/index.xhtml</to-view-id>
</navigation-case> </navigation-rule>
<managed-bean>
<managed-bean-name>bean</managed-bean-name>
<managed-bean-class>jsfpackage.bean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config>
41
VIEAT/B.E/SEM-V/220943107040
Advance java Programming(3160707)
Output:
42
VIEAT/B.E/SEM-V/220943107040