GeeCON Prague 2014*
The moose likes Web Services and the fly likes how to open attachments Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Web Services
Bookmark "how to open attachments" Watch "how to open attachments" New topic
Author

how to open attachments

Michael Hul
Greenhorn

Joined: Oct 21, 2008
Posts: 12
Im not sure exactly where this question belongs so I'll just post it here since it's related to the webservices I'm working on.

I have a service that when invoked returns the response with a pdf as an attachment. This is all initiated from a jsp page. A user clicks a button which then submits the form and then i have a scriptlet call a java class where the webservice is consumed. This returns the response and displays it in the jsp. Now, i also have a second button titled 'Display PDF' that when clicked I need to have display the pdf attachment in another window. How the heck do I go about that??
Nishant Modak
Greenhorn

Joined: Sep 29, 2006
Posts: 27
Assumption: The service-reply has the attachment as 'SOAP attachment'.

1. Without the need for the Display PDF button.
---> The service response that you get can be handled with *coding* Handlers in the client side, where you can process the returned pdf attachment and then display it directly in the browser.

2. With the Display PDF button.
---> You still code the client handler for handling the service-reply with attachment then store it locally. And when the Display pdf is clicked in the same session. Display the pdf (open the pdf) in the browser.

I hope this helps. Let the forum know, how you achieved this.
Michael Hul
Greenhorn

Joined: Oct 21, 2008
Posts: 12
Sorry I should have posted earlier, but I did something like your 2nd suggestion. Since I invoked the webservice using the following I get the attachment (if it exists) using the following Then I convert the attachment to a byte array and store it in a static class variable in a separate class so that when the 'Display PDF' button is clicked, it loads a servlet that can access the attachment using a call similar to the following then I display it using That seems to work fine. Thanks for the reply
[ November 11, 2008: Message edited by: Michael Hul ]
 
GeeCON Prague 2014
 
subject: how to open attachments