I have a WebService that returns a PDF URL. The problem is that the CMS is terrible, flakey, and that document may not even exist. (or there may not be a network connection to the CMS server)
I am using Spring 3.2 MVC and my controller is simple enough:
modelAndView.addObject("documentURL", service.getCmswsGetDocumentUrl());
and the view:
<object data="${documentURL}" width="600" height="800" type='application/pdf' >
This all works fine if the document exists.
However, I want to be able to do, say a javascript alert() or something if the document is not there.
Is there a way to embed the pdf in the modelAndView like
modleAndVIew.addObject("pdf",file);
Or some way that I can add the data to the html object through jQuery?
I just don't want to make 2 calls, one to retrieve the document to see if I can, then one to actually retrieve the document in the html object tag.
Any ideas?
Adendum Edit:
Can I do something like this?: Is it possible to put binary image data into html markup and then get the image displayed as usual in any browser?
where I base64 encode the PDF in the controller and pass that to the view?