in reply to Doubt about Template Toolkit

What seems to be the trouble?

Your code seems to be generating a complete HTML document which I guess you are sending to a browser. The second iteration of the loop will send the same complete HTML document as will subsequent iterations.

When the browser receives the HTML document it will process it. From memory, the HTML spec is that everything after the closing </html> should be ignored. This means all of your code's output after the first iteration of your loop. So this could be one reason why your code appears not to get past the first time around the loop.

Also, bear in mind that one of the first things you are telling the browser to do is go off somewhere else! It will obey this instruction pretty quickly after it gets the <meta http-equiv="refresh"> command. Once it goes off somewhere else, it won't be loading in anything else you send to it.

It strikes me that you want to approach this problem in a different manner...

Replies are listed 'Best First'.
Re^2: Doubt about Template Toolkit
by Anonymous Monk on Jul 15, 2022 at 23:52 UTC

    Hi Bod, thanks for your observations. In fact, I am doing what you states: Using window.open, but now below url is not processed. It looks like a weird characters avoid window.open process the URL, but I do not what those are. I compare formed url with a url generated with a public place to do it. (http://www.blooberry.com/indexdot/html/topics/urlencoding.htm) Using previous page I converted below url (No encoding)

    NO ENCODING https://localhost:8080/ibm/console/webtop/AELView?sql=((TMX_NodeName ! += '' and TMX_NodeName = 'CTJAXM7300W' and PhysicalSlot = 1 and Physic +alPort= 3) or (TMX_NodeName != '' and TMX_NodeName= 'CTJAXM7300W' and + PhysicalPort = 0)) or (TMX_NodeName != '' and TMX_NodeName = 'CTJAXM +7300W' and PhysicalSlot = 1 and PhysicalPort = 1) or ((TMX_NodeName ! += '' and TMX_NodeName = 'TTTNXMCL05W' and PhysicalSlot = 01 and Physi +calPort = 9) or (TMX_NodeName != '' and TMX_NodeName= 'TTTNXMCL05W' +and PhysicalPort = 0)) or ((TMX_NodeName != '' and TMX_NodeName = 'TT +TNXMCL05W' and PhysicalSlot = 17 and PhysicalPort = 1) or (TMX_NodeNa +me != '' and TMX_NodeName = 'TTTNXMCL05W' and PhysicalSlot = 0 and Ph +ysicalPort = 0)) or ((TMX_NodeName != '' and TMX_NodeName = 'TTTNXMCL +O01-AGR3-06' and PhysicalSlot = 03 and PhysicalPort = 7 ) or (TMX_No +deName != '' and TMX_NodeName = 'TTTNXMCLO01-AGR3-06' and PhysicalSl +ot = 0 and PhysicalPort = 0 AND (AlertGroup IN ('ReachabilityProblem' +, 'component unreachable','ER CEth Inalcanzable') OR AlertGroup LIKE + '[Pp]ower')) ) or (TMX_NodeName = 'TTTNXMCLO01-AGR3-06' and Physical +Slot = 03 and PhysicalPort = 0) or (TMX_NodeName = 'TTTNXMCLO01-AGR3- +06' and PhysicalSlot = 0 and PhysicalPort = 0) or (TMX_NodeName != '' + and TMX_NodeName = 'TTTNXMCLO01-AGR3-06' AND PhysicalSlot = 0 and Ph +ysicalPort = 0 AND (AlertGroup IN ('ReachabilityProblem', 'component +unreachable','ER CEth Inalcanzable') OR AlertGroup LIKE '[Pp]ower')) + or ((TMX_NodeName != '' and TMX_NodeName = 'CTLNXMCUO10-DIST1-09' a +nd PhysicalSlot = 01 and PhysicalPort = 17 ) or (TMX_NodeName != '' a +nd TMX_NodeName = 'CTLNXMCUO10-DIST1-09' and PhysicalSlot = 09 and P +hysicalPort = 2 ) ) or (TMX_NodeName = 'CTLNXMCUO10-DIST1-09' and Phy +sicalSlot = 01 and PhysicalPort = 0) or (TMX_NodeName = 'CTLNXMCUO10- +DIST1-09' and PhysicalSlot = 09 and PhysicalPort = 0) or (TMX_NodeNam +e != '' and TMX_NodeName = 'CTLNXMCUO10-DIST1-09' AND PhysicalSlot = +0 and PhysicalPort = 0 AND (AlertGroup IN ('ReachabilityProblem', 'co +mponent unreachable','ER CEth Inalcanzable') OR AlertGroup LIKE '[Pp +]ower')) or ((TMX_NodeName != '' and TMX_NodeName = 'CTLNXMCU10W' and + PhysicalSlot = 0 and PhysicalPort = 1) or (TMX_NodeName != '' and TM +X_NodeName = 'CTLNXMCU10W' and PhysicalSlot = 0 and PhysicalPort = 2) + or (TMX_NodeName != '' and TMX_NodeName = 'CTLNXMCU10W' and Physical +Slot = 0 and PhysicalPort = 5) or (TMX_NodeName != '' and TMX_NodeNam +e = 'CTLNXMCU10W' and PhysicalPort = 0))&transientname=C02-2003-0263& +viewname=Default_TMX&viewtype=system&datasource=NCOMS,NCOMS2

    My code generates same URL-Safe Encoding but when I process with window.open does not show anything.

    URL-SAFE ENCODING https://localhost:8080/ibm/console/webtop/AELView?sql=((TMX_NodeName%2 +0!=%20''%20and%20TMX_NodeName%20=%20'CTJAXM7300W'%20and%20PhysicalSlo +t%20=%201%20and%20PhysicalPort=%203)%20or%20(TMX_NodeName%20!=%20''%2 +0and%20TMX_NodeName=%20'CTJAXM7300W'%20and%20PhysicalPort%20=%200))%2 +0or%20(TMX_NodeName%20!=%20''%20and%20TMX_NodeName%20=%20'CTJAXM7300W +'%20and%20PhysicalSlot%20=%201%20and%20PhysicalPort%20=%201)%20or%20( +(TMX_NodeName%20!=%20''%20and%20TMX_NodeName%20=%20'TTTNXMCL05W'%20an +d%20PhysicalSlot%20=%2001%20and%20PhysicalPort%20=%209)%20%20or%20(TM +X_NodeName%20!=%20''%20and%20TMX_NodeName=%20'TTTNXMCL05W'%20and%20Ph +ysicalPort%20=%200))%20or%20((TMX_NodeName%20!=%20''%20and%20TMX_Node +Name%20=%20'TTTNXMCL05W'%20and%20PhysicalSlot%20=%2017%20and%20Physic +alPort%20=%201)%20or%20(TMX_NodeName%20!=%20''%20and%20TMX_NodeName%2 +0=%20'TTTNXMCL05W'%20and%20PhysicalSlot%20=%200%20and%20PhysicalPort% +20=%200))%20or%20((TMX_NodeName%20!=%20''%20and%20TMX_NodeName%20=%20 +'TTTNXMCLO01-AGR3-06'%20%20and%20PhysicalSlot%20=%2003%20and%20Physic +alPort%20=%207%20)%20or%20(TMX_NodeName%20!=%20''%20and%20TMX_NodeNam +e%20=%20'TTTNXMCLO01-AGR3-06'%20%20and%20PhysicalSlot%20=%200%20and%2 +0PhysicalPort%20=%200%20AND%20(AlertGroup%20IN%20('ReachabilityProble +m'%2C%20'component%20unreachable'%2C'ER%20CEth%20Inalcanzable')%20OR% +20AlertGroup%20%20LIKE%20'%5BPp%5Dower'))%20)%20or%20(TMX_NodeName%20 +=%20'TTTNXMCLO01-AGR3-06'%20and%20PhysicalSlot%20=%2003%20and%20Physi +calPort%20=%200)%20or%20(TMX_NodeName%20=%20'TTTNXMCLO01-AGR3-06'%20a +nd%20PhysicalSlot%20=%200%20and%20PhysicalPort%20=%200)%20or%20(TMX_N +odeName%20!=%20''%20and%20TMX_NodeName%20=%20'TTTNXMCLO01-AGR3-06'%20 +AND%20PhysicalSlot%20=%200%20and%20PhysicalPort%20=%200%20AND%20(Aler +tGroup%20IN%20('ReachabilityProblem'%2C%20'component%20unreachable'%2 +C'ER%20CEth%20Inalcanzable')%20OR%20AlertGroup%20%20LIKE%20'%5BPp%5Do +wer'))%20or%20((TMX_NodeName%20!=%20''%20and%20TMX_NodeName%20=%20'CT +LNXMCUO10-DIST1-09'%20%20and%20PhysicalSlot%20=%2001%20and%20Physical +Port%20=%2017%20)%20or%20(TMX_NodeName%20!=%20''%20and%20TMX_NodeName +%20=%20'CTLNXMCUO10-DIST1-09'%20%20and%20PhysicalSlot%20=%2009%20and% +20PhysicalPort%20=%202%20)%20)%20or%20(TMX_NodeName%20=%20'CTLNXMCUO1 +0-DIST1-09'%20and%20PhysicalSlot%20=%2001%20and%20PhysicalPort%20=%20 +0)%20or%20(TMX_NodeName%20=%20'CTLNXMCUO10-DIST1-09'%20and%20Physical +Slot%20=%2009%20and%20PhysicalPort%20=%200)%20or%20(TMX_NodeName%20!= +%20''%20and%20TMX_NodeName%20=%20'CTLNXMCUO10-DIST1-09'%20AND%20Physi +calSlot%20=%200%20and%20PhysicalPort%20=%200%20AND%20(AlertGroup%20IN +%20('ReachabilityProblem'%2C%20'component%20unreachable'%2C'ER%20CEth +%20Inalcanzable')%20OR%20AlertGroup%20%20LIKE%20'%5BPp%5Dower'))%20or +%20((TMX_NodeName%20!=%20''%20and%20TMX_NodeName%20=%20'CTLNXMCU10W'% +20and%20PhysicalSlot%20=%200%20and%20PhysicalPort%20=%201)%20or%20(TM +X_NodeName%20!=%20''%20and%20TMX_NodeName%20=%20'CTLNXMCU10W'%20and%2 +0PhysicalSlot%20=%200%20and%20PhysicalPort%20=%202)%20or%20(TMX_NodeN +ame%20!=%20''%20and%20TMX_NodeName%20=%20'CTLNXMCU10W'%20and%20Physic +alSlot%20=%200%20and%20PhysicalPort%20=%205)%20or%20(TMX_NodeName%20! +=%20''%20and%20TMX_NodeName%20=%20'CTLNXMCU10W'%20and%20PhysicalPort% +20=%200))&transientname=C02-2003-0263&viewname=Default_TMX&viewtype=s +ystem&datasource=NCOMS%2CNCOMS2

    It only works for short URL

    https://localhost:8080/ibm/console/webtop/AELView?sql=Serial%3C0&trans +ientname=C02-2003-0260_SINREFERENCIA&viewname=Default_TMX&viewtype=sy +stem&datasource=NCOMS%2CNCOMS2

    What can I do in order to get this solved? Or Who can I figure out what (is this character/are those characters) that it does not allow to process the URL?

      I am replying with my correct user and correcting some gramatical text errors. Hi Bod, thanks for your observations. In fact, I am doing what you stated: Using window.open, but now below url is not processed. It looks like weird characters avoid window.open command processes the URL, but I do not know what those are. I compare formed url with a url generated with a public place to do it. (http://www.blooberry.com/indexdot/html/topics/urlencoding.htm) Using previous page I converted below url (No encoding)

      https://localhost:8080/ibm/console/webtop/AELView?sql=((TMX_NodeName ! += '' and TMX_NodeName = 'CTJAXM7300W' and PhysicalSlot = 1 and Physic +alPort= 3) or (TMX_NodeName != '' and TMX_NodeName= 'CTJAXM7300W' and + PhysicalPort = 0)) or (TMX_NodeName != '' and TMX_NodeName = 'CTJAXM +7300W' and PhysicalSlot = 1 and PhysicalPort = 1) or ((TMX_NodeName ! += '' and TMX_NodeName = 'TTTNXMCL05W' and PhysicalSlot = 01 and Physi +calPort = 9) or (TMX_NodeName != '' and TMX_NodeName= 'TTTNXMCL05W' +and PhysicalPort = 0)) or ((TMX_NodeName != '' and TMX_NodeName = 'TT +TNXMCL05W' and PhysicalSlot = 17 and PhysicalPort = 1) or (TMX_NodeNa +me != '' and TMX_NodeName = 'TTTNXMCL05W' and PhysicalSlot = 0 and Ph +ysicalPort = 0)) or ((TMX_NodeName != '' and TMX_NodeName = 'TTTNXMCL +O01-AGR3-06' and PhysicalSlot = 03 and PhysicalPort = 7 ) or (TMX_No +deName != '' and TMX_NodeName = 'TTTNXMCLO01-AGR3-06' and PhysicalSl +ot = 0 and PhysicalPort = 0 AND (AlertGroup IN ('ReachabilityProblem' +, 'component unreachable','ER CEth Inalcanzable') OR AlertGroup LIKE + '[Pp]ower')) ) or (TMX_NodeName = 'TTTNXMCLO01-AGR3-06' and Physical +Slot = 03 and PhysicalPort = 0) or (TMX_NodeName = 'TTTNXMCLO01-AGR3- +06' and PhysicalSlot = 0 and PhysicalPort = 0) or (TMX_NodeName != '' + and TMX_NodeName = 'TTTNXMCLO01-AGR3-06' AND PhysicalSlot = 0 and Ph +ysicalPort = 0 AND (AlertGroup IN ('ReachabilityProblem', 'component +unreachable','ER CEth Inalcanzable') OR AlertGroup LIKE '[Pp]ower')) + or ((TMX_NodeName != '' and TMX_NodeName = 'CTLNXMCUO10-DIST1-09' a +nd PhysicalSlot = 01 and PhysicalPort = 17 ) or (TMX_NodeName != '' a +nd TMX_NodeName = 'CTLNXMCUO10-DIST1-09' and PhysicalSlot = 09 and P +hysicalPort = 2 ) ) or (TMX_NodeName = 'CTLNXMCUO10-DIST1-09' and Phy +sicalSlot = 01 and PhysicalPort = 0) or (TMX_NodeName = 'CTLNXMCUO10- +DIST1-09' and PhysicalSlot = 09 and PhysicalPort = 0) or (TMX_NodeNam +e != '' and TMX_NodeName = 'CTLNXMCUO10-DIST1-09' AND PhysicalSlot = +0 and PhysicalPort = 0 AND (AlertGroup IN ('ReachabilityProblem', 'co +mponent unreachable','ER CEth Inalcanzable') OR AlertGroup LIKE '[Pp +]ower')) or ((TMX_NodeName != '' and TMX_NodeName = 'CTLNXMCU10W' and + PhysicalSlot = 0 and PhysicalPort = 1) or (TMX_NodeName != '' and TM +X_NodeName = 'CTLNXMCU10W' and PhysicalSlot = 0 and PhysicalPort = 2) + or (TMX_NodeName != '' and TMX_NodeName = 'CTLNXMCU10W' and Physical +Slot = 0 and PhysicalPort = 5) or (TMX_NodeName != '' and TMX_NodeNam +e = 'CTLNXMCU10W' and PhysicalPort = 0))&transientname=C02-2003-0263& +viewname=Default_TMX&viewtype=system&datasource=NCOMS,NCOMS2

      My code generates same URL-Safe Encoding but when I process with window.open does not show anything.

      https://localhost:8080/ibm/console/webtop/AELView?sql=((TMX_NodeName%2 +0!=%20''%20and%20TMX_NodeName%20=%20'CTJAXM7300W'%20and%20PhysicalSlo +t%20=%201%20and%20PhysicalPort=%203)%20or%20(TMX_NodeName%20!=%20''%2 +0and%20TMX_NodeName=%20'CTJAXM7300W'%20and%20PhysicalPort%20=%200))%2 +0or%20(TMX_NodeName%20!=%20''%20and%20TMX_NodeName%20=%20'CTJAXM7300W +'%20and%20PhysicalSlot%20=%201%20and%20PhysicalPort%20=%201)%20or%20( +(TMX_NodeName%20!=%20''%20and%20TMX_NodeName%20=%20'TTTNXMCL05W'%20an +d%20PhysicalSlot%20=%2001%20and%20PhysicalPort%20=%209)%20%20or%20(TM +X_NodeName%20!=%20''%20and%20TMX_NodeName=%20'TTTNXMCL05W'%20and%20Ph +ysicalPort%20=%200))%20or%20((TMX_NodeName%20!=%20''%20and%20TMX_Node +Name%20=%20'TTTNXMCL05W'%20and%20PhysicalSlot%20=%2017%20and%20Physic +alPort%20=%201)%20or%20(TMX_NodeName%20!=%20''%20and%20TMX_NodeName%2 +0=%20'TTTNXMCL05W'%20and%20PhysicalSlot%20=%200%20and%20PhysicalPort% +20=%200))%20or%20((TMX_NodeName%20!=%20''%20and%20TMX_NodeName%20=%20 +'TTTNXMCLO01-AGR3-06'%20%20and%20PhysicalSlot%20=%2003%20and%20Physic +alPort%20=%207%20)%20or%20(TMX_NodeName%20!=%20''%20and%20TMX_NodeNam +e%20=%20'TTTNXMCLO01-AGR3-06'%20%20and%20PhysicalSlot%20=%200%20and%2 +0PhysicalPort%20=%200%20AND%20(AlertGroup%20IN%20('ReachabilityProble +m'%2C%20'component%20unreachable'%2C'ER%20CEth%20Inalcanzable')%20OR% +20AlertGroup%20%20LIKE%20'%5BPp%5Dower'))%20)%20or%20(TMX_NodeName%20 +=%20'TTTNXMCLO01-AGR3-06'%20and%20PhysicalSlot%20=%2003%20and%20Physi +calPort%20=%200)%20or%20(TMX_NodeName%20=%20'TTTNXMCLO01-AGR3-06'%20a +nd%20PhysicalSlot%20=%200%20and%20PhysicalPort%20=%200)%20or%20(TMX_N +odeName%20!=%20''%20and%20TMX_NodeName%20=%20'TTTNXMCLO01-AGR3-06'%20 +AND%20PhysicalSlot%20=%200%20and%20PhysicalPort%20=%200%20AND%20(Aler +tGroup%20IN%20('ReachabilityProblem'%2C%20'component%20unreachable'%2 +C'ER%20CEth%20Inalcanzable')%20OR%20AlertGroup%20%20LIKE%20'%5BPp%5Do +wer'))%20or%20((TMX_NodeName%20!=%20''%20and%20TMX_NodeName%20=%20'CT +LNXMCUO10-DIST1-09'%20%20and%20PhysicalSlot%20=%2001%20and%20Physical +Port%20=%2017%20)%20or%20(TMX_NodeName%20!=%20''%20and%20TMX_NodeName +%20=%20'CTLNXMCUO10-DIST1-09'%20%20and%20PhysicalSlot%20=%2009%20and% +20PhysicalPort%20=%202%20)%20)%20or%20(TMX_NodeName%20=%20'CTLNXMCUO1 +0-DIST1-09'%20and%20PhysicalSlot%20=%2001%20and%20PhysicalPort%20=%20 +0)%20or%20(TMX_NodeName%20=%20'CTLNXMCUO10-DIST1-09'%20and%20Physical +Slot%20=%2009%20and%20PhysicalPort%20=%200)%20or%20(TMX_NodeName%20!= +%20''%20and%20TMX_NodeName%20=%20'CTLNXMCUO10-DIST1-09'%20AND%20Physi +calSlot%20=%200%20and%20PhysicalPort%20=%200%20AND%20(AlertGroup%20IN +%20('ReachabilityProblem'%2C%20'component%20unreachable'%2C'ER%20CEth +%20Inalcanzable')%20OR%20AlertGroup%20%20LIKE%20'%5BPp%5Dower'))%20or +%20((TMX_NodeName%20!=%20''%20and%20TMX_NodeName%20=%20'CTLNXMCU10W'% +20and%20PhysicalSlot%20=%200%20and%20PhysicalPort%20=%201)%20or%20(TM +X_NodeName%20!=%20''%20and%20TMX_NodeName%20=%20'CTLNXMCU10W'%20and%2 +0PhysicalSlot%20=%200%20and%20PhysicalPort%20=%202)%20or%20(TMX_NodeN +ame%20!=%20''%20and%20TMX_NodeName%20=%20'CTLNXMCU10W'%20and%20Physic +alSlot%20=%200%20and%20PhysicalPort%20=%205)%20or%20(TMX_NodeName%20! +=%20''%20and%20TMX_NodeName%20=%20'CTLNXMCU10W'%20and%20PhysicalPort% +20=%200))&transientname=C02-2003-0263&viewname=Default_TMX&viewtype=s +ystem&datasource=NCOMS%2CNCOMS2

      It only works for short URL

      https://localhost:8080/ibm/console/webtop/AELView?sql=Serial%3C0&trans +ientname=C02-2003-0260_SINREFERENCIA&viewname=Default_TMX&viewtype=sy +stem&datasource=NCOMS%2CNCOMS2

      This is ttml file content

      [%# formReference.ttml %] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <TITLE>Tivoli Netcool/OMNIbus Web GUI</TITLE> </head> <body> <form> <input type="hidden" id="preUrl" value="[% pre %]"> <input type="hidden" id="postUrl" value="[% post %]"> <select name="url" id="url" onchange="update();"> [% FOREACH url IN urls -%] <option value="[% url.value %]">[% url.key %]</option> [% END -%] </select> <input id="value" type="text" > <script type="text/javascript"> function update() { var select = document.getElementById('url'); var option = select.options[select.selectedIndex]; var preUrl = document.getElementById('preUrl').value; var postUrl = document.getElementById('postUrl').value; var newUrl = preUrl + encodeURI(option.value) + "&transientn +ame=" + option.text + postUrl; document.getElementById('value').value = newUrl; try { var newWindow = window.open(newUrl, '_blank', 'toolbar=0, +location=0,menubar=0'); } catch(ex) { document.getElementById('value').value = ex; } } update(); </script> </form> </body> </html>

      What can I do in order to get this solved? or How can I figure out what (is this character/are those characters) that it does not allow to process the URL?

        At last...!!!! My solution:

        [%# formReference.ttml %] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <TITLE>Please select your option</TITLE> <STYLE type="text/css"> select{display:inline-block;} div{text-align:center; border:1px solid gray;} </STYLE> </head> </head> <body> <form> <input type="hidden" id="preUrl" value="[% pre %]"> <input type="hidden" id="postUrl" value="[% post %]"> <div> <select name="url" id="url" onchange="update();"> [% FOREACH url IN urls -%] <option value="[% url.value %]">[% url.key %]</option> [% END -%] </select> <p id="p"></p> </div> <script type="text/javascript" charset="UTF-8"> function update() { var select = document.getElementById('url'); var option = select.options[select.selectedIndex]; var preUrl = document.getElementById('preUrl').value; var postUrl = document.getElementById('postUrl').value; var newUrl = preUrl + encodeURI(option.value) + "&transient +name=" + option.text + postUrl; document.getElementById("p").textContent = "Reference selec +ted: " + option.text; try { var newWindow = window.open("", '_blank', 'toolbar=0,loc +ation=0,menubar=0'); newWindow.location.href = newUrl; } catch(ex) { document.getElementById('value').value = ex; } } update(); </script> </form> </body> </html>

        Thanks all for your valuable help. I appreciate it.

      By the way, how can I edit ortograpy errors I did? Because I wrote quickly I forgot some basic English grammar. That way all you found out I am not a person who dominates English language.

        ... how can I edit ortograpy errors ...

        If you post as a registered user (e.g., logangha), see How do I change/delete my post? for site etiquette and protocol regarding editing your post. If you post as the Anonymous Monk, you cannot edit your post.


        Give a man a fish:  <%-{-{-{-<