aspose file tools
The moose likes JSP and the fly likes File outside war Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "File outside war" Watch "File outside war" New topic

File outside war

Grzegorz Novvak

Joined: Nov 12, 2009
Posts: 12
Using Flex3 I've created a simple VideoPlayer, it works fine, just as it should. Now i want to embed it into a JSP page. I've written something like this:

The VideoPlayer shows up on the page, it works but it does't play the movie located at D:/video.flv
The war archive is deployed in the JBoss deploy dir. When the movie is in the application archive the player plays the movie, but when the video file is somewhere else, outside the archive (like in this example) then the player doesn't play anything.
My question is how to gain access to the video file which is outside the war file?
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 62312

Think about it for a minute. You are telling the browser to look on the D drive. The browser. The browser that runs on the client.

For this to work, every visitor would need to have the file sitting on their local D drives. If they have one. And are running Windows.

You must address the file by URL, not by file path.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Travis Hein
Ranch Hand

Joined: Jun 06, 2006
Posts: 161
First, the url sent needs to be a full web accessible URL, "d:\" only work on your desktop, and outside of a web browser. using "file://" might work, but also only if the browser was on the same machine as the jboss server.

What we need to do is cause that content folder to be served through a HTTP url some how.,

in this case, i would recommend having your jboss app server connected behind an apache server, with mod_jk, perhaps mounted on point /app
so that hitting your page /app/VideoPlayer.jsp would load this page with the flash tags, etc.

and then have the source variable be

where the path /content is mapped to the d:\ folder and is handled by apache , such as a simple directory folder .

Note however this does not enforce any login or security filtering, so anyone with a HTTP client could navigate the contents of the content folder. and thats why we don't have "Options Indexes" in there.

If you did want to continue using just jboss, without getting into using apache, or wanted to have some kind of security filtering, requiring the users to first log in before getting the content, you would need to create a file streamer servlet and have that mapped to (for example, /content/* in your web.xml in your app)

Here is a simple example of this, where it takes the path following the servlet mapping and tries to resolve that to a file name inside the content folder (d:\ in this case)

Where this servlet doesn't do any "is logged in checking", I was thinking a servlet filter would do that for us, mapped to /content/* as well.

If there is no requirement to have users logged in before getting the content, I would recommend letting apache serve the media content, as a native process it might handle high thrughputs better, and certainly would not cause the precious resource of worker threads in jboss to be tied up to serve this static content.

Error: Keyboard not attached. Press F1 to continue.
Grzegorz Novvak

Joined: Nov 12, 2009
Posts: 12
Thanks for the replies

I have few questions.

The solution with two servers is new to me, I've looked up for tutorials or hints how to do it, I've found these two:
Is it a good point to start with? I'll look into this when I have more time.

The solution with a servlet.
As I understand this solution is similar to downloading a file from the server to a local machine, am I right?
What would be the value of the source var in my JSP which I pass to Flex? Just the name of the video file?

The app and the server runs on my PC
Travis Hein
Ranch Hand

Joined: Jun 06, 2006
Posts: 161
No, I think the servlet approach would still need to use a full HTTP front end URL.

JBoss on its own without apache still has an internal HTTP server built into it, the servlet JSP code is only ran within the server, communicating to it with a browser client is done with rendered HTML over HTTP still.

so the url value for 'source' would be the path as would be seen by your web browser connecting to the JBoss service, plus the contextPath of the webapp, and the servletPath we have mapped the content file servlet to, and then the name of the content file within our file system folder.


where ${fileName} should exist in "d:\"
I agree. Here's the link:
subject: File outside war