Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
FileResource Label (file download) and SSL
Hi,
I have following file download label inside a view:
FileResource fileRes = new FileResource(file, getApplication());
Link lnkFile = new Link(fileRes.getFilename(), fileRes);
viewLayout.addComponent(lnkFile);
My Web application runs on glassfish 3.1. Without SSL (Port 8080) the file download link works on all browsers fine (Firefox, IE7/8/9). But if I use a SSL connection (Port 8181) I cannot download the file on IE7 and IE8. The error message is:
File.dat von 127.0.0.1 kann nicht runtergeladen werden.
Die Internetsite konnte nicht geöffnet werden. Sie ist entweder nicht verfügbar oder konnte nicht gefunden werden. Versuchen Sie es später erneut.
Translated from german to english:
File.data cannot be downloaded from 127.0.0.1.
The internet site could not be open. The site is not available or could not be found. Please try it again later.
On Firefox and IE9 it works also fine with SSL.
Is this is a configuration problem? Is there any trick to download a file with SSL on IE7/8 with a resource link?
Thanks and regards,
Steffen
YES! That's it!
After setting the cache time to 1ms in FileResource it works.
/** {@inheritDoc}
*/
@Override
public DownloadStream getStream() {
DownloadStream dStream = super.getStream();
dStream.setParameter("Content-Disposition", "attachment; filename=\"" + getFilename() + "\"");
dStream.setContentType("application/unknown");
dStream.setCacheTime(1); // <<<<<<<<< This is the workaround!!!! :-)
informNewStream();
return dStream;
}
Many thanks and regards,
Steffen
EDIT:
Note that its also important to override the FileResource.getCacheTime() method:
/** {@inheritDoc}
*/
@Override
public long getCacheTime() {
return 1;
}