Advertisement
Guest User

Untitled

a guest
Dec 19th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.42 KB | None | 0 0
  1. <%--
  2. Document : passwordForm
  3. Created on : Nov 26, 2017, 2:24:41 AM
  4. Author : hp
  5. --%>
  6.  
  7. <%@page import = "java.io.File"%>
  8. <%@page import = "org.apache.commons.fileupload.FileItem"%>
  9. <%@page import = "java.util.Iterator"%>
  10. <%@page import = "org.apache.commons.fileupload.FileUploadException"%>
  11. <%@page import = "java.util.List"%>
  12. <%@page import = "org.apache.commons.fileupload.disk.DiskFileItemFactory"%>
  13. <%@page import = "org.apache.commons.fileupload.FileItemFactory"%>
  14. <%@page import = "org.apache.commons.fileupload.servlet.ServletFileUpload"%>
  15. <%@page import = "java.sql.ResultSet"%>
  16. <%@page import = "java.sql.Connection"%>
  17. <%@page import = "java.sql.Statement"%>
  18. <%@page import = "java.sql.DriverManager"%>
  19. <%@page contentType = "text/html" pageEncoding="UTF-8"%>
  20.  
  21. <!DOCTYPE html>
  22. <%
  23. String UserID = "";
  24. if (((String) session.getAttribute("UserID")) != null) {
  25. UserID = (String) session.getAttribute("UserID");
  26. }
  27. String Group = "";
  28. if (((String) session.getAttribute("Group")) != null) {
  29. Group = (String) session.getAttribute("Group");
  30. }
  31.  
  32. String Name = "";
  33. if (((String) session.getAttribute("Name")) != null) {
  34. Name = (String) session.getAttribute("Name");
  35. }
  36. %>
  37. <html>
  38. <head>
  39. <title>Product</title>
  40. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>
  41. <link rel="stylesheet" href="css/layout.css" type="text/css" />
  42. <script type="text/javascript" src="jquery.min.js"></script>
  43. <!-- Waterwheel Carousel -->
  44. <script type="text/javascript" src="jquery.waterwheelCarousel.min.js"></script>
  45. <script type="text/javascript" src="jquery.waterwheelCarousel.setup.js"></script>
  46. <!-- / Waterwheel Carousel -->
  47.  
  48. <script language="JavaScript" src="addImage.js">
  49.  
  50. </script>
  51. </head>
  52. <body id="top">
  53. <div class="wrapper col1">
  54. <div id="header">
  55.  
  56. <h1><a href="HOMEPAGE.html">MISS BROWNIES</a></h1>
  57. <%
  58. if (Group.equals("Customer")) {
  59. %>
  60. <br>
  61. <br>
  62. <h6>Welcome <%=Name%>! </h6>
  63. <%
  64. } else if (Group.equals("Admin")) {
  65. %>
  66. <br>
  67. <br>
  68. <h6>Welcome Admin <%=Name%>! </h6>
  69. <%
  70. }
  71. %>
  72. </div>
  73. </div>
  74. <!-- ####################################################################################################### -->
  75. <div class="wrapper col3">
  76. <div id="topbar">
  77. <div id="topnav">
  78. <ul>
  79. <%
  80. if (UserID.equals("")) {
  81. %>
  82. <li class="active"><a href="Login.jsp">Login</a></li>
  83. <li><a href="homepage.jsp">Homepage</a></li>
  84. <li><a href="about.jsp">About Us</a></li>
  85. <li><a href="">Custom >> </a>
  86. <ul>
  87. <li><a href="product.jsp">Gallery</a></li>
  88. <li><a href="custom.jsp">Product</a></li>
  89. </ul>
  90. </li>
  91. <li><a href="contact.jsp">Contact Us</a></li>
  92. <%
  93. }
  94. %>
  95.  
  96.  
  97. <!-- MENU FOR CUSTOMER -->
  98. <%
  99. if (Group.equals("Customer")) {
  100. if (UserID.equals("")) {
  101. %>
  102. <li class="active"><a href="Login.jsp">Login</a></li>
  103. <%
  104. }
  105. %>
  106. <li><a href="homepage.jsp">Homepage</a></li>
  107. <li><a href="about.jsp">About Us</a></li>
  108. <li><a href="contact.jsp">Contact Us</a></li>
  109. <li><a href="">Custom >> </a>
  110. <ul>
  111. <li><a href="product.jsp">Gallery</a></li>
  112. <li><a href="custom.jsp">Product</a></li>
  113. </ul>
  114. </li>
  115. <%
  116. if (!UserID.equals("")) {
  117. %>
  118. <li><a href="">My Account >></a>
  119. <ul>
  120. <li><a href="profile.jsp">Profile</a></li>
  121. <li><a href="passwordForm.jsp">Change Password</a></li>
  122. <li><a href="myorder.jsp">Order</a></li>
  123. </ul
  124. </li>
  125. <li><a href="logout.jsp">Logout</a></li>
  126.  
  127.  
  128.  
  129. <!-- MENU FO ADMIN -->
  130. <%
  131. }
  132. } else if (Group.equals("Admin")) {
  133. if (UserID.equals("")) {
  134. %>
  135. <li><a href="Login.jsp">Login</a></li>
  136. <%
  137. }
  138. %>
  139. <li><a href="homepage.jsp">Homepage</a></li>
  140. <li><a href="about.jsp">About Us</a></li>
  141. <li><a href="custom.jsp">Product</a></li>
  142. <li><a href="">Order >></a>
  143. <ul>
  144. <li><a href="orderPending.jsp">Pending</a></li>
  145. <li><a href="onGoing.jsp">On Going</a></li>
  146. <li><a href="orderDone.jsp">Done</a></li>
  147. <li><a href="orderSuccess.jsp">Paid</a></li>
  148. </ul>
  149. </li>
  150. <li><a href="report.jsp">Report</a></li>
  151. <li><a href="logout.jsp">Logout</a></li>
  152. <%
  153. }
  154. %>
  155. </ul>
  156. </div>
  157. <div id="search">
  158. <form action="#" method="post">
  159. <fieldset>
  160. <legend>Site Search</legend>
  161. <input type="text" value="Search Our Website&hellip;" onfocus="this.value = (this.value == 'Search Our Website&hellip;') ? '' : this.value;" />
  162. <input type="submit" name="go" id="go" value="Search" />
  163. </fieldset>
  164. </form>
  165. </div>
  166. <br class="clear" />
  167. </div>
  168.  
  169. </div>
  170. <!-- ####################################################################################################### -->
  171. <%
  172. Connection connection = null;
  173. Class.forName("org.gjt.mm.mysql.Driver");
  174. String url = "jdbc:mysql://localhost/dbbrownies";
  175. String user = "root";
  176. String pwd = "";
  177.  
  178. connection = DriverManager.getConnection(url, user, pwd);
  179. Statement statement = connection.createStatement();
  180.  
  181. try {
  182.  
  183. String ImageFile = "";
  184. String itemName = "";
  185. boolean isMultipart = ServletFileUpload.isMultipartContent(request);
  186. if (!isMultipart) {
  187. } else {
  188. FileItemFactory factory = new DiskFileItemFactory();
  189. ServletFileUpload upload = new ServletFileUpload(factory);
  190. List items = null;
  191. try {
  192. items = upload.parseRequest(request);
  193. } catch (FileUploadException e) {
  194. e.getMessage();
  195. }
  196.  
  197. Iterator itr = items.iterator();
  198. while (itr.hasNext()) {
  199. FileItem item = (FileItem) itr.next();
  200. if (item.isFormField()) {
  201. String name = item.getFieldName();
  202. String value = item.getString();
  203. if (name.equals("ImageFile")) {
  204. ImageFile = value;
  205. }
  206.  
  207. } else {
  208. try {
  209. itemName = item.getName();
  210. File savedFile = new File(config.getServletContext().getRealPath("/") + "\\images\\" + itemName);
  211. item.write(savedFile);
  212. } catch (Exception e) {
  213. out.println("Error" + e.getMessage());
  214. }
  215. }
  216. }
  217. try {
  218. statement.executeUpdate("insert into product(proimage, adminID) values ('" + itemName + "','" + UserID + "')");
  219.  
  220. } catch (Exception el) {
  221. out.println("Inserting error" + el.getMessage());
  222. }
  223. }
  224. } catch (Exception e) {
  225. out.println(e.getMessage());
  226. }
  227. %>
  228. <!-- ####################################################################################################### -->
  229. <div class="wrapper col4">
  230. <div id="container">
  231.  
  232. <h1 align="center" style="font-family:Comic Sans MS; font-size:50px; color:#daa520"><b>PRODUCT</b></h1>
  233.  
  234. <form name="menu" action="addMenu.jsp" method="post" >
  235. <table>
  236. <tr>
  237. <td colspan="2"><h2 style="font-size:30px;">Add Product</h2></td>
  238. </tr>
  239. <tr>
  240. <td><h1>Name: </h1></td>
  241. <td><input type="text" name="pName" size="50"></td>
  242. </tr>
  243. <tr>
  244. <td><h1>Topping: </h1></td>
  245. <td>
  246. <input type="text" name="pTopping" size="50"></td>
  247. </tr>
  248. <tr>
  249. <td><h1>Price </h1></td>
  250. <td><input type="text" name="pPrice" size="50"></td>
  251. </tr>
  252. <tr>
  253. <td><h1>Serving </h1></td>
  254. <td><input type="text" name="pServing" size="50"></td>
  255. </tr>
  256. <tr>
  257. <td><h1>Description </h1></td>
  258. <td><textarea name="pDesc" rows="6" cols="45"></textarea></td>
  259. </tr>
  260. <tr>
  261. <td>&nbsp;</td>
  262. <td>
  263. </br>
  264. <input type="submit" name="Submit" value="ADD" style="font--size:7pt; background-color:yellow; font-family:Georgia; padding:3px;" onClick="return check()">&nbsp;&nbsp;
  265. <input type="reset" name="Reset" style="font--size:7pt; background-color:yellow; font-family:Georgia; padding:3px;" value="CANCEL"></br>
  266. </td>
  267. </tr>
  268. </table>
  269. </form>
  270.  
  271.  
  272. </div>
  273. </div>
  274. <!-- ####################################################################################################### -->
  275. <div class="wrapper col6">
  276. <div id="copyright">
  277. <p class="fl_left">Copyright &copy; 2014 - All Rights Reserved - <a href="#">MISS BROWNIES</a></p>
  278. <p class="fl_right"> <a target="_blank" href="http://www.os-templates.com/" title="Free Website Templates">MISS BROWNIES</a></p>
  279. <br class="clear" />
  280. </div>
  281. </div>
  282. </body>
  283. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement