Typically, directories web applications or sub-directories of same.
Looks like you're using the ROOT Context, which means "downloaddir"
would be a sub-directory of that.
I think what you are probably looking for is:
http://localhost/myservlet?filename=abc.txt
Then, in your servlet, read the file from the location and spool it out
to the browser.
Something along the lines of:
// send file to browser
java.io.OutputStream o = response.getOutputStream();
java.io.FileInputStream is = new java.io.FileInputStream(filePath + "/"
+ fileName);
java.io.File oFile = new java.io.File(filePath + "/" + fileName);
response.setContentType("image/gif"); // or whatever MIME type you want
response.setContentLength((int)oFile.length());
byte[] buf = new byte[32 * 1024]; // 32k buffer
int nRead = 0;
while( (nRead=is.read(buf)) != -1 ) {
o.write(buf, 0, nRead);
}
o.flush();
o.close();
oFile = null;
// end
John
Robert Priest wrote:
How do I create a virtual directory under tomcat? For instance
/DownloadDir/ -> maps to -> c:\temp\downloads\
In a url a user would enter something like:
http://localhost/myservlet/downloaddir/abc.txtto access the files in
c:\temp\downloads
I wouldn't use a context for that, would I? Doesn't a Context represent a
"Web Application", not just a directory?
Anyone have any information on setting one up?
Thank you in advance...
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]