tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kenneth topp <>
Subject Re: Servlet context and returned files
Date Mon, 09 Oct 2000 16:32:19 GMT

This is a browser/w3c issue.  There is no method to provide naming hints
on downloaded files at all.  The browser uses what it wants from the url,
and it's behavior is more observed, rather then defined :(

But, there is a solution, I'd recommend doing a URI mapping like:

/myservlet/* -> myServlet.  (this is standard web.xml fare)

And have your servlet instead of getParameter("name") use
  getRequestUri().substring("/myserlvet/".length(), getRequestUri().length() )

The url's will now be:


That way, the browser will use the filename, MyFile.pdf, and that's what
you want, no?

Kenneth Topp

On Mon, 9 Oct 2000, Drew Kidder wrote:

> >I posted this a while back, but haven't seen a response, so I thought I'd 
> >try posting again.  Here's the deal:
> >
> >I have a servlet, say "MyServlet", that I'm using to do various 
> >things.  One of those things is managing file transfer and bandwidth 
> >throttling. The user is presented with several links which represent files 
> >that live in the /usr/apache/htdocs directory.  The actual anchor is 
> >"" or something like 
> >that.  The user clicks the link, the servlet strips off the 'name' 
> >argument, and then goes to get the file and downloads it with a server 
> >output stream.
> >
> >Anyhoo...
> >
> >What happens is that when I click the link, it returns the file - but 
> >instead of having the correct filename of "MyFile.pdf", it has the name 
> >"MyServlet.pdf". It doesn't matter what file I click, I'll always get a 
> >filename of "MyServlet" with the proper extension appended on at the end. 
> >The file downloads correctly and such, but is named improperly.
> >
> >Is this an issue with the servlet container? Is something not correct in 
> >my setup? How can I keep the name from changing to the name of the 
> >servlet?  This is a rather frustrating bug, and I'm not really sure where 
> >to start looking.
> >
> >Thank you.
> ------
> Andrew Kidder
> L3 SW/Support Engineer, IBU
> Tivoli Systems
> 512-436-4544

View raw message