Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Setting an HTTP Response Header

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] Setting an HTTP Response Header
 Login/Join
 
Member
posted
Is there any way to set an HTTP response header or custom response header? Something like ASP's Response.AddHeader? Thanks, Steve

p.s. I'm using AJAX async request to WebFocus to update parts of a web page and need to return status/error codes to browser javascript. I have success using a hidden div to receive a value from WebFocus, interpret it as a status code, then act on it. It's not generalized or elegant. It would be much easier if the status was in a custom header. In AJAX I could just read the header directly.

This message has been edited. Last edited by: Kerry,
 
Posts: 14 | Location: Texas | Registered: May 16, 2006Report This Post
Expert
posted Hide Post
What about returning an XML document.

You could return the data or if it fails, then return a status.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Platinum Member
posted Hide Post
The only way I know to set an HTTP Response header from WebFOCUS would be with a Java Servlet filter.

Now, you do get response codes when using Web Services, which you can call from ASP.

You might also be able to use an AJAX request to call the procedure, check status, then load the frame with it.


WF 71.x, 76.x, 7701, 8.0 Beta OS: Linux, Win2k3, Win2k, Win2k8, WinXP


 
Posts: 203 | Registered: November 19, 2007Report This Post
Member
posted Hide Post
Waz, dlogan, thanks for your reply's.

Waz, I looked at XML. It seems a bit overkill compared to what I am doing now. I would need to write many lines just to create an XML document in the focexec, then parse it in the browser. Even with JQuery, it's not trivial. XML is doable, but fits better for complex data and status parsing. You can see in my example below I only need one line in my focexec to pass status back to the web page and five lines in the javascript to deal with it.

dlogan, ajax uses the web service response code to know if the http request was successful or not and is outside of my control. Focus always returns a 200 regardless of errors in my focexec processing. I'm looking for something I can control from within a focexec, so the Java Servlet filter is also out of scope.

Here is an example:

I have a page with a checkbox used to control an enable flag in the database. When the user clicks the checkbox, I don't need or want to update the whole page. The web page tags are like this:

<input type=checkbox id=eflg onChange=toggle_eflg[);>
<div id=rtnstatus style="display:none"></div>


The javascript function is [in JQuery]:

function toggle_eflg()
{
   jQuery.ajax({
      type: "POST",
      url: "/ibi_apps/WFServlet",
      data: "IBIF_ex=DBAPP&WHERETO=TOGEFLG&EFLGCHKED="+jQuery('#eflg').is(':checked'),
      success: function(data) {
         jQuery('#rtnstatus').html(data);
         statusresult = parseInt(jQuery('#rtnstatusresult').val());
         if(statusresult != 1)
            alert('error');
            jQuery('#eflg').attr('checked',false);
      }
   });
}


And the focexec is:

-TOGEFLG
MODIFY FILE DB
FREEFORM S1 EFLG
MATCH S1
ON NOMATCH REJECT
ON MATCH UPDATE EFLG
DATA
'KEY','&EFLGCHKED',$
END
-HTMLFORM BEGIN
<input type=hidden id=rtnstatusresult value="!IBI.AMP.CHNGD;">
-HTMLFORM END
-EXIT


I would like to be able to just set a custom header with the number of records updated in the focexec. That should take one line only. I would suggest something like:

-SET &RC = HTTPADDHEADER('X-RtnStatResult',&CHNGD);


or maybe better,

-HTMLFORM ADDHEADER
X-RtnStatResult: !IBI.AMP.CHNGD;
-HTMLFORM END


Then on the web page I wouldn't need the hidden div, or jQuery lines to load the return status into the hidden div and convert to integer. I could just test the header directly and branch as needed.

Being able to write headers would let me write simpler code and pages, and could be used for other purposes, like writing cookies, etc. By the way, I think I would prefer the -HTMLFORM style and will probably start the process of asking IBI to implement this.

Thanks for any input on how this might be accomplished better,

Steve

This message has been edited. Last edited by: Steve F,
 
Posts: 14 | Location: Texas | Registered: May 16, 2006Report This Post
<FreSte>
posted
Can't you use an hidden IFRAME for your update-fex and
end the update-fex with something like this:

...
-HTMLFORM BEGIN
<html>
<script>
parent.document.getElementById("eflg").checked = {true,false};
</script>
</html>
-HTMLFORM END


Just a thought ...
 
Report This Post
Member
posted Hide Post
FreSte,

That actually worked. I remember a time when iFrames were prohibited from running script, or was it ajax inserted javascript was prohibited by security policy?

In any case, I'm not sure this is better than what I'm using now, or what benefit it provides that my example doesn't. I used a checkbox as the example, but I have similar error handling on every async updater; input fields, checkboxs, action buttons that add/delete application objects. In every case, I have to be careful of concurrent actions and make sure I use a different tag (or iframe as the case would be) for each request in order to insure the second request doesn't overwrite the return values from the first request. I may take another look at xml parsing the return data directly.

It would just be so much easier to set a header, check it on return and let the data be data.

Steve
 
Posts: 14 | Location: Texas | Registered: May 16, 2006Report This Post
Expert
posted Hide Post
Keep in mind, that browsers security will allow script calls between frames on the same domain.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Setting an HTTP Response Header

Copyright © 1996-2020 Information Builders