Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Downloading a jpeg image in new window

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm trying to open different types of Attachments. All The attachments are opening with their respective applications In new window.

E.g .doc in MSWord.

Whereas coming to JPEG, gif files. These are opening in the same window . I need to open them in new window.
I placed this code also :

response.setHeader("Content-Disposition","attachment;fileName=".concat(String.valueOf(destFileName)));

BufferedInputStream bis = new BufferedInputStream(blobStream);
response.setContentLength((int)blob.length());
int aByte = 0;
while ((aByte = bis.read()) != -1) {
response.getOutputStream().write(aByte);
}
bis.close();
response.flushBuffer();
Please help me.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the servlet side you can't force the browser to open a new window. That has to be done on the browser side with HTML or JavaScript.
Bill
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic