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;" /> Log out</s:a></span>
</s:form>
I tried this:
$('#logoutId').click(function(event) {
$('#logoutdiv').load('ConfirmationPopup.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.
The jsp:include action tag is used to include the content of another resource it may be jsp, html or servlet.
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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With