[opencms-dev] How to include results of a webservice call into a JSP that generates an opencms 8.0.0 page?

Jens-U. Mozdzen jmozdzen at mozdzen.de
Mon Jul 23 09:56:28 CEST 2012


Hi Enrico,

> Date: Fri, 20 Jul 2012 09:44:38 +0000
> From: Enrico Ballarin Dolfin <enrico at sed.ethz.ch>
> To: The OpenCms mailing list <opencms-dev at opencms.org>
> Subject: [opencms-dev] How to include results of a webservice call
> 	into a	JSP that generates an opencms 8.0.0 page?
> Message-ID: <201207200944.39072.enrico at sed.ethz.ch>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi,
>
> I'm looking for a way to include results of a webservice call into a JSP that
> generates an OpenCms 8.0.0 page.
> [...]

The result of such calls are typically returned to the browser, not to  
the Tomcat server (Opencms):

> The webservice calls can returns a PNG image, a text, an XML file, etc, that
> is stored in a DB table as blob field.
> [...]
> While this approach works well for PNG images, e.g.
>
> <p><img src="/MyServices/GetPngBlob?param2=<%= value %>" /></p>

The image data is requested by and returned returned to the browser  
that can immediately display the PNG.

> I'm having problems to use the GetTextBlob and the GetXmlBlob service:
> I need to call the service and to store the result of the service call in a
> JSP variable (e.g. String data) and then to display it in HTML:
>
> <p><%= data %></p>

If you actually only need to display the content in the web page  
without (much) further processing (and want to stick with the  
webservices call, see below), why not include it via an AJAX call?  
(Give a unique id to the p tag and create an "on success" callback for  
the ajax call that sets innerHTML to the value returned.)

> The JSP that I use to generate the page has a structure like this and uses a
> bean that I have programmed in Java to be able to access an other DB:
> [...]
> Any idea how can I perform the webservice call inside my JSP ?

Does it have to be a webservice call at all? If you've implemented the  
webservice call inside the same Opencms instance (or at least the same  
Tomcat), why are you wrapping access to the data in another web call  
at all? You might as well do similar steps inside the JSP where you'd  
like to have the results available (ie making direct Java calls to the  
DB). Then you'd have the resulting data on the Opencms side and can  
process it any way you like, inside the JSP.

Regards,
Jens




More information about the opencms-dev mailing list