Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include a jsp inside another jsp using javascript

I have a button logout. Once logout is clicked I need to show another page. How can I do this using JavaScript? Can anyone please help me?

My Code:

<s:form name="LogoutAction"
                id="LogoutAction" action="logout">
    <span class="inlayField2">
    <s:a href="logout" cssClass="planTabHeader" id="logoutId"> <img src="../../KY/images/common/header/lock.png" alt="logout" style="border: none;background-color: transparent;" /> &nbsp;Log out</s:a></span>
    </s:form> 

I tried this:

$('#logoutId').click(function(event) {

    $('#logoutdiv').load('ConfirmationPopup.jsp');
});
like image 730
mukund Avatar asked Apr 23 '13 06:04

mukund


People also ask

How can we include one JSP in another JSP?

To include JSP in another JSP file, we will use <jsp:include /> tag. It has a attribute page which contains name of the JSP file.

Which tag is used to include JSP into another JSP file at runtime?

The jsp:include action tag is used to include the content of another resource it may be jsp, html or servlet.

Is it possible to include the results of another page in JSP?

Include action tag is used for including another resource to the current JSP page. The included resource can be a static page in HTML, JSP page or Servlet.


1 Answers

You can't include a JSP in respone to a click on the client side because it's a server-side technology. You could include the desired HTML in the page before it's sent, hide that area with CSS, and then make it visible in response to a mouse click using JavaScript.The include would already have happened on the server before the page was sent to the client. You can have something like this:

<div id="confirmPopup" style="display:hidden;">
      <%@ include file="ConfirmationPopup.jsp" %>
</div>
<script>
  $('#logoutId').click(function(event) {
   document.getElementById("confirmPopup").style.display="block";
  });
</script>
like image 153
AllTooSir Avatar answered Oct 06 '22 01:10

AllTooSir