Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Doubt about Template Toolkit

by logangha (Acolyte)
on Jul 14, 2022 at 15:53 UTC ( [id://11145527]=perlquestion: print w/replies, xml ) Need Help??

logangha has asked for the wisdom of the Perl Monks concerning the following question:

I am using Template Toolkit to generate HTML code. It is used inside a loop. First time (first iteration) works ok, but next it does not do anything. Here it is Perl code

my $headers = HTTP::Headers->new; $headers->header('Content-Type' => 'text/html;charset=UTF-8'); print $headers->as_string; my $template = Template->new({ INCLUDE_PATH => some path, INTERPOLATE => 1, }) || do { my $error = $Template::ERROR; my $q = new CGI; error($q, "Caught error: " . $error); }; my $link = ""; foreach my $key (keys %referencesData) { $link = $referencesData{$key}; # Here it is where html is invoked and first iteration works ok, b +ut next it does not do anything $template->process('template.ttml', { link => $link } ) || do { my $error = $template->error(); my $q = new CGI; error($q, "Caught error: " . $error); }; }

And here it is ttml code

[%# template.ttml %] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <head> <TITLE>Some title</TITLE> <meta http-equiv="refresh" content="$link" /> </head> <body> <center> </center> <form action=""> </form> </body> </html>

As I mentioned, it works ok in first iteration, but next one it seems it does not do anything. What seems to be the trouble?

Replies are listed 'Best First'.
Re: Doubt about Template Toolkit
by hippo (Bishop) on Jul 14, 2022 at 16:42 UTC

    Your provided code doesn't actually define %referencesData so maybe it only has one key?

    Here's an SSCCE showing TT running successfully in a loop.

    #!/usr/bin/env perl use strict; use warnings; use Template; my $tt = "value = [% thing %]\n"; my $template = Template->new; for my $this (qw/foo bar baz/) { $template->process (\$tt, { thing => $this }); }

    🦛

      Thanks for your quick answer hippo. This is %referencesData content:

      $VAR1 = { 'C02-2003-0263' => 'https://10.94.249.177:16311/ibm/console/ +webtop/AELView?sql=((TMX_NodeName%20!=%20\'\'%20and%20TMX_NodeName%20 +=%20\'CTJAXM7300W\'%20and%20PhysicalSlot%20=%201%20and%20PhysicalPort +=%203)%20or%20(TMX_NodeName%20!=%20\'\'%20and%20TMX_NodeName=%20\'CTJ +AXM7300W\'%20and%20PhysicalPort%20=%200))%20or%20(TMX_NodeName%20!=%2 +0\'\'%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\'%20and%20PhysicalSlot%2 +0=%2001%20and%20PhysicalPort%20=%209)%20%20or%20(TMX_NodeName%20!=%20 +\'\'%20and%20TMX_NodeName=%20\'TTTNXMCL05W\'%20and%20PhysicalPort%20= +%200))%20or%20((TMX_NodeName%20!=%20\'\'%20and%20TMX_NodeName%20=%20\ +'TTTNXMCL05W\'%20and%20PhysicalSlot%20=%2017%20and%20PhysicalPort%20= +%201)%20or%20(TMX_NodeName%20!=%20\'\'%20and%20TMX_NodeName%20=%20\'T +TTNXMCL05W\'%20and%20PhysicalSlot%20=%200%20and%20PhysicalPort%20=%20 +0))%20or%20((TMX_NodeName%20!=%20\'\'%20and%20TMX_NodeName%20=%20\'TT +TNXMCLO01-AGR3-06\'%20%20and%20PhysicalSlot%20=%2003%20and%20Physical +Port%20=%207%20)%20or%20(TMX_NodeName%20!=%20\'\'%20and%20TMX_NodeNam +e%20=%20\'TTTNXMCLO01-AGR3-06\'%20%20and%20PhysicalSlot%20=%200%20and +%20PhysicalPort%20=%200%20AND%20(AlertGroup%20IN%20(\'ReachabilityPro +blem\',%20\'component%20unreachable\',\'ER%20CEth%20Inalcanzable\')%2 +0OR%20AlertGroup%20%20LIKE%20\'[Pp]ower\'))%20)%20or%20(TMX_NodeName% +20=%20\'TTTNXMCLO01-AGR3-06\'%20and%20PhysicalSlot%20=%2003%20and%20P +hysicalPort%20=%200)%20or%20(TMX_NodeName%20=%20\'TTTNXMCLO01-AGR3-06 +\'%20and%20PhysicalSlot%20=%200%20and%20PhysicalPort%20=%200)%20or%20 +(TMX_NodeName%20!=%20\'\'%20and%20TMX_NodeName%20=%20\'TTTNXMCLO01-AG +R3-06\'%20AND%20PhysicalSlot%20=%200%20and%20PhysicalPort%20=%200%20A +ND%20(AlertGroup%20IN%20(\'ReachabilityProblem\',%20\'component%20unr +eachable\',\'ER%20CEth%20Inalcanzable\')%20OR%20AlertGroup%20%20LIKE% +20\'[Pp]ower\'))%20or%20((TMX_NodeName%20!=%20\'\'%20and%20TMX_NodeNa +me%20=%20\'CTLNXMCUO10-DIST1-09\'%20%20and%20PhysicalSlot%20=%2001%20 +and%20PhysicalPort%20=%2017%20)%20or%20(TMX_NodeName%20!=%20\'\'%20an +d%20TMX_NodeName%20=%20\'CTLNXMCUO10-DIST1-09\'%20%20and%20PhysicalSl +ot%20=%2009%20and%20PhysicalPort%20=%202%20)%20)%20or%20(TMX_NodeName +%20=%20\'CTLNXMCUO10-DIST1-09\'%20and%20PhysicalSlot%20=%2001%20and%2 +0PhysicalPort%20=%200)%20or%20(TMX_NodeName%20=%20\'CTLNXMCUO10-DIST1 +-09\'%20and%20PhysicalSlot%20=%2009%20and%20PhysicalPort%20=%200)%20o +r%20(TMX_NodeName%20!=%20\'\'%20and%20TMX_NodeName%20=%20\'CTLNXMCUO1 +0-DIST1-09\'%20AND%20PhysicalSlot%20=%200%20and%20PhysicalPort%20=%20 +0%20AND%20(AlertGroup%20IN%20(\'ReachabilityProblem\',%20\'component% +20unreachable\',\'ER%20CEth%20Inalcanzable\')%20OR%20AlertGroup%20%20 +LIKE%20\'[Pp]ower\'))%20or%20((TMX_NodeName%20!=%20\'\'%20and%20TMX_N +odeName%20=%20\'CTLNXMCU10W\'%20and%20PhysicalSlot%20=%200%20and%20Ph +ysicalPort%20=%201)%20or%20(TMX_NodeName%20!=%20\'\'%20and%20TMX_Node +Name%20=%20\'CTLNXMCU10W\'%20and%20PhysicalSlot%20=%200%20and%20Physi +calPort%20=%202)%20or%20(TMX_NodeName%20!=%20\'\'%20and%20TMX_NodeNam +e%20=%20\'CTLNXMCU10W\'%20and%20PhysicalSlot%20=%200%20and%20Physical +Port%20=%205)%20or%20(TMX_NodeName%20!=%20\'\'%20and%20TMX_NodeName%2 +0=%20\'CTLNXMCU10W\'%20and%20PhysicalPort%20=%200))&transientname=C02 +-2003-0263&viewname=Default_TMX&viewtype=system&datasource=NCOMS,NCOM +S2', 'C02-2003-0260_SINREFERENCIA' => 'https://10.94.249.177:1631 +1/ibm/console/webtop/AELView?sql=Serial%3C0&transientname=C02-2003-02 +60_SINREFERENCIA&viewname=Default_TMX&viewtype=system&datasource=NCOM +S,NCOMS2' };

      First key is processed succesfully, but second not...

        Thanks for this sample input. Before going any further I should just mention that passing raw SQL in a query string like this sets off all sorts of security Klaxons. Hopefully you are already aware of this and have taken all appropriate countermeasures.

        How do you know the second key is not processed? Are you viewing the results in a browser? If so, by the time the second key is reached your browser may have already refreshed and taken you to the URL in the first value at which point the rest of the script's output will be unseen.

        Did you run my SSCCE and determine for yourself that it processes the template inside the loop multiple times successfully?


        🦛

Re: Doubt about Template Toolkit
by haj (Vicar) on Jul 15, 2022 at 09:39 UTC
    I just noticed that your template is a complete HTML page (with two <head> tags, btw). So, you are printing two complete HTML pages to STDOUT. Your browser will read until the first </html> and then do the refresh. What behavior do you expect from that application?

      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.

        The days were browsers freely allowed sites to open as many windows/tabs as they wanted are thankfully long gone.

        But this might help in a private app, if you allow it explicitly in the browser settings, YMMV.

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery

      Hi haj, that ttml file was incorrect. This is the correct one

      [%# template.ttml %] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <TITLE>Some title</TITLE> <meta http-equiv="refresh" content="$link" /> </head> <body> <center> </center> <form action=""> </form> </body> </html>

      The idea with all of this, is when this cgi is executed, every processed url appears in a new tab. But first url does that, second url does not do anything. I made changes to cgi script to see that it reached after loop is executed and it efectively did. That is why I mention that second url is not executed.

        It is not TT's fault that this doesn't work as expected: Browsers don't work that way. If you use refresh (I'd recommend that you check the syntax, you did not specify the intended delay), browsers are not supposed to open a new tab.

        Also, hash keys are returned in random order, so you can't say for sure which of the URLs is inserted into the template first.

        If you are on Linux and have LWP installed, the easiest way to check your CGI is the following command:

        GET http://your-server.com/your.cgi.url/
        The idea with all of this, is when this cgi is executed, every processed url appears in a new tab

        Sending multiple HTML documents to the browser will not achieve this...

        I think I would approach this by adding all the URLs into an array and passing a reference to the array into Template to process a single template file. In the template file, have a some Javascript and a FOREACH loop that adds the Javascript calls to window.open for each URL.

        Rather than processing the template file multiple times within Perl, assemble the data in Perl and pass that once to the template file and let that do the iterations.

Re: Doubt about Template Toolkit
by Bod (Parson) on Jul 15, 2022 at 22:14 UTC
    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...

      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?

        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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11145527]
Approved by talexb
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-03-28 23:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found