Originally posted by Ben Hagadorn:
1) how to specify the file path for where the uploaded files are saved. I currently derive this by using servletContext.getRealPath("UploadedFiles") but that won't give me what I need for a location outside my deployment.
Since you're no longer saving the files inside the web context, it doesn't really matter where you put them. You will now have to specify a path based on the server's operating system file structure. Just pick a directory and make sure that the directory has public read/write authority.
It's probably not a good idea to hard-code the path, though. I'd suggest specifying it as a context parameter in your web.xml file, and then reading the context parameter in your application code.
Originally posted by Ben Hagadorn:
2) how to derive a valid URL for the links I display on my JSP pages. I currently use "/MyAPP/UploadedFiles/<the file>".
Because the file is no longer in the web context, you can't get to the file directly from a URL any more. You will have to create an Action class that will read the file from the server's file system and then output it to the HTTPServletResponse object's output stream.
So, your new URL will be something like "MyApp/DownloadAction.do?file=<thefile>"
Struts has a
DownloadAction class that you can extend. This class does almost all the work of downloading the file. All you have to do is override its
getStreamInfo method to tell it where to find the file and what its content type is.