This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am using the Websphere 5.1 container. in my jsp page I have a link which should linke to one secure zip file, we'd like to put under the /WEB-INF/ since the webuser can't directly access them by typing the file URL.
but the authorized user should still be able to access it, so I tried to make the access link to call a Struts action, which forward back the zip file. somehow, it does not work. I am wondering does Websphere container suport server side redirect files which are put under /WEB-INF?
here is the struts action mapping I used (which is not working, the web page display HTTP 403 forbidden error) : path="/download" type="org.apache.struts.actions.ForwardAction" parameter="/WEB-INF/downlaod/my.zip" />
If you really want to store this file in WEB-INF, you can't access it through a forward or a link, as security will stop you. You will have to write an action class that will read this file using the java.io.* classes, and then output it to an output stream in HTTPServetResponse. Unzip the struts-examples.war that comes with the Struts 1.2 download, and look at ImageAction.java for an example of how to do this.
Thanks Merrill, did struts1.0/1.1 suport this streaming? I am using struts1.0, from the examples there I don't see thay have the streaming examples.
Joined: Feb 15, 2005
There's nothing new about the streaming technique. I'm sure it will work with Struts 1.1. It's just that the 1.2 download has an example of it, and the earlier download doesn't. I'd suggest downloading the 1.2 Struts just so you can get the example.