Topic
2 replies Latest Post - ‏2013-05-24T20:08:10Z by Josh_Winwood
S9F7_Veronica_Viera
S9F7_Veronica_Viera
2 Posts
ACCEPTED ANSWER

Pinned topic Fetch data from one server and use it in another

‏2013-04-23T00:31:52Z |

 

Hi there!
 
Im kind of newbie on HATS, and i am needing a hand.
 
I wanted to know how can i get a variable from another server so that i can use it in the HATS server. I don't want the data to be readable from the url, and im not sure if i should use GET, POST, cookies or a mix of all of them.
 
The procedure should be something like:
 
1 - The user reach the authentication page (authentication server)
2 - I process the data the user put, and with them i get a new data i save in a variable
3 - Then, that variable is the one i need to use in HATS
 
I know this can be a bit simple for someone that is involved in HATS programming, but as i sad im still learing and any help would be very appreciated.
 
Thank you!
  • tmparker
    tmparker
    484 Posts
    ACCEPTED ANSWER

    Re: Fetch data from one server and use it in another

    ‏2013-04-25T17:25:58Z  in response to S9F7_Veronica_Viera

    If this initial data is coming from a non-HATS web application you could try storing the value in a HTTP session variable.  If you are then going directly into the HATS application in that browser session you should be able to read the session variables using business logic and store the value in a HATS global variable for use whenever you want in your HATS app.

  • Josh_Winwood
    Josh_Winwood
    11 Posts
    ACCEPTED ANSWER

    Re: Fetch data from one server and use it in another

    ‏2013-05-24T20:08:10Z  in response to S9F7_Veronica_Viera

    Veronica,

    I accomplish this by using the following html code to set a global variable from my initial servlet .java file (note: variable name must start with hatsgv_ prefix):

    <input type="hidden" name="hatsgv_variableName" value="whatever"> 

    Then I direct them to the hats server/application they want.  (note that you must enable global variable overrides on the other tab in project settings for at least the variable you wish to set here).

    Within the .jsp of the HATS transformation, to obtain data from the variable, I use the following code:

    IGlobalVariable gvVariableName     = ((TransformInfo)request.getAttribute(CommonConstants.REQ_TRANSFORMINFO)).getGlobalVariable("variableName");

     

    Then you can do stuff like:

    if (gvVariableName != null) {
        String somethingElse = gvVariableName.getString(0);
    }

    and:

    if (something happens){
       gvVariableName.set("some value");
    }

     

    For more information see:
    http://publib.boulder.ibm.com/infocenter/hatshelp/v75/index.jsp?topic=/com.ibm.hats.doc/doc/ugprject.htm
    (
    search for "hatsgv_") to jump to global variable override section

    Updated on 2013-05-24T20:09:04Z at 2013-05-24T20:09:04Z by Josh_Winwood