You can use ajax to get html from the second jsp, and then add to the DOM or innerHTML element.
.Jsp homepage
<span id=confirmSpan></span>
<script language="Javascript">
function xmlhttpPost(strURL, queryStr) {
var xmlHttpReq = false;
var self = this;
if (window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}else{
alert("no ajax")
return
}
self.xmlHttpReq.open('POST', strURL, true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4) {
updatepageConfirm(self.xmlHttpReq.responseText);
}
}
self.xmlHttpReq.send(queryStr);
}
function updatepageConfirm(str){
document.getElementById("confirmSpan").innerHTML = str;
}
function logout1(){
xmlhttpPost("confirm.html");
}
</script>
</head>
<body>
<form id="search" action="/search" method="get">
<input type=button onclick=logout1() value=logout>
</form >
Example of a page with a confirmation code -> any valid html for a div can be
confirm.jsp
Take an action ... Are you sure?
// todo form here html span / pop up / script / css → as iframe, - - ?
, id "logoutConfirmSpan", , ajax ( async → false, ) html innerHTML
html , .
. HTML div Ajax , ajax jQuery
:
HTML-
<span id = 'logoutConfirmSpan'> </span>
<script>
function setHtmlForConfirm(req)
{
document.getElementById('logoutConfirmSpan').innerHTML = req.responseText;
}
</script>