469,283 Members | 2,263 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,283 developers. It's quick & easy.

File Persistence In the Session Object

I am developing a Struts1.1 based application, that returns an Excel
File generated by Jakarta's POI classes. One of the requirements is
that the file be stored in the SESSION ONLY, not on the file system.

Is this even possible? Doesn't a file need to be physically present
before a reference to it can be stored in the session?

prompt insight would be most appreciated, as I'm working against a
deadline.

Thanks!

PK
Jul 17 '05 #1
5 3737
The browser just reacts to an input stream. Some browsers tend to open
MS Excel when they receive a special input stream. I don't know POI but
I'm sure you can write the created Excel file from memory to any kind of
output stream, e.g. one created by HttpResponse.getOutputStream.
So you'd not store the file in the HttpSession but stream it directly to
the browser of the client. The client could save the received excel file
to disk.

Patrick
Kid A wrote:
I am developing a Struts1.1 based application, that returns an Excel
File generated by Jakarta's POI classes. One of the requirements is
that the file be stored in the SESSION ONLY, not on the file system.

Is this even possible? Doesn't a file need to be physically present
before a reference to it can be stored in the session?

prompt insight would be most appreciated, as I'm working against a
deadline.

Thanks!

PK


Jul 17 '05 #2
That is true, and that was the way I designed the application at
first.
But there needs to be a way for the user, as reports are being
created, to be stored by the session, and then have the option of
downloading them from an index of created files, but this list would
only persist as long as the session is active.

For example, the system generated 3 files. The user clicks on a link
to take them to a list of the files that were created in that session,
and they should be able to download whichever of the three they want,
when they want, but as soon as the session is expired/logout, the
files are lost.

I believe it's IMPOSSIBLE to store an OutputStream in the session,
true?

-PK

Patrick Carl <ca**********@nefkom.net> wrote in message news:<bm**********@news1.nefonline.de>...
The browser just reacts to an input stream. Some browsers tend to open
MS Excel when they receive a special input stream. I don't know POI but
I'm sure you can write the created Excel file from memory to any kind of
output stream, e.g. one created by HttpResponse.getOutputStream.
So you'd not store the file in the HttpSession but stream it directly to
the browser of the client. The client could save the received excel file
to disk.

Patrick
Kid A wrote:
I am developing a Struts1.1 based application, that returns an Excel
File generated by Jakarta's POI classes. One of the requirements is
that the file be stored in the SESSION ONLY, not on the file system.

Is this even possible? Doesn't a file need to be physically present
before a reference to it can be stored in the session?

prompt insight would be most appreciated, as I'm working against a
deadline.

Thanks!

PK

Jul 17 '05 #3
You can't store an OutputStream in the session, but you should be able
to store the byte array associated with that OutputStream. I'm
assuming POI pumps out a byte array at some point... instead of
putting that into the OutputStream, save it to the session.

-Nathan

pa******@hotmail.com (Kid A) wrote in message news:<53*************************@posting.google.c om>...
That is true, and that was the way I designed the application at
first.
But there needs to be a way for the user, as reports are being
created, to be stored by the session, and then have the option of
downloading them from an index of created files, but this list would
only persist as long as the session is active.

For example, the system generated 3 files. The user clicks on a link
to take them to a list of the files that were created in that session,
and they should be able to download whichever of the three they want,
when they want, but as soon as the session is expired/logout, the
files are lost.

I believe it's IMPOSSIBLE to store an OutputStream in the session,
true?

-PK

Patrick Carl <ca**********@nefkom.net> wrote in message news:<bm**********@news1.nefonline.de>...
The browser just reacts to an input stream. Some browsers tend to open
MS Excel when they receive a special input stream. I don't know POI but
I'm sure you can write the created Excel file from memory to any kind of
output stream, e.g. one created by HttpResponse.getOutputStream.
So you'd not store the file in the HttpSession but stream it directly to
the browser of the client. The client could save the received excel file
to disk.

Patrick
Kid A wrote:
I am developing a Struts1.1 based application, that returns an Excel
File generated by Jakarta's POI classes. One of the requirements is
that the file be stored in the SESSION ONLY, not on the file system.

Is this even possible? Doesn't a file need to be physically present
before a reference to it can be stored in the session?

prompt insight would be most appreciated, as I'm working against a
deadline.

Thanks!

PK

Jul 17 '05 #4
So why do you generate the files before offering the links? You could
offer the user the three different possibilities and after he selects
one you create the demanded Excel file. You'd just offer the links, not
the files. Furthermore you wouldn't have to create three files when two
are thrown away.

Patrick

Kid A wrote:
That is true, and that was the way I designed the application at
first.
But there needs to be a way for the user, as reports are being
created, to be stored by the session, and then have the option of
downloading them from an index of created files, but this list would
only persist as long as the session is active.

For example, the system generated 3 files. The user clicks on a link
to take them to a list of the files that were created in that session,
and they should be able to download whichever of the three they want,
when they want, but as soon as the session is expired/logout, the
files are lost.

I believe it's IMPOSSIBLE to store an OutputStream in the session,
true?

-PK

Patrick Carl <ca**********@nefkom.net> wrote in message news:<bm**********@news1.nefonline.de>...
The browser just reacts to an input stream. Some browsers tend to open
MS Excel when they receive a special input stream. I don't know POI but
I'm sure you can write the created Excel file from memory to any kind of
output stream, e.g. one created by HttpResponse.getOutputStream.
So you'd not store the file in the HttpSession but stream it directly to
the browser of the client. The client could save the received excel file
to disk.

Patrick
Kid A wrote:
I am developing a Struts1.1 based application, that returns an Excel
File generated by Jakarta's POI classes. One of the requirements is
that the file be stored in the SESSION ONLY, not on the file system.

Is this even possible? Doesn't a file need to be physically present
before a reference to it can be stored in the session?

prompt insight would be most appreciated, as I'm working against a
deadline.

Thanks!

PK


Jul 17 '05 #5
These are great suggestions, I'll definitly look into them and see
what works best for our needs. I'll let you know what I decide to do.
Thanks!
Patrick Carl <ca**********@nefkom.net> wrote in message news:<bm**********@news1.nefonline.de>...
So why do you generate the files before offering the links? You could
offer the user the three different possibilities and after he selects
one you create the demanded Excel file. You'd just offer the links, not
the files. Furthermore you wouldn't have to create three files when two
are thrown away.

Patrick

Kid A wrote:
That is true, and that was the way I designed the application at
first.
But there needs to be a way for the user, as reports are being
created, to be stored by the session, and then have the option of
downloading them from an index of created files, but this list would
only persist as long as the session is active.

For example, the system generated 3 files. The user clicks on a link
to take them to a list of the files that were created in that session,
and they should be able to download whichever of the three they want,
when they want, but as soon as the session is expired/logout, the
files are lost.

I believe it's IMPOSSIBLE to store an OutputStream in the session,
true?

-PK

Patrick Carl <ca**********@nefkom.net> wrote in message news:<bm**********@news1.nefonline.de>...
The browser just reacts to an input stream. Some browsers tend to open
MS Excel when they receive a special input stream. I don't know POI but
I'm sure you can write the created Excel file from memory to any kind of
output stream, e.g. one created by HttpResponse.getOutputStream.
So you'd not store the file in the HttpSession but stream it directly to
the browser of the client. The client could save the received excel file
to disk.

Patrick
Kid A wrote:

I am developing a Struts1.1 based application, that returns an Excel
File generated by Jakarta's POI classes. One of the requirements is
that the file be stored in the SESSION ONLY, not on the file system.

Is this even possible? Doesn't a file need to be physically present
before a reference to it can be stored in the session?

prompt insight would be most appreciated, as I'm working against a
deadline.

Thanks!

PK

Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Simon Harvey | last post: by
4 posts views Thread by Marcel Balcarek | last post: by
3 posts views Thread by Jo Inferis | last post: by
7 posts views Thread by Steve Mauldin | last post: by
2 posts views Thread by dkode | last post: by
3 posts views Thread by Robert | last post: by
4 posts views Thread by =?Utf-8?B?YWtzaGF5am9odXI=?= | last post: by
4 posts views Thread by coldpizza | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.