<%@ page import="java.sql.*" %>
<%
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","pankaj");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select img,name from books");
%>
<html>
<head>
<title>ONLINE BOOK STORE - LOGIN PAGE</title>
</head>
<body>
<table align=center>
<tr>
<td align=center><img src="logo.jpg"></img>
<tr>
<td align=right><a href="http://master-gtu.blogspot.com">www.master-gtu.blogspot.com</a>
</table>
<table border=0 width=100% height=60% >
<tr>
<td colspan=5 align=center><h2>WELCOME TO ONLINE BOOK SHOPPING</h2>
<tr>
<td width=70% >
<marquee>
<table cellpadding=2 cellspacing=8>
<tr>
<%
while(rs.next())
{
%>
<td>
<img src="<%="images/"+rs.getString("img") %>" width=100 height=150>
<%
}
%>
<tr>
<%
rs=stmt.executeQuery("select img,name from books");
while(rs.next())
{
%>
<td><%=rs.getString("name")%>
<%
}
%>
</table>
</marquee>
<td align=center valign=top>
<i><h2>LOGIN</h2></i>
<form action="pro37logincheck" method="post">
<table>
<tr>
<td>USERNAME
<td><input type="text" name="username">
<tr>
<td>PASSWORD
<td><input type="text" name="password">
<tr>
<td colspan=2>
<%
String msg=request.getParameter("msg");
if(msg!=null)
out.println("<font color=red>"+msg+"</font>");
%>
<tr>
<td><input type="submit" name="LOGIN">
<td><input type="submit" name="CLEAR">
</table>
</form>
</table>
</body>
</html>
<%
rs.close();
stmt.close();
con.close();
}catch(Exception e){}
%>
<%@ page import="java.sql.*" %>
<%
int amt=0,sno=1;
String userid=String.valueOf(session.getAttribute("userid")); //converting to string becouse session will return Object type
String name=String.valueOf(session.getAttribute("name"));
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","pankaj");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from usercart where userid='"+userid+"'");
%>
<html>
<script language="javascript">
function purchase()
{
crno=document.getElementById("crno").value;
if(crno.length==10 )
alert('HIIIIII <%=name %> YOUR PAYMENT IS DONE, THANKING YOU !!! :-)');
else
alert('Pls Enter Proper Credit Card Number..');
//response.sendRedirect("/pro37showbooks.jsp");
}
</script>
<body>
<table align=center>
<tr>
<td align=center colspan=4><img src="logo.jpg"></img>
</table>
<table border=20 width=100% align=center><tr><td>
<table align=center>
<tr>
<th align=center colspan=5><h2><i>USER-BILL</i></h2>
<tr>
<td width=70% colspan=3>
<td colspan=5 >
<b>Name : <%=name %></b>
<tr bgcolor=limegreen>
<th>SERIAL NO
<th>NAME OF PRODUCT
<th>PER PRICE
<th>QUANTITY
<th>PRICE
<%
while(rs.next())
{
%>
<tr>
<td><%=sno%>
<td><%=rs.getString("name") %>
<td><%=rs.getString("price") %><br>
<td><%=rs.getString("quantity") %>
<td><%=Integer.parseInt(rs.getString("quantity")) * Integer.parseInt(rs.getString("price")) %><br>
<%
amt=amt+(Integer.parseInt(rs.getString("quantity")) * Integer.parseInt(rs.getString("price")));
sno++;
%>
<%
}
%>
<tr>
<td colspan=4 align=right>TOTAL AMOUNT
<td><%=amt %>
<tr>
<td width=70% colspan=3>
<td colspan=5 >
master-gtu.blogspot.com<br>
pankaj & vijay<br>
MCA - 4<br>
<tr>
<th colspan=5> Credit Card Number : <input type="text" id="crno" ><br>
<input type="button" name="pay" value=" PAY AMOUNT " onclick="purchase()">
<DIV ALIGN=RIGHT><a href="pro37showbooks.jsp">BACK TO HOME<a></DIV>
</table>
</table>
</body>
</html>
<%
}catch(Exception e){ out.println(e); }
%>
<%@ page import="java.sql.*" %>
<%
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","pankaj");
Statement stmt=con.createStatement();
String cat=request.getParameter("cat");
String userid=String.valueOf(session.getAttribute("userid"));
String name=String.valueOf(session.getAttribute("name"));
ResultSet rs;
if(cat!=null)
rs=stmt.executeQuery("select * from books where cat='"+cat+"'");
else
rs=stmt.executeQuery("select * from books");
%>
<html>
<head>
<title>ONLINE BOOK STORE - LOGIN PAGE</title>
</head>
<body>
<table align=center>
<tr>
<td align=center><img src="logo.jpg"></img>
<tr>
<td align=right><a href="http://master-gtu.blogspot.com">www.master-gtu.blogspot.com</a>
</table>
<table border=0 width=100% height=60% >
<tr>
<td width=20% valign=top>
<br><br><br><br><i><font face="MonoTypeCorsiva">SELECT CATEGORY</face></i><br><br>
<jsp:include page="pro37showlist.jsp"/>
<td>
<table border=1 cellpadding=5 cellspacing=10 width=100% height=100% >
<tr height=10% align=right>
<td colspan=5>
Welcome <%=name %> | <a href="pro37showcart.jsp">Show My Cart</a> | My Account | <a href="pro37logout">Logout</a>
<%
while(rs.next())
{
%>
<tr>
<td width=10>
<td><img src="<%="images/"+rs.getString("img") %>" width=100 height=150>
<td>
Name : <%=rs.getString("name") %><br>
Author : <%=rs.getString("auth") %><br>
Price : <%=rs.getString("price") %><br>
Status :
<%
if(rs.getString("quantity").equals("0"))
{
out.println("<font color=red>Not Available</font>");
}
else
{
%>
<font color=green>Available</font>
<td>
<form action="pro37addtocart" name="formsubmit" method=post>
<input type="hidden" name="cat" value=<%=rs.getString("cat") %>>
<input type="hidden" name="id" value=<%=rs.getString("id") %>>
<input type="hidden" name="totalq" value=<%=rs.getString("quantity") %>>
<input type="hidden" name="price" value=<%=rs.getString("price") %>>
Quantity
<select name="selq">
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
<option value=4>4</option>
<option value=5>5</option>
<option value=6>6</option>
<option value=7>7</option>
<option value=8>8</option>
<option value=9>9</option>
<option value=10>10</option>
</select><br><input type=submit value="ADD TO CART">
<%-- <a href="" onclick="javascript:alert(document.formsubmit.action)">slfj</a> --%>
</form>
<%
}
%>
<%
}
%>
</table>
</table>
</body>
</html>
<%
}catch(Exception e){ out.println(e);}
%>
<%@ page import="java.sql.*,java.util.*" %>
<%
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","pankaj");
Statement stmt=con.createStatement();
String cat=request.getParameter("cat");
String userid=String.valueOf(session.getAttribute("userid")); //converting to string becouse session will return Object type
String name=String.valueOf(session.getAttribute("name"));
ResultSet rs;
rs=stmt.executeQuery("select * from usercart where userid='"+userid+"'");
%>
<html>
<head>
<title>ONLINE BOOK STORE - LOGIN PAGE</title>
</head>
<body>
<table align=center>
<tr>
<td align=center><img src="logo.jpg"></img>
<tr>
<td align=right><a href="http://master-gtu.blogspot.com">www.master-gtu.blogspot.com</a>
</table>
<table border=0 width=100% height=60% >
<tr>
<td width=20% valign=top>
<br><br><br><br><i><font face="MonoTypeCorsiva">SELECT CATEGORY</face></i><br><br>
<jsp:include page="pro37showlist.jsp"/>
<td>
<table border=1 cellpadding=5 cellspacing=10 width=100% height=100% >
<tr height=10% align=right>
<td colspan=5>
Welcome <%=name %> | <a href="pro37showcart.jsp">Show My Cart</a> | My Account | <a href="pro37logout">Logout</a>
<%
while(rs.next())
{
%>
<tr>
<td width=10>
<td><img src="<%="images/"+rs.getString("img") %>" width=100 height=150>
<td>
Name : <%=rs.getString("name") %><br>
Author : <%=rs.getString("auth") %><br>
Price : <%=Integer.parseInt(rs.getString("quantity")) * Integer.parseInt(rs.getString("price")) %><br>
Quantity : <%= rs.getString("quantity") %><br>
<%
}
%>
<tr>
<td colspan=3><a href="pro37purchase.jsp">PURCHASE</a>
</table>
</table>
</body>
</html>
<%
rs.close();
stmt.close();
con.close();
}catch(Exception e)
{ out.println(e);}
%>
<ul>
<li><a href="pro37showbooks.jsp?cat=java">WTAD</a>
<li><a href="pro37showbooks.jsp?cat=network">FON</a>
<li><a href="pro37showbooks.jsp?cat=java">JAVA</a>
<li>MIS
<li>ANDROID
<li><a href="pro37showbooks.jsp?cat=c">C</a>
<li>C++
</ul>
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
@WebServlet("/pro37logincheck")
public class pro37logincheck extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
String msg="Username Or Password Incorrect....";
try{
String username,password;
username=req.getParameter("username");
password=req.getParameter("password");
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","pankaj");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from userinfo where username='"+username+"' and password='"+password+"'");
if(rs.next())
{
HttpSession session=req.getSession(true);
session.setAttribute("userid",rs.getString("userid"));
session.setAttribute("name",rs.getString("username"));
res.sendRedirect("pro37showbooks.jsp");
}
else
{
res.sendRedirect("pro37index.jsp?msg="+msg);
}
}catch(Exception e){ out.println(e); }
}
public void doPost(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
{
doGet(req,res);
}
}
import javax.servlet.http.*;
import javax.servlet.annotation.*;
@WebServlet("/pro37addtocart")
public class pro37addtocart extends HttpServlet
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
String cat="",id,msg="Username Or Password Incorrect....",userid,name,auth,img;
int quantity,price,selq,totalq;
HttpSession session=req.getSession(false);
userid=String.valueOf(session.getAttribute("userid"));
res.setContentType("text/html");
PrintWriter out=res.getWriter();
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","pankaj");
Statement stmt=con.createStatement();
id=req.getParameter("id");
selq=Integer.parseInt(req.getParameter("selq"));
rs=stmt.executeQuery("select * from books where id="+id);
totalq=Integer.parseInt(rs.getString("quantity"));
price=Integer.parseInt(rs.getString("price"));
name=rs.getString("name");
auth=rs.getString("auth");
rs=stmt.executeQuery("update books set quantity="+quantity+" where id="+id);
stmt.executeQuery("insert into usercart values('"+userid+"','"+id+"','"+selq+"','"+name+"','"+img+"','"+auth+"','"+cat+"','"+price+"')");
res.sendRedirect("pro37showbooks.jsp?cat="+cat);
public void doPost(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
import javax.servlet.http.*;
import javax.servlet.annotation.*;
@WebServlet("/pro37logout")
public class pro37logout extends HttpServlet
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
res.setContentType("text/html");
PrintWriter out=res.getWriter();
String msg="Logout Successfully....";
HttpSession session=req.getSession(true);
res.sendRedirect("pro37index.jsp?msg="+msg);
public void doPost(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException