aspose file tools*
The moose likes Servlets and the fly likes Combine 2 content types in a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Combine 2 content types in a servlet" Watch "Combine 2 content types in a servlet" New topic
Author

Combine 2 content types in a servlet

Pavlos Chatzidimitriou
Greenhorn

Joined: Aug 18, 2008
Posts: 10
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

Joined: Jan 28, 2003
Posts: 4181
    
  21

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.


Steve
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Combine 2 content types in a servlet