Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
332 views
in Technique[技术] by (71.8m points)

java - 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');
});
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...