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", via 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 clients 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 unlogged user, one for clients and one for administrators). I can not do this via servlet.
I tried to use RequestDispatcher for this, but it did not work.
I have also tried to call the JS function to reload the page, but it runs independently of the Servlet stream and I can not tell if the user who tried to log in actually exists, or whether he is an admin or a client.
Does anyone know how I could solve this?