title: Displaying Bootstrap Modal in Java
body: <p>I've got a login system made in Java for a project, and now I want to display Twitter Bootstrap's modal from the Java code on the JSP page. Is that possible? I've tried invoking the Javascript function, but that doesn't work because Javascript is client side and Java is server side.</p>
  
  <p>I've tried printing a script tag in Java, but that doesn't work either. I can print the modal in Java as well (with ) but I can't dismiss it then.</p>
  
  <p><strong>The modal I'm trying to display:</strong></p>
  
  <pre><code>&lt;!-- Login Modal --&gt;
  &lt;div class="modal fade" id="loginmodal" tabindex="-1" role="dialog" aria-labelledby="loginmodallabel" aria-hidden="true"&gt;
    &lt;div class="modal-dialog"&gt;
      &lt;div class="modal-content"&gt;
        &lt;div class="modal-header"&gt;
          &lt;h3 class="modal-title" id="loginmodallabel"&gt; Sample Title&lt;/h3&gt;
        &lt;/div&gt;
        &lt;div class="modal-body"&gt;
          &lt;p&gt;Sample Text&lt;/p&gt;
        &lt;/div&gt;
        &lt;div class="modal-footer"&gt;
          &lt;button type="button" class="btn btn-block" data-dismiss="modal"&gt;Close&lt;/button&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>The Java code</strong></p>
  
  <pre><code>//Checks if the username and password exist for the current selected building
  if(LoginDao.validate(name, pass, build, session))
      {           
          response.sendRedirect("/bigdata/dashboard.jsp");  
      }    
  else{    
      // I want to show the modal here
      rd= request.getRequestDispatcher("login.jsp");    
      rd.include(request,response);    
  }
  </code></pre>
  
  <p><strong>For reference:</strong> 
  Twitter Bootstrap Modal: <a href="http://getbootstrap.com/javascript/#modals" rel="nofollow">http://getbootstrap.com/javascript/#modals</a></p>