Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Combine 2 content types in a servlet  RSS feed

 
Pavlos Chatzidimitriou
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • 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?
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!