Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. <%@page import="javax.servlet.annotation.MultipartConfig"%>
  2. <%@page import="java.sql.*"%>
  3. <%@page import="java.io.InputStream"%>
  4. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  5.  
  6.  
  7. <%
  8. request.setCharacterEncoding("UTF-8");
  9. Part p = request.getPart("image");
  10. InputStream inputStream = null;
  11. if (p != null) {
  12. inputStream = p.getInputStream();
  13. }
  14.  
  15. String driver = "com.mysql.jdbc.Driver";
  16. String url = "jdbc:mysql://localhost:3306/test42";
  17. Class.forName(driver);
  18. Connection con = DriverManager.getConnection(url, "root", "1234");
  19.  
  20. String sqlString = "INSERT INTO test42.images items(idimages) values(" + inputStream + ");";
  21.  
  22. String msg = p.toString();
  23.  
  24. %>
  25.  
  26. <form method="post" action="mainPage.jsp" enctype="multipart/form-data">
  27. choose file :
  28. <input type="file" name="image" />
  29.  
  30. <input type="submit" value="submit">
  31. </form>
  32.  
  33. java.lang.IllegalStateException: Request.getPart is called without multipart configuration. Either add a @MultipartConfig to the servlet, or a multipart-config element to web.xml
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement