• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Combine 2 content types in a servlet

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all i start learning servlets now and i have a question about how can in one servlet send an html page and a file such as a photo in the response.I have this servlet :

It runs but i get only the html page without downloading the file.Now i wonder if i have to make a second servlet for the file but then how can i do this.Any suggestions?
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't send two different content types over a single response. You will need two response, which means you will need two different requests (as responses can only be sent after a request was made).

The easiest way is probably to have the HTML page you send trigger the second response, either using javascript or an internal frame (iframe) to send a request to a second servlet that then initiates the download.
 
reply
    Bookmark Topic Watch Topic
  • New Topic