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

Enrico Ballarin Dolfin enrico at sed.ethz.ch
Mon Jul 23 10:57:03 CEST 2012


Hi Jens,

On Monday 23 July 2012 07:56:28 Jens-U. Mozdzen wrote:
> 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.)

thanks for your suggestion, I'll give a look at this possibility.

> 
> > 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.

At the beginning I was following this approach, getting the content of the 
blob field in the String variable 'data' using my Java bean in JSP.

I could then display in the webpage the content of the 'data' variable if it 
was of type text, but in the case that is was of type PNG or XML I got only an 
hex string displayed, like this:

\x3c3f786d6c2076657273696f6e3d22312e302220656...

For this reason I implemented the webservices, but also because there will be 
other programs as the opencms application, needing to access the blob fields.

Now the webservice is implemented, as needed for other applications.
I could use it in the opencms application, but I could also try an opencms 
only solution, if I could find a way to display the PNG and XML content of the 
String 'data' variable...

Regards,
Enrico

> 
> Regards,
> Jens
> 
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev



More information about the opencms-dev mailing list