Quantcast
Channel: Active questions tagged servlets - Stack Overflow
Viewing all articles
Browse latest Browse all 714

Why Uploaded Image not being displayed in IE?

$
0
0

I am using simple HTML page for upload and post image to a servlet, then I convert image in byte[] and save it in session using doPost() method:

    response.setContentType("text/html");    items = upload.parseRequest(request);    byte[] byteArray = item.get();    request.getSession().setAttribute("image1", byteArray);    out.println("<html>");    out.println("<body onload='javascript:callParent()'>File uploaded successfully.");    out.println("<img src='/ImageUpload' alt='' id='img2' name='img2' />");    out.println("</body>");    out.println("</html>");

in img tag's src i am calling same servlet and in doGet() get byte[] stored in session andsend them back as following:

    response.setContentType("image/jpeg");    byte[] byteArray =(byte[])request.getSession().getAttribute("image1");    OutputStream output = response.getOutputStream();     output.write(byteArray);    output.close();

This code working fine in Mozilla but not working in IE only red X is being displayed but <img> tag is getting wide according to image size, but not displayed any thing.

Also, when I click submit button twice then the form is submitted in IE, in other words, it is being submitted in one click.

I am using IE-8 and image is of type JPEG.

Is there any setting issue? I tried to search on web, but no any result.


Viewing all articles
Browse latest Browse all 714

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>