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.
Session expired when using Embedded/ExternalResource
I have a external webpage, where at startup automatically downloads a document depending on the url-parameters, like:
http:// .... //url-action?action=show_pdf&id=2000000008602&auto-login=josc110
In my vaadin application i want to have a button which just downloads a document, while opening the URL like shown above.
My idea was to add a button which adds a non visible Embedded component after the button was pressed in order to download the desired document, like:
Button viewButton = new Button("Show document");
viewButton.setStyleName(BaseTheme.BUTTON_LINK);
addComponent(viewButton);
viewButton.addListener(new Button.ClickListener() {
@Override
public void buttonClick(final ClickEvent event) {
Embedded downloader = new Embedded();
downloader.setType(Embedded.TYPE_BROWSER);
downloader.setWidth("0px");
downloader.setHeight("0px");
ExternalResource ex = new ExternalResource("http:/.../url-action?action=show_pdf&id=2000000008602&auto-login=josc110");
downloader.setSource(ex);
addComponent(downloader);
}
Problem:
After the button is pressed, the document is downloading well. But when i want to continue using my vaadin application its session expired already.
Sounds like something weird as Session cookie gets overridden due to the autologin-parameter or the like. Just a guess, might be completely unrelated to your actual problem ;) ...
I cannot reproduce the reported behavior. So I'm still convinced that it must be a problem with the resource you are loading. You could try to trace the network-communication via Firebug / Whistler / Wireshark and check if there are any session-cookies set. Other path towards the problem might be to create a simple PHP-testapp that includes the same resource in an iframe and check if it is loosing the session also. Maybe you should check first, if the problem remains, if you load some other resource instead, for example a static PDF or an image. Don't know all your code / setup and especially don't know the resource you are actually loading, so it's a bit difficult to find out what the problem is ...
How about of using window.open() instead of hidden embedded hack? That's not what Embedded is meant for so there might be unknown consequences, like this. Here's the API.