1
I have the following case:
I have an index.jsp file, which has the structure below:
<jsp:include page="templates/header.jspf"/>
<div id="view">
<jsp:include page="home.jspf"/>
</div>
<jsp:include page="templates/footer.jspf"/>
For navigation I call the pages via ajax, and change the content of the div from id="view", through the JS below:
function abrirPag(valor){
var url = valor;
xmlRequest.open("GET",url,true);
xmlRequest.onreadystatechange = mudancaEstado;
xmlRequest.send(null);
return url;
}
function mudancaEstado(){
if (xmlRequest.readyState == 4){
document.getElementById("view").innerHTML = xmlRequest.responseText;
}
}
But I have a problem. I have a login form, which accepts login from customers and administrators. After logging in, I would like the system to validate the user type and reload this index.jsp including the corresponding header (it is a header for the uninlogged user, another for clients and another for administrators). I’m not getting through.
I tried to use Requestdispatcher for that, but it didn’t work.
I also tried to call the JS function to reload the page, but it runs independent of the Servlet flow and I can’t know if the user who tried to log in really exists, nor if it is admin or client.
Does anyone know how I could solve this?
Interesting this approach. I will test here and return confirming whether or not I got it. Thank you very much!
– Marlon R.