Focal Point
[SOLVED] Call Servlet from Fex file

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/4417098416

December 30, 2011, 09:02 AM
berkh1dj
[SOLVED] Call Servlet from Fex file
How would I call a custom servlet from a fex procedure?

This message has been edited. Last edited by: Kerry,


WebFOCUS 7.6
Windows, All Outputs
January 04, 2012, 03:15 AM
<JG>
in it's very simplest form

 
-HTMLFORM BEGIN
<html>
  <head>
  </head>
   <body onLoad="window.location.href='http://www.ibi.com'">
   </body>
</html>
-HTMLFORM END
 


The href can be anything you want and can be a variable substituted at run time.
January 10, 2012, 03:06 PM
berkh1dj
This will work. However, I will need to store the
<host>
and
<port>  
properties of the URL in an environment specific properties file and call those properties in the HTMLFORM fex.

 <body onLoad="window.location.href='http://<host>:<port>/servlet'">
  


How would I do this?

This message has been edited. Last edited by: berkh1dj,


WebFOCUS 7.6
Windows, All Outputs
January 11, 2012, 02:47 AM
<FreSte>
Create a file with the environment specific properties:
(this file could be database driven [iow. generated dynamically by a fex] )

-* --- hostinfo.fex
-SET &HOST = 'http://www.ibi.com';
-SET &PORT = ':80';


... and then call this in your HTML-form like this:

-INCLUDE hostinfo
-RUN
 
-HTMLFORM BEGIN
<html>
  <head>
  </head>
   <body onload="window.location.href='!IBI.AMP.HOST;!IBI.AMP.PORT;'">
   </body>
</html>
-HTMLFORM END

January 11, 2012, 08:30 AM
berkh1dj
That's what I needed. Thanks!


WebFOCUS 7.6
Windows, All Outputs
January 16, 2012, 03:32 PM
berkh1dj
How would I pass parameters from the fex file to the servlet using the method described above?

This does not seem to work:
 

-SET &HOST = 'http://www.ibi.com';
-SET &PORT = ':80';
-SET &PARAM1 = 'x';
-SET &PARAM2 = 'y';

<body onLoad="window.location.href='!IBI.AMP.HOST;!IBI.AMP.PORT;/servlet?param1=!IBI.AMP.PARAM1;¶m2=!IBI.AMP.PARAM2;'">



Please let me know what I am doing wrong.

Thanks!


WebFOCUS 7.6
Windows, All Outputs
January 17, 2012, 03:49 PM
<FreSte>
Hi,

I think my previous answer put you on the wrong track; there was a little error in it.

The line
... and then call this in your HTML-form like this:


should be

... and then call this in your FEX like this:



So, you example should look like this (assuming it's all in 1 FEX):

-SET &HOST = 'http://www.ibi.com';
-SET &PORT = ':80';
-SET &PARAM1 = 'x';
-SET &PARAM2 = 'y';

-HTMLFORM BEGIN
<html>
<body onLoad="window.location.href='!IBI.AMP.HOST;!IBI.AMP.PORT;/servlet?param1=!IBI.AMP.PARAM1&|param2=!IBI.AMP.PARAM2;'">
...
</body>
</html>
-HTMLFORM END


Note the &|param2 in the <body ... line. If you would not use the pipe-sign ( =| ), WebFOCUS 'thinks' that &param2 is a defined variable within
this FEX which isn't.

Hope this helps,

-Fred-

This message has been edited. Last edited by: <FreSte>,