How to trigger a Jquery function based on a boolean flag value from JSP

I am going some validation in my Action class and returning some flag to JSP. Based on the Flag value, I need to trigger the JQuery function to create some popup window.  Here is my Jquery script:

      var message ='Confirm Delete? ';
      alert("inside close");
          var title = $('form').attr('data-CloseTitle');
          var cancelLabel  = $('form').attr('data-CloseCancelLabel');
          var confirmLabel = $('form').attr('data-CloseConfirmLabel');
          var confirmMessage = $('form').attr('data-CloseConfirmMessage');
          // Default labels for dialog
          if(!title) { title = 'Close Approval'; }
          if(!cancelLabel) { cancelLabel = 'No'; }
          if(!confirmLabel) { confirmLabel = 'Yes, continue.'; }
          if(!confirmMessage) { confirmMessage = 'approval is required. Do you want to send this to close'; }
          $('#biller').bind('click', function(e){
                alert("inside function");
              var link = $( this ).attr('data-CloseLink');
              var dialogButtons = {};
              dialogButtons[cancelLabel] = function(){ $( this ).dialog('close'); }
              dialogButtons[confirmLabel] = function(){  $( this ).dialog('close');
              $('form').attr('action', link);
              $("form").submit(); }
              $('<div id="dialog-confirm" title="'+ title +'">'+ confirmMessage +'</div>') // Create dialog
                resizable: false,
                draggable: false,
                show: 'drop',
                hide: 'drop',
                modal: true,
                buttons: dialogButtons
              return e;

Here is my JSP, I am trying to trigger the Jquery based on the flag:
<c:if test="${sendToclose}">

But the jquery is not triggering and popup is not coming. Please let me know the problem here or any suggestions to trigger the jquery based on the flag value only.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

wrap it like

     $(function() {

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kiran SonawaneProject LeadCommented:

quickjavaAuthor Commented:
Thanks and it is working. But actually I don't want any button on the screen to trigger this.  I want to trigger the Jquery when the flag is true.  Currently I binded the jquery using the button click .
 $('#biller').bind('click', function(e){ } But I don't want any button on the screen and I need to trigger it when the flag is true.  How to bind this in jquery instead of button click.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.