Вы находитесь на странице: 1из 15

Advance Java Online Shopping Portal

Part of codlings

LOGIN.JSP
<%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Login Page</title> </head> <body> <title>Login Page</title> <div id="header"> <div id="title"> <br> <h1 class="style1">Arts ForEver</h1> </div> <img src="bg/front.jpg" width="760" height="275" alt="front"/> </div> <script language="JavaScript1.2"> <!-- Begin var months=new Array(13); months[1]="January"; months[2]="February"; months[3]="March"; months[4]="April"; months[5]="May"; months[6]="June"; months[7]="July"; months[8]="August"; months[9]="September"; months[10]="October"; months[11]="November"; months[12]="December"; var time=new Date(); var lmonth=months[time.getMonth() + 1]; var date=time.getDate(); var year=time.getYear(); if (year < 2000) // Y2K Fix, Isaac Powell year = year + 1900; // http://onyx.idbsu.edu/~ipowell document.write("<right>" + lmonth + " "); document.write(date + ", " + year + "</right>"); // End --> </script>

1|Page

Advance Java Online Shopping Portal


<table align="center" border="0" cellspacing="10" celpadding="12"><br><br> <form method="post" action="http://localhost:8084/Shopping_Cart/Goin" > <tr> <td align="left">User Name:</td> <td><input type="text" name="UName" maxlength="25" align="right"><br></td> </tr> <tr> <td align="left">Password:</td> <td><input type="Password" name="txtpassword1" size="15" maxlength="25" align="right"></td> </tr> <tr> <td><INPUT type="submit" value="Singin"></td> </tr> </form> <form method="post" action="http://localhost:8084/Shopping_Cart/Signup.jsp" > <tr> <td><input type="submit" value="SignUp"><br><br><br><br><br><br><br><br><br></td> </tr> </form> <tr> <form method="post" action="http://localhost:8084/Shopping_Cart/Aboutus.jsp"> <td> <input type="Submit" value="ABOUT US" name="" </td></form> >

size="15"

<form method="post" action=" http://localhost:8084/Shopping_Cart/Contactus.jsp"> <td><input type="Submit" value="CONTACT US" name="" /></td> </form></tr>

</table> </body>
</html>

2|Page

Advance Java Online Shopping Portal SHOPPINGCART.JSP


<%@page import="java.util.Enumeration"%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <jsp:useBean id="cart" scope="session" class="beans.ShoppingCart" /> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Shopping Cart Contents</title> </head> <body> <center> <div id="title"> <br> <h2 class="style1">Cart </h2> <img src="bg/banner-cart-checkout.jpg" width="684" height="278" alt="banner-cart-checkout"/> </div> <table width="300" border="1" cellspacing="0" cellpadding="2" border="0"> <caption><b>Shopping Cart Contents</b></caption> <tr> <th>Description</th> <th>Price</th> <th>Quantity</th> </tr> <% Enumeration e = cart.getEnumeration(); String[] tmpItem; // Iterate over the cart while (e.hasMoreElements()) { tmpItem = (String[]) e.nextElement(); %> <tr> <td><%=tmpItem[1]%></td> <td align="center">LKR<%=tmpItem[2]%></td> <td align="center"><%=tmpItem[3]%></td> </tr> <% } %> </table> <br><br><br><br> <span>Total</span>

3|Page

Advance Java Online Shopping Portal


<span id="cart_block_total" class="price ajax_block_cart_total"><%=cart.getCost()%> LKR </span> </center>

<form method="post" action="http://localhost:8084/Shopping_Cart/Payment.jsp" > <tr> <br><br><br><br><br><br><td><input type="submit" here Payment.." ></td> </tr> </form>

value="Click

<a href="Products.jsp">Back to Shopping</a> </body> </html>

4|Page

Advance Java Online Shopping Portal Servlet for the Login.jsp

package PK1; import import import import import import import import import java.io.IOException; java.io.PrintWriter; javax.servlet.ServletException; javax.servlet.http.HttpServlet; javax.servlet.http.HttpServletRequest; javax.servlet.http.HttpServletResponse; java.io.*; java.sql.*; javax.servlet.RequestDispatcher;

/** * * @author Niranjan */ public class Goin extends HttpServlet { /** * Processes requests for both HTTP <code>GET</code> and methods. * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ Connection dbcon; Statement state; ResultSet result; public String status, userId; protected void processRequest(HttpServletRequest request, response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); String Username = request.getParameter("UName"); String Password = request.getParameter("txtpassword1"); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc:MyDataSource", "", ""); PreparedStatement stat2 where username=? and password=?"); = con.prepareStatement("Select * from member <code>POST</code>

HttpServletResponse

stat2.setString(1, Username); stat2.setString(2, Password); ResultSet rs = stat2.executeQuery();

5|Page

Advance Java Online Shopping Portal


if (rs.next()) { status = rs.getString("Status"); userId = rs.getString("useID"); out.println("<html>"); out.println("<body>"); out.println("<h2 align=center>Arts ForEver</h2>"); out.println("<form action=http://localhost:8084/Shopping_Cart/Products.jsp>"); out.println("<INPUT type=submit value=SKIP align=center><br><br>"); out.println("</form>");

method=post This Page

out.println("<form >"); out.println("&nbsp; &nbsp&nbsp; &nbsp; &nbsp&nbsp;&nbsp; &nbsp; &nbsp&nbsp; &nbsp; &nbsp&nbsp;&nbsp; &nbsp; &nbsp&nbsp; &nbsp; &nbsp&nbsp;&nbsp;"); //out.println ("&nbsp; &nbsp&nbsp; &nbsp; &nbsp&nbsp;&nbsp; &nbsp; &nbsp&nbsp; &nbsp; &nbsp&nbsp;&nbsp; &nbsp; &nbsp&nbsp; &nbsp; &nbsp&nbsp;&nbsp; <input type=submit value=About Us align=left>"); out.println("</form>"); out.println("<form>"); out.println("&nbsp; &nbsp&nbsp; &nbsp; &nbsp&nbsp;&nbsp; &nbsp; &nbsp&nbsp; &nbsp; &nbsp&nbsp;&nbsp; &nbsp; &nbsp&nbsp; &nbsp; &nbsp&nbsp;&nbsp;"); out.println("&nbsp; &nbsp&nbsp; &nbsp; &nbsp&nbsp;&nbsp; &nbsp; &nbsp&nbsp; &nbsp; &nbsp&nbsp;&nbsp; &nbsp; &nbsp&nbsp; &nbsp; &nbsp&nbsp;&nbsp;"); // out.println("<input type=submit value=Contact Us align=left>"); out.println("</form>"); out.println("<form>"); out.println("&nbsp; &nbsp&nbsp; &nbsp; &nbsp&nbsp;&nbsp; &nbsp; &nbsp&nbsp; &nbsp; &nbsp&nbsp;&nbsp; &nbsp; &nbsp&nbsp; &nbsp; &nbsp&nbsp;&nbsp;"); out.println("&nbsp; &nbsp&nbsp; &nbsp; &nbsp&nbsp;&nbsp; &nbsp; &nbsp&nbsp; &nbsp; &nbsp&nbsp;&nbsp; &nbsp; &nbsp&nbsp; &nbsp; &nbsp&nbsp;&nbsp;"); //out.println ("<input font=red color=black type=submit value=Services align=left>"); out.println("</form>"); out.println("</body></html>"); } else { out.println("<html>"); out.println("<body>"); //out.println ("<h1 align=center> Art Stuff's</h1>"); out.println("<h3 align=center>Varitey of Art's</h3>"); out.println("<br><br><br><br><br><h2 align=center>Try Again with the Correct Username</h2>"); out.println("<form method=post action=http://localhost:8084/Shopping_Cart/Login.jsp>"); out.println("<input type=submit value=Back align=center>"); out.println("</form></body></html>"); out.println("<br> <br> For Loging to the Site Please Press BACK Button"); out.println("<br> <FORM method=post action=http://localhost:8084/Shopping_Cart/Login.jsp>"); out.println("<br> <INPUT type=submit name= Return value=BACK>"); } } catch (Exception e) {

6|Page

Advance Java Online Shopping Portal


out.println(e.toString()); } try { dbcon.close(); } catch (Exception e) { System.out.println(e.toString()); } } // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code."> /** * Handles the HTTP <code>GET</code> method. * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } /** * Handles the HTTP <code>POST</code> method. * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } /** * Returns a short description of the servlet. * @return a String containing servlet description */ @Override public String getServletInfo() { return "Short description"; }// </editor-fold> }

7|Page

Advance Java Online Shopping Portal

Task 7
Create a user interface on the Web using java

Screen layouts

Login page

This Is the login page of the Web site. 1st user have to signup to the system then can login to the system

8|Page

Advance Java Online Shopping Portal Signup Page

9|Page

Advance Java Online Shopping Portal About us

10 | P a g e

Advance Java Online Shopping Portal Contact us page

11 | P a g e

Advance Java Online Shopping Portal

Product Catalog

12 | P a g e

Advance Java Online Shopping Portal Art Products (Add to Cart)

13 | P a g e

Advance Java Online Shopping Portal

14 | P a g e

Advance Java Online Shopping Portal View Cart

15 | P a g e

Вам также может понравиться