I am using simple HTML page for upload and post image to servlet then I convert image in byte[] and save 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 and
send 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 form get submitted in IE in other it is being submit in one click.
I am using IE-8 and image is of type .JPEG.
is there is any setting issue I tried to search on web but no any result.
Actually i was using onload() event of body tag to open browse button automatically.
but when i remove code for opening browse through java script it started working fine with IE i don’t know what is the problem with IE and java script now i am clicking browse button manually and everything is working.