Why is JS/JQuery function inside JSTL is not working?
<p>In my JSP, I calling a JSP function based on the value of JSTL. I see the alert statement inside the JS (inside JSTL) working , but not the JQuery. Why is that?</p>

<pre><code>&lt;c:set var = "error" value="${SPRING_SECURITY_LAST_EXCEPTION.message}"/&gt;
&lt;c:choose&gt;                  

    &lt;c:when test="${error=='not unregistered'}"&gt; 
            &lt;script type="text/javascript"&gt;
               alert("Hi"); 
               openSignUp();
            &lt;/script&gt;                                                                               
    &lt;/c:when&gt;
    &lt;c:otherwise&gt;
        &lt;c:out value="${SPRING_SECURITY_LAST_EXCEPTION.message}" /&gt;                                             
    &lt;/c:otherwise&gt;                                      
&lt;/c:choose&gt;                     
&lt;c:remove var = "SPRING_SECURITY_LAST_EXCEPTION" scope = "session" /&gt;   

&lt;script&gt;
   function openSignUp(){
         $('#signUp_dialog').dialog({
            width:350,
            open: function(event, ui) {
            $(".ui-button-text").remove();
            $(".ui-dialog-title").css("margin-right","275px");
            }
         });                    
    }

&lt;/script&gt;
</code></pre>

<p>I tried following as well, by putting directly the code inside JS function inside the script tags of JSTL. Still no luck.</p>

<pre><code>&lt;c:set var = "error" value="${SPRING_SECURITY_LAST_EXCEPTION.message}"/&gt;
&lt;c:choose&gt;                  
    &lt;c:when test="${error=='not unregistered'}"&gt; 
        &lt;script type="text/javascript"  src="&lt;c:url value="/resources/scripts/jquery-ui-1.11.4/external/jquery/jquery.js" /&gt;"&gt;
        $(document).ready(function() {  
            $('#signUp_dialog').dialog({

                width:350,
                open: function(event, ui) {
                    alert("hi");
                    $(".ui-button-text").remove();
                $(".ui-dialog-title").css("margin-right","275px");
                }
             });    
        });     
        &lt;/script&gt;                                                                               
    &lt;/c:when&gt;
    &lt;c:otherwise&gt;
        &lt;c:out value="${SPRING_SECURITY_LAST_EXCEPTION.message}" /&gt;                                             
    &lt;/c:otherwise&gt;                                      
&lt;/c:choose&gt;                     
&lt;c:remove var = "SPRING_SECURITY_LAST_EXCEPTION" scope = "session" /&gt;   
</code></pre>

<p>Please help me. Thanks.</p>