Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
- {
- Enfants enfants = new Enfants();
- //PrintWriter pw = response.getWriter();
- int id = Integer.parseInt(request.getParameter("id"));
- String url = "jdbc:mysql://localhost:3307/suzieloveschildren";
- String username = "root";
- String password = "";
- String driverName = "com.mysql.jdbc.Driver";
- try {
- Class.forName(driverName);
- Connection connection = DriverManager.getConnection(url, username, password);
- String sql = "SELECT Profile_Pic FROM enfants WHERE id= " + id ;
- System.out.println(sql);
- PreparedStatement stmt = connection.prepareStatement(sql );
- ResultSet rs = stmt.executeQuery();
- if (rs.next())
- {
- byte barray [] = rs.getBytes(1);
- response.setContentType("image/png");
- //System.out.println("Base64 data is " + barray);
- OutputStream img = response.getOutputStream();
- img.write(barray);
- img.flush();
- img.close();
- }
- }
- catch(Exception ex) {
- }
- }
- <img style="max-width: 300px;max-height: 300px;" src="ViewEnfants?id=${enfants.id}" />
- http://localhost:8080/slc/ViewEnfants?id=223
Add Comment
Please, Sign In to add comment