Ca3 1170
Ca3 1170
LOGINJSP.JSP
<%--
Document : loginjsp
Created on : 14 Apr, 2020, 12:16:47 PM
Author : Para SF
--%>
</head>
<body>
<center>
<div class="inner">
<label>ID<br><input type="text" name="id"></label><br><br>
<label>PASSWORD<input type="password" name="pass"></label><br><br>
<label><button type="submit" style="background-color:whitesmoke; padding:5px;">LOGIN</button></label>
</div>
</form>
</center>
</div>
</center>
</body>
</html>
DataServelet.java
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.*;
Statement statement=conn.createStatement();
rs=ps.executeQuery();
if(rs.next())
{
response.sendRedirect("afterlogin.jsp");
}
else
{
out.println("WRONG ID PASSWORD");
}
}
catch(Exception e)
{
out.print(e);
}
AFTERLOGIN.JSP
/******************************************QUESTION 2*************************************************************/
VERIFY.JSP
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
try{
Connection conn=DriverManager.getConnection("jdbc:derby://localhost:1527/Question_Two","ashish","jha");
if(conn!=null)
{
String sql="insert into question2(name,email,college,state,stream) values(?,?,?,?,?) ";
String name=request.getParameter("name");
String email=request.getParameter("email");
String college=request.getParameter("college");
String state=request.getParameter("state");
String stream=request.getParameter("stream");
PreparedStatement ps=conn.prepareStatement(sql);
ps.setString(1,name);
ps.setString(2,email);
ps.setString(3,college);
ps.setString(4,state);
ps.setString(5,stream);
int rowInserted=ps.executeUpdate();
if(rowInserted>0){
out.println("DATA ENTERED<br>");
}
else
{
out.print("DATA ENTRY DECLINED");
}
Statement st=conn.createStatement();
String sql1="select * from Question2 where name like 'N%'";
ResultSet rs=st.executeQuery(sql1);
int count=0;
while(rs.next())
{%>
<br><br>
<%=rs.getString("name")%><br>
<%=rs.getString("email")%><br>
<%=rs.getString("college")%><br>
<%=rs.getString("state")%><br>
<%=rs.getString("stream")%><br><br>
<% count=count+1;}
out.print("<br><br>TOTAL COUNT OF DATA WHOSE NAME START WITHS N :"+ count);
}
catch(Exception ex)
{
out.print("EXCEPTION IS:" +ex);
}
%>
</body>
</html>
INDEX.HTML
<!DOCTYPE html>
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.inner{
background: linear-gradient(to bottom, #66ffff 0%, #3399ff 100%);
paddin-top:10px;
box-shadow:10px background;
}
.outer{
padding-left: 30%;
padding-right: 30%;
padding-top: 10%;
box-shadow:10px background;
border: 1px cadetblue;
}
.headings{
padding:15px;
}
/* .input
{
border-color:whitesmoke;
}*/
</style>
</head>
<body>
<div class="outer">
<center>
<form action="verify.jsp" method="POST" style="box-shadow:10px whitesmoke">
<div style="background-color: whitesmoke" class="headings">ENTER DATA</div>
<div class="inner" >
</div>
</div>
</form>
</center>
</div>
</body>
</html>
************************************QUESTION 2 OVER*******************************************************
/**************************************QUESTION 3**************************************************************/
<html>
<head>
<title>Food Management</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body{
margin: 0px;
padding:0px;
}
.buylist{
margin-left: 30%;
margin-right: 30%;
margin-top: 3%;
margin-bottom: 3%;
background-color: graytext;
padding:3px;
}
.menu
{
background-color: graytext;
padding:8px;
}
.Pmenu
{
background-color: graytext;
padding:2px;
}
.menu h1{
color:whitesmoke;
border: 1px black;
}
.Pmenu h2{
color:whitesmoke;
border: 1px black;
}
.buylist h2{
color:whitesmoke;
border: 1px black;
}
img{
height:200px;
width:300px;
}
.imageCont
{
margin-left: 15%;
}
.outerCont{
margin-top: 30px;
margin-bottom: 30px;
}
.priceList{
background-color: buttonface;
margin-left: 10%;
margin-right: 10%;
}
td{
padding:30px
}
.plisttable{
margin-left: 18%;
}
</style>
</head>
<body>
<div class="menu">
<center>
<h1>Ashish Food Service</h1>
</center>
</div>
<div class="outerCont">
<div class="imageCont">
<img src="C:\Users\Para SF\Downloads\bread.jpg" alt="Bread image">
<img src="C:\Users\Para SF\Downloads\milk.jpg" alt="Bread image”>
<img src="C:\Users\Para SF\Downloads\cookies.jpg" alt="Bread image">
</div>
</div>
<div class="priceList">
<div class="Pmenu">
<center>
<h2>Price List</h2>
</center>
</div>
<div class="plisttable">
<table>
<tr>
<td>ITEM NAME</td>
<td>COMPANY NAME</td>
<td>MANUFACTURE DATE</td>
<td>PRICE</td>
</tr>
<tr>
<td>BREAD</td>
<td>SUNDROP</td>
<td>16th April 2020</td>
<td>20</td>
</tr>
<tr>
<td>MILK</td>
<td>MOTHER DAIRY</td>
<td>16th April 2020</td>
<td>30</td>
</tr>
<tr>
<td>COOKIES</td>
<td>LOVELY SWEETS</td>
<td>16th April 2020</td>
<td>100</td>
</tr>
</table>
</div>
</div>
<div class="buylist">
<center>
<h2>BUY</h2>
<div style="background-color: beige; padding:10px;">
<form action="FoodServlet" method="POST">
<input type="text" name="pname" placeholder="ITEM NAME">
<input type="number" name="tno" placeholder="HOW MANY">
<button type="submit">BUY</button>
</form>
</div>
</center>
</div>
</body>
</html>
FOODSERVLET.JAVA
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.*;
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
try
{
Connection conn=DriverManager.getConnection("jdbc:derby://localhost:1527/Question_Three","ashish","jha");
if(conn!=null)
{
int cookiesPrice=100,BreadPrice=20,MilkPrice=30;
String sql="insert into question3(item,number) values(?,?)";
String name=request.getParameter("pname");
int number=Integer.parseInt(request.getParameter("tno"));
PreparedStatement ps= conn.prepareStatement(sql);
ps.setString(1,name);
ps.setInt(2,number);
int rowInserted=ps.executeUpdate();
if(name.equals("cookies") || name.equals("COOKIES"))
{
cookiesPrice=cookiesPrice*number;
out.print(number +" "+ name +" is = "+ cookiesPrice);
out.print("<br><br>THANKYOU FOR BUYING "+name);
}
else
if(name.equals("bread") || name.equals("BREAD"))
{
BreadPrice=BreadPrice*number;
out.print(number +" "+ name +" is = "+ BreadPrice);
out.print("<br><br>THANKYOU FOR BUYING "+name);
}
else
if(name.equals("milk") || name.equals("MILK"))
{
MilkPrice=MilkPrice*number;
out.print(number +" "+ name +" is = "+ MilkPrice);
out.print("<br><br>THANKYOU FOR BUYING "+name);
}
else
{
out.print("WRONG ITEM NAME ENTERED");
}
}
catch(Exception ex)
{
out.println("EXCEPTION IS: "+ex);
}
}
/***************************************************Question 3 Over***********************************************/
/*****************************************************Question 4**************************************************/
INDEX.HTML
<!DOCTYPE html>
<html>
<head>
<title>FEE MANAGEMENT</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.outer{
background: linear-gradient(to bottom, #66ffff 0%, #3399ff 100%);
margin-left:40%;
margin-right:40%;
margin-top:10%;
box-shadow:10px background;
border: 1px cadetblue;
}
.inner{
padding: 10%;
box-shadow:10px background;
}
.heading{
margin-top: 5%;
}
input
{
border:none;
padding: 5px;
}
</style>
</head>
<body>
<center>
<!-- <div class="heading">
</div>-->
<div class="outer" >
<center>
<p style="background-color:whitesmoke; padding-top:15px; padding-bottom: 15px">DISCOUNT CALCULATOR</p>
<form style="box-shadow:10px whitesmoke;" action="Feemanage" method="POST">
<div class="inner">
<label>NAME<br><input type="text" name="name"></label><br><br>
<label>COLLEGE<input type="text" name="college"></label><br><br>
<label>AGE<br><input type="number" name="age"></label><br><br>
<label>CGPA<br><input type="text" name="cgpa"></label><br><br>
<label><button type="submit" style="background-color:whitesmoke; padding:5px;">CALCULATE</button></label>
</div>
</form>
</center>
</div>
</center>
</body>
</html>
FEEMANAGE.JSP
}
catch(Exception ex)
{
out.println("EXCEPTION IS: "+ ex);
}
%>
</body>
</html>
UPDATE.JSP
<%--
Document : update
Created on : 17 Apr, 2020, 9:31:15 PM
Author : Para SF_ASHISH
--%>
/****************************************************Question 5**************************************************/
INDEX.HTML
<!DOCTYPE html>
<html>
<head>
<title>ATTENDENCE MANAGEMENT</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.outer{
background: linear-gradient(to bottom, #66ffff 0%, #3399ff 100%);
margin-left:40%;
margin-right:40%;
margin-top:10%;
box-shadow:10px background;
border: 1px cadetblue;
}
.inner{
padding: 10%;
box-shadow:10px background;
}
.heading{
margin-top: 5%;
}
input
{
border:none;
padding: 5px;
}
</style>
</head>
<body>
<center>
<div class="outer" >
<center>
<p style="background-color:whitesmoke; padding-top:15px; padding-bottom: 15px">ATTENDENCE CALCULATOR</p>
<form style="box-shadow:10px whitesmoke;" action="Attendmanage.jsp" method="POST">
<div class="inner">
<label>NAME<br><input type="text" name="name"></label><br><br>
<label>COLLEGE<input type="text" name="college"></label><br><br>
<label>ID<br><input type="number" name="id"></label><br><br>
<label>ATTENDENCE<br><input type="number" name="attendence"></label><br><br>
<label><button type="submit" style="background-color:whitesmoke; padding:5px;">CALCULATE</button></label>
</div>
</form>
</center>
</div>
</center>
</body>
</html>
ATTENDENCEMANAGE.JSP
}
}
catch(Exception ex)
{
out.println("EXCEPTION IS : "+ ex);
}
%>
</body>
</html>
/****************************************************Question 5 OVER********************************************/