• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF - mask URL to protect content  RSS feed

 
Johnny Bacu
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to mask an URL in JSF such that the server (knows)refers to the actual file while the client is aware of a temporary generated URL?
Let's say, the client requests URL:

www.mydomain.com/temporary_generated_non_existent_folder/file1.flv

The server knows that the requested file is actually located in

www.mydomain.com/real_location/file1.flv

And provides that correct file, while hiding from the client the real URL.
So, if the client tries again that URL, this time the server knows that the URL has been used and is not valid anymore, it provides www.mydomain.com/url_not_valid.htm

Also, on the server side, I cannot load the FLV file into memory and then feed the bytes to the output stream of the http request since the file could be really large.

Thanks
 
Tim Holloway
Bartender
Posts: 18715
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Clients never really know anything about server files. A URL is not a filename locator, despite its resemblance to a filename path, and web servers are different software than file servers. So a properly-configured webapp can take any given URL and, using its own programmer-codes criteria, synthesize or copy any response it wants.

In the case of a multi-megabyte multimedia file, definitely you don't want to load to RAM then copy. Not only does it eat lots of RAM, but it takes extra time to do it in 2 stages. However, the Java IO system is stream-based, so you can copy fixed content from a webapp resource or external file in more manageable chunks. Typically, you'd allocate a byte buffer of , say 4K bytes. Then you'd open your streams, stream in 4K of input to the buffer, stream it out to the Response stream, then repeat the loop until there was no more data. This is bog-standard code for doing file copies in Java, whether it's done in webapps or just a desktop app that needs to copy a file. If you want to get fancy, you can double-buffer the process, but the basic strategy remains the same.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!