473,465 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Image loading

8 New Member
Hi
I am doing image upload in my application. I am getting the image from the FormFile .I am converting the image into byte[] and storing those image in a drive.
But is there any possible way to store the image in the session as byte[] and then converting these bytes[] back to an image .
For example in my application in the first page I am allowing user to upload the image and in the next page I am displaying the image for confirmation.
So in the first page image are allowed to uploaded then in the second page images should obtained from the session .only on the confirmation page image need to be stored in the server. If it is possible please provide me the guidance for the above process.


Thanks
Apr 17 '09 #1
5 2579
debasisdas
8,127 Recognized Expert Expert
what is the language that you are using ?
Apr 20 '09 #2
shareme
8 New Member
Hi
Thank you for your reply.I am using java ,jsp.
Apr 20 '09 #3
ne0lithic
9 New Member
I think you could do this by creating a BufferedImage (java.awt.image.BufferedImage). That way you don't need a byte array each time. You can save your BufferedImage as a session variable if you use:

Expand|Select|Wrap|Line Numbers
  1. BufferedImage bufferedImage = ImageIO.read(new File("somePicture.jpg"));
  2. session.setAttribute("myPicture",bufferedImage);
  3.  
Cheers.

Nikhil
Apr 23 '09 #4
dmjpro
2,476 Top Contributor
@shareme
So you are using web application?
Google with "file uploading using JSP", you will find something "multipart-request" and rest you will understand. Once your file gets uploaded then you can view it on your page, if user doesn't want to keep it anymore then delete it ;)
Apr 23 '09 #5
shareme
8 New Member
Hi
Thank u for your reply. I used your suggestion. It works fine .Now I am using another approach here is the code.
Action file:
Expand|Select|Wrap|Line Numbers
  1.  
  2. HttpSession httpSession = request.getSession(true);
  3.  httpSession.setAttribute("stream",venueManagementForm.getSelfPhoto_Path().getInputStream());
  4.  
image.jsp:

Expand|Select|Wrap|Line Numbers
  1. <%@ page import="java.io.*" %>
  2.  
  3.         <%@ page import="java.net.*" %>
  4.  
  5.         <%@page contentType="image/gif" %>
  6.  
  7.         <%
  8.  
  9.             OutputStream o = response.getOutputStream();         
  10.  
  11.            InputStream is = (InputStream)session.getAttribute("stream");    
  12.  
  13.             byte[] buf = new byte[32 * 1024]; // 32k buffer
  14.  
  15.             int nRead = 0;
  16.  
  17.             while( (nRead=is.read(buf)) != -1 ) {
  18.  
  19.                       o.write(buf, 0, nRead);
  20.  
  21.             }
  22.  
  23.             o.flush();;
  24.  
  25.             o.close();
  26.  
  27.             return; 
  28.  
  29.         %>
  30.  
  31.  
  32.  
Display Jsp:


Expand|Select|Wrap|Line Numbers
  1.         <img src="<%="/admin/venueManagement/image.jsp"%>" width="300" height="337">
  2.  
The above process works fine .
Apr 25 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: OneSolution | last post by:
Hi All, Here's what I'm trying to do. I have a diverse customer base, and as it grows, it's increasingly harder to figure out what aspect of our web site is selling and what is not. So I've...
2
by: Mekon | last post by:
I have never written a line of script in my life but I need some help with it now. I have this auto generated code which I want to modify if possible The script generates a strip of...
2
by: Rob Manger | last post by:
Hi All, I am hoping someone can help me. I am trying to setup my main page so that when the user moves the mouse over an image, it changes the source (got this working). When the user CLICKS...
4
by: zborisau | last post by:
Hey good people, I've been given a problem to solve recently - and stuck with the solution for a good 4 days already. i have a link which leads to popup window. the purpose of that popup...
4
by: Sharon | last post by:
Hi Everyone, I have a TIF file 62992 x 113386 Pixels, Huffman RLE compression, 3200 x 3200 DPI resolution, binary colored (1 Bit Per Pixel), file on disk size 43.08 MB (45,169,042 Bytes). This...
4
by: Bruce | last post by:
I have an asp.net page that is dynamically building a table and populating cells with images (typically jpeg) and with associated metadata. How can the asp.net code efficiently determine the...
1
by: agatha.life | last post by:
I did a javascript for the loading of images (I didn't want to have the images loaded in "on loading" because they are too many). The website is for a model and if you look at the codeof pages (...
14
by: Steve K. | last post by:
I have a method that I use to get a System.Drawing.Image from a file without keeping a handle on the file open (so I can delete the file). Here is the code: <code> public static Image...
4
by: Sophy | last post by:
Hi folks, Now, I am facing problem with canceling image loading. I have tried: var img = new Image(); img.src = "path/to/the/image"; // and then I set the img.src to another source
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.