jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From far4ever <fathimafarh...@gmail.com>
Subject displaying the image using JSP
Date Mon, 01 Dec 2008 07:05:10 GMT

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
-------
<%@page 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.


Mime
View raw message