File server (not again...)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

File server (not again...)

Tarkin
Not to beat a dead horse, but I have some details that should enable potential responders to ferret out what I am trying to accomplish...

I have jetty(6.1.3) set up to serve a single webapp, which acts as file repository. That is, users login via a simple jsp, and I have a custom Filter (and some related classes, like DAO) that takes care of session authentication and user management. Users are assigned to a Group, and also have 'role'. User, Group, and Role each have their Attributes defined in the session attributes, and my Filter authenticates the session and populates the User, Group, and Role session attributes on every request (probably overkill, but I am learning).

I am using the Google Web Toolkit as a front-end, and I'd like the users to view, and download, files that are kept in an arbitrary 'data' directory (in my case, $JETTY_HOME/data). So far, I have a nice little RemoteServiceServlet that returns a URL to their Group directory, which is a sub-directory of the data directory. The GWT frontend creates a nice little IFRAME, which handily displays a list of files in that directory with timestamps and sizes.

My difficulty arises when I click on a file...if the file is text, the IFRAME updates with that file as the input...instead of being returned as a download. So far, to test the functionality of the whole shebang, I usually just upload various random text files from the bowels of my $HOME directory....README files, forth listings, java sources, etc. But I dont want to view the files, I want to _download_ them when I click on them, without having to 'Save as...' from within the browser.

Tips, hints, thoughts, suggestions are greatly appreciated.

TIA and TTFN,
  Tarkin

 
Reply | Threaded
Open this post in threaded view
|

Re: File server (not again...)

Tony Thompson
Try setting the Content-Type to "application/force-download".  Sometimes
IE tries to be too helpful.

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Tarkin
Sent: Sunday, June 24, 2007 3:49 AM
To: [hidden email]
Subject: [Jetty-support] File server (not again...)


Not to beat a dead horse, but I have some details that should enable
potential responders to ferret out what I am trying to accomplish...

I have jetty(6.1.3) set up to serve a single webapp, which acts as file
repository. That is, users login via a simple jsp, and I have a custom
Filter (and some related classes, like DAO) that takes care of session
authentication and user management. Users are assigned to a Group, and
also have 'role'. User, Group, and Role each have their Attributes
defined in the session attributes, and my Filter authenticates the
session and populates the User, Group, and Role session attributes on
every request (probably overkill, but I am learning).

I am using the Google Web Toolkit as a front-end, and I'd like the users
to view, and download, files that are kept in an arbitrary 'data'
directory (in my case, $JETTY_HOME/data). So far, I have a nice little
RemoteServiceServlet that returns a URL to their Group directory, which
is a sub-directory of the data directory. The GWT frontend creates a
nice little IFRAME, which handily displays a list of files in that
directory with timestamps and sizes.

My difficulty arises when I click on a file...if the file is text, the
IFRAME updates with that file as the input...instead of being returned
as a download. So far, to test the functionality of the whole shebang, I
usually just upload various random text files from the bowels of my
$HOME directory....README files, forth listings, java sources, etc. But
I dont want to view the files, I want to _download_ them when I click on
them, without having to 'Save as...' from within the browser.

Tips, hints, thoughts, suggestions are greatly appreciated.

TIA and TTFN,
  Tarkin

 
--
View this message in context:
http://www.nabble.com/File-server-%28not-again...%29-tf3971541.html#a112
73084
Sent from the Jetty Support mailing list archive at Nabble.com.


------------------------------------------------------------------------
-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
 
This message (and any associated files) is intended only for the
use of the individual or entity to which it is addressed and may
contain information that is confidential, subject to copyright or
constitutes a trade secret. If you are not the intended recipient
you are hereby notified that any dissemination, copying or
distribution of this message, or files associated with this message,
is strictly prohibited. If you have received this message in error,
please notify us immediately by replying to the message and deleting
it from your computer. Messages sent to and from Stoneware, Inc.
may be monitored.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

Re: File server (not again...)

Tarkin
 
Tony Thompson wrote
Try setting the Content-Type to "application/force-download".  Sometimes
IE tries to be too helpful.

-----Original Message-----
From: jetty-support-bounces@lists.sourceforge.net
[mailto:jetty-support-bounces@lists.sourceforge.net] On Behalf Of Tarkin
Sent: Sunday, June 24, 2007 3:49 AM
To: jetty-support@lists.sourceforge.net
Subject: [Jetty-support] File server (not again...)


Not to beat a dead horse, but I have some details that should enable
potential responders to ferret out what I am trying to accomplish...

I have jetty(6.1.3) set up to serve a single webapp, which acts as file
repository. That is, users login via a simple jsp, and I have a custom
Filter (and some related classes, like DAO) that takes care of session
authentication and user management. Users are assigned to a Group, and
also have 'role'. User, Group, and Role each have their Attributes
defined in the session attributes, and my Filter authenticates the
session and populates the User, Group, and Role session attributes on
every request (probably overkill, but I am learning).

I am using the Google Web Toolkit as a front-end, and I'd like the users
to view, and download, files that are kept in an arbitrary 'data'
directory (in my case, $JETTY_HOME/data). So far, I have a nice little
RemoteServiceServlet that returns a URL to their Group directory, which
is a sub-directory of the data directory. The GWT frontend creates a
nice little IFRAME, which handily displays a list of files in that
directory with timestamps and sizes.

My difficulty arises when I click on a file...if the file is text, the
IFRAME updates with that file as the input...instead of being returned
as a download. So far, to test the functionality of the whole shebang, I
usually just upload various random text files from the bowels of my
$HOME directory....README files, forth listings, java sources, etc. But
I dont want to view the files, I want to _download_ them when I click on
them, without having to 'Save as...' from within the browser.

Tips, hints, thoughts, suggestions are greatly appreciated.

TIA and TTFN,
  Tarkin

 
--
View this message in context:
http://www.nabble.com/File-server-%28not-again...%29-tf3971541.html#a112
73084
Sent from the Jetty Support mailing list archive at Nabble.com.


------------------------------------------------------------------------
-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jetty-support mailing list
Jetty-support@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jetty-support
 
This message (and any associated files) is intended only for the
use of the individual or entity to which it is addressed and may
contain information that is confidential, subject to copyright or
constitutes a trade secret. If you are not the intended recipient
you are hereby notified that any dissemination, copying or
distribution of this message, or files associated with this message,
is strictly prohibited. If you have received this message in error,
please notify us immediately by replying to the message and deleting
it from your computer. Messages sent to and from Stoneware, Inc.
may be monitored.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jetty-support mailing list
Jetty-support@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jetty-support
Actually, I'm developing and browsing on Linux (Debian),  and using Firefox to see my results.
I couldn't find a Content Type of "application/force-download" in a quick scan of the IANA content
types, but your reply got me thinking...

According to the JavaEE Tutorial, the Content Type of a response should be set before the response is committed.
Sounds like a job for my Filter, which should be able to get the request path ( "/data/${group_directory}" ), and set the response content type (to "application/octet-stream", which should force a download) before chaining the request.

Aye, but here's the rub: GWT is rewriting my URLs. Where I would expect to see a ContextPath of "/data/${group_directory}", instead I get null. So I tried getRequestURI(), and get "/Test/B44E63D807E5E86C1EF0D917CE57B43D.cache.html"....
I have no idea how these weirdo hash-named files are mapped, and this breaks my Filter idea.

I've thought of somehow appending a query, and using the Filter to test for the presence of a flag-type parameter, but that seems hackish.  (Ed. note it doesn't appear to work. GWT also appends queries in random-seeming places).

My next thought is to extend org.mortbay.jetty.servlet.DefaultServlet to add this functionality to it, and maybe integrate some of my other needs as well - for example, checking the "Role" session attribute and permitting/denying directory changes as appropriate. (For right now, the default servlet will let me browse the directory all the way back to the resources base, which should not be the behavior for Joe User).

ThanQ and TTFN,
  Tarkin
Reply | Threaded
Open this post in threaded view
|

Re: File server (not again...)

Chris Haynes
Yes - I suggest you do what Tony suggested in an extension of the Default Servlet.

If it still does not work after changing the content type, you might also changing the HTML 'target' attribute of the referring form / anchor so that the response is not handled by the IFRAME, but by the overall main window.

Chris Haynes



On Sunday, June 24, 2007 at 6:42:51 PM, Tarkin wrote:
>  
> Tony Thompson wrote:

>> Try setting the Content-Type to "application/force-download".  Sometimes
>> IE tries to be too helpful.

>> -----Original Message-----
>> From: [hidden email]
>> [mailto:[hidden email]] On Behalf Of Tarkin
>> Sent: Sunday, June 24, 2007 3:49 AM
>> To: [hidden email]
>> Subject: [Jetty-support] File server (not again...)


>> Not to beat a dead horse, but I have some details that should enable
>> potential responders to ferret out what I am trying to accomplish...

>> I have jetty(6.1.3) set up to serve a single webapp, which acts as file
>> repository. That is, users login via a simple jsp, and I have a custom
>> Filter (and some related classes, like DAO) that takes care of session
>> authentication and user management. Users are assigned to a Group, and
>> also have 'role'. User, Group, and Role each have their Attributes
>> defined in the session attributes, and my Filter authenticates the
>> session and populates the User, Group, and Role session attributes on
>> every request (probably overkill, but I am learning).

>> I am using the Google Web Toolkit as a front-end, and I'd like the users
>> to view, and download, files that are kept in an arbitrary 'data'
>> directory (in my case, $JETTY_HOME/data). So far, I have a nice little
>> RemoteServiceServlet that returns a URL to their Group directory, which
>> is a sub-directory of the data directory. The GWT frontend creates a
>> nice little IFRAME, which handily displays a list of files in that
>> directory with timestamps and sizes.

>> My difficulty arises when I click on a file...if the file is text, the
>> IFRAME updates with that file as the input...instead of being returned
>> as a download. So far, to test the functionality of the whole shebang, I
>> usually just upload various random text files from the bowels of my
>> $HOME directory....README files, forth listings, java sources, etc. But
>> I dont want to view the files, I want to _download_ them when I click on
>> them, without having to 'Save as...' from within the browser.

>> Tips, hints, thoughts, suggestions are greatly appreciated.

>> TIA and TTFN,
>>   Tarkin



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support