Я пытаюсь получить изображение, хранящееся в базе данных MYSQL и установить его на странице JSP, но я получаю следующее сообщение об ошибке:Настройка изображения из базы данных
Servlet.service() for servlet [SearchStudentControlling] in context with path [/Roomantech] threw exception [java.lang.IllegalStateException: getOutputStream() contain error so i didn,t the image in my jsp page
Я использую следующий код, чтобы получить и установите изображение. Я получаю ошибку на строке номер 339, которая не существует (мой код имеет только 312 строк). Я боролся последние два часа, но не мог определить проблему.
session = request.getSession(false);
if(session!=null)
{
%>
<div style="width:100%;height:70%;">
<%@include file="header.jsp"%>
<div align="center" style="margin-top:150px">
<table align="center" width="73%;" height="100%;" class="abc">
<form action="nextpersonalinformation.do" method="post">
<strong><h2 style="color: darkblue;margin-bottom:30px;"><b><u>Person Information****</b></u></h2></strong>
<tr><td></td><td></td></tr>
<tr style="background-color: #003366;color: white;border-radius:5px"><td><h4 style="color: darkblue"><b style="color: white"> Your Hostel details****:</b></h4></td><td><b style="color: white">Enter Values:</b></td></tr>
<tr><td></td><td></td></tr>
<tr style="background-color: teal;font-size: 20px"></tr>
<%
ArrayList<PersonDetaildto>pa = (ArrayList<PersonDetaildto>)session.getAttribute("InformationPerson");
for(PersonDetaildto kk : pa)
{
System.out.println(kk.getFirst_nm()+" "+kk.getMiddle_nm());
%>
<tr>
<td>Person Image</td>
<td><img height="75px" width="75px" align="left" src="
<% byte[] imgbytes = kk.getPerson_image();
InputStream images = kk.getPersonimagee();
int size1=0;
response.reset();
response.setContentType("image/jpeg");
response.addHeader("Content-Disposition","filename=logo.jpg");
while((size1=images.read(imgbytes))!= -1)
{
response.getOutputStream().write(imgbytes,0,size1);
}
response.flushBuffer();
images.close();
%>"/></td>
</tr>
<tr><td></td><td></td></tr>
<tr><td></td><td></td></tr>
<tr><td></td><td></td></tr>
<tr>
</table>
</div>
<div style="width:100%;height:200px;">
</div>
<%
}
}
else
{
response.sendRedirect("welcome.do");
}
%>
<%@include file="footer.jsp"%>
</body>
</html>
Вы каким-то образом сохранить изображение в базе данных? – hubert