Advertisement
Guest User

Untitled

a guest
Oct 29th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.17 KB | None | 0 0
  1. <%@page import="javax.swing.ImageIcon"%>
  2. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  3. pageEncoding="ISO-8859-1"%>
  4. <%@page import ="java.sql.*" %>
  5. <%@page import="java.io.*" %>
  6. <%@ page import="java.util.*" %>
  7. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  8. <html>
  9. <head>
  10. <link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/product.css" />
  11. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  12. <title>Product</title>
  13. </head>
  14. <body>
  15. <div class="nav">
  16. <div id="contactBox">
  17. <form method="post" action="showSearch.jsp">
  18. <input type="text" name="searching" id="search"/><input type="submit" name="look" value="Search" id="searchButton"/>
  19. </form>
  20. </div>
  21. <img src="indica.PNG" alt="indica" width="500" height="90" id="indi"/>
  22. <div id="single">
  23. <ul>
  24. <li><a href="HomePage.jsp" class="home">HOME</a></li>
  25. <li><a href="Product.jsp" class="product">PRODUCT</a></li>
  26. <li><a href="" class="contact">CONTACT</a></li>
  27. <li><a href="" class="cart">CART</a></li>
  28. <li><a href="login.jsp" class="login">LOGIN</a></li>
  29. </ul>
  30. </div>
  31. </div>
  32. <div id="selection">
  33. <form method="post" action="Product.jsp">
  34. <img src="name.PNG" alt="indica" width="270" height="100" id="brand"/>
  35. <div id="buttons">
  36. <input type="submit" value="Men" name="btn" class="but"/><br>
  37. <input type="submit" value="Women" name="btn" class="but"/><br>
  38. <input type="submit" value="Brand" name="btn" class="but"/><br>
  39. <input type="submit" value="CashManager" name="btn" class="but"/><br>
  40. <input type="submit" value="Trend" name="btn" class="but"/><br>
  41. <input type="submit" value="Sale" name="btn" class="but"/><br>
  42. <input type="hidden" name="submitted" value="true"/>
  43. </div>
  44.  
  45. </form>
  46. </div>
  47.  
  48. <div id="wall">
  49.  
  50. <%
  51. String url="jdbc:mySql://localhost/indica";
  52. String login="root";
  53. String password="";
  54. Class.forName("com.mysql.jdbc.Driver");
  55. Connection con=DriverManager.getConnection(url,login,password);
  56. Boolean submitted=Boolean.parseBoolean(request.getParameter("submitted"));
  57. if (submitted){
  58. String type=request.getParameter("btn");
  59. ResultSet rs = null;
  60. ResultSet res =null;
  61. PreparedStatement pStart = null;
  62. PreparedStatement pShow = null;
  63.  
  64. //OutputStream img;
  65. Blob imgs ;
  66. byte[] imgDatas = null ;
  67. byte[] imgData = null ;
  68. try{
  69. pStart = con.prepareStatement("SELECT * FROM sunglasses WHERE Gender=?");
  70. pStart.setString(1, type);
  71. rs=pStart.executeQuery();
  72. ArrayList id=new ArrayList();
  73. while(rs.next()){
  74. String strprodvalue = rs.getString("id");
  75. id.add(strprodvalue);
  76. }
  77.  
  78. for (int i = 0; i < id.size(); i++) {
  79. String ids=(String)id.get(i);
  80. Blob image = null;
  81. pShow = con.prepareStatement("SELECT * FROM sunglasses WHERE id=?");
  82. pShow.setString(1, ids);
  83. res=pShow.executeQuery();
  84. while(res.next()){
  85. Blob bl =res.getBlob("image");
  86. byte[] pict = bl.getBytes(1,(int)bl.length());
  87. response.setContentType("image/jpg");
  88. OutputStream o = response.getOutputStream();
  89.  
  90. %>
  91. <TABLE BORDER="1">
  92. <TR>
  93. <TH>picture</TH>
  94. </TR>
  95. <TR>
  96.  
  97. <td>Image</td><td><%o.write(pict); %></td>
  98. <%o.flush();
  99. o.close();%>
  100.  
  101.  
  102. </TR>
  103. </TABLE>
  104. <BR>
  105. <%
  106. o.flush();
  107. o.close();
  108. %>
  109. <%
  110. }
  111. }
  112. }catch(Exception e){
  113. e.printStackTrace();
  114. }
  115. }
  116. %>
  117.  
  118.  
  119. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement