hi
i have extracted the image from the repository ( as Inputstram) in a servlet
and now i need to pass it to the JSP and make it display but with some other
text fields as well . but when i use my below code it displays the object
but not the text... and also it throws a exception as well ( when 'forward'
of dispatcher is called)
servlet code
----------
InputStream pic = null;
try {
OutputStream os = null;
response.setContentType("image/jpeg");
try {
pic = profileImgManageBean.viewImage("fileName");
int read = 0;
byte[] bytes = new byte[1024];
os = response.getOutputStream();
while ((read = pic.read(bytes)) != -1) {
os.write(bytes, 0, read);
}
} catch (ImageNotFoundException imE) {
}
RequestDispatcher view =
request.getRequestDispatcher("view.jsp");
view.forward(request, response);
os.close();
} catch (Exception ex) {
Logger.getLogger(ViewImage.class.getName()).log(Level.SEVERE,
null, ex);
} finally {
pic.close();
JSP code
-------
<[EMAIL PROTECTED] contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>User Prifile Picture</title>
</head>
<body>
<h2>Profile Picture</h2>
<%=response.encodeURL(request.getContextPath())% BORDER=0
WIDTH=16 HEIGHT=16>
</body>
</html>
can anyone say the proper way to diaplay the image( also i need to know for
other documents as well e. g pdf..) please help.....
--
View this message in context:
http://www.nabble.com/displaying-the-image-using-JSP-tp20766990p20766990.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.