I am retrieving image bytes from mysql database through the following Servlet method:
and then display the image bytes in a jsp page.
Please tell me how do I use the img tag in my jsp page.
public byte[] getProfilePicture( int id ) {
byte[] bytes = null;
try {
connection = dataSource.getConnection();
pst = connection.prepareStatement("SELECT profile_picture FROM users WHERE id = '"+id+"' ");
resultSet = pst.executeQuery();
while( resultSet.next() ) {
bytes = resultSet.getBytes("profile_picture");
}
} catch(Exception e) {
e.printStackTrace();
}
return bytes;
}
Thanks, I am waiting for your kind response.