Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String relativeWebPath = "/temp_image";
- UPLOAD_DIRECTORY = getServletContext().getRealPath(relativeWebPath);
- String UPLOAD = "";
- PrintWriter out = response.getWriter();
- try
- {
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/shopbyway","root","");
- st = con.createStatement();
- st2 = con.createStatement();
- st3 = con.createStatement();
- }
- catch(Exception e)
- {
- }
- //process only if its multipart content
- int count=0;
- String temp="";
- String file_name="A";
- String p_name="";
- String product_description="";
- String uploadFilePath="uploads\\";
- String user="";
- String n_cate="";
- String name="";
- String newp="";
- String category_name="";
- int p_id=0;
- int p_cate=0;
- int c_cate=0;
- int shop_id=0;
- int k=0;
- int price=0;
- int old=0;
- ResultSet rs,rs2;
- FileItem fileitem = null;
- String UPLOAD_DIR = "uploads\\";
- if(ServletFileUpload.isMultipartContent(request))
- {
- try {
- List<FileItem> multiparts = new ServletFileUpload(
- new DiskFileItemFactory()).parseRequest(request);
- for(FileItem item : multiparts)
- {
- if (item.isFormField())
- {
- if(item.getFieldName().equals("shop_name"))
- {
- temp = item.getString();
- shop_id = Integer.parseInt(temp);
- }
- if(item.getFieldName().equals("p_cate"))
- {
- temp = item.getString();
- p_cate = Integer.parseInt(temp);
- }
- if(item.getFieldName().equals("p_name"))
- {
- p_name = item.getString();
- }
- if(item.getFieldName().equals("newp"))
- {
- newp = item.getString();
- }
- if(item.getFieldName().equals("product_description"))
- {
- product_description = item.getString();
- }
- if(item.getFieldName().equals("price"))
- {
- temp = item.getString();
- price = Integer.parseInt(temp);
- }
- if(item.getFieldName().equals("shop_owner"))
- {
- user = item.getString();
- }
- }
- if(!item.isFormField()){
- //out.println(item);
- fileitem = item;
- name = new File(item.getName()).getName();
- file_name = item.getName();
- item.write( new File(UPLOAD_DIRECTORY + File.separator + name));
- //item.write( new File(uploadFilePath));*/
- }
- }
- out.println("\nFile uploaded successfully");
- //response.sendRedirect("/shop_temp/index.jsp");
- } catch (Exception ex) {
- }
- }else{
- }
- UPLOAD = file_name;
- if(p_name.equals(""))
- {
- old=0;
- p_name = newp;
- }
- else
- {
- old=1;
- }
- out.println(user+"<br>");
- out.println(shop_id+"<br>");
- out.println(p_name+"<br>");
- out.println(product_description+"<br>");
- out.println(price+"<br>");
- out.println(p_cate+"<br>");
- out.println(old+"<br>");
- String que = "insert into approval values(null,'"+user+"',"+shop_id+",'"+p_name+"','"+product_description+"',"+price+","+p_cate+",'"+UPLOAD+"',"+old+",0);";
- try
- {
- st3.executeUpdate(que);
- }
- catch(SQLException e)
- {
- }
- response.sendRedirect("/shop_temp/manage_products.jsp?mesg=We will verify your product with in 24 working hour");
Add Comment
Please, Sign In to add comment