<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<%@ taglib prefix="cui" tagdir="/WEB-INF/tags" %>

<!DOCTYPE html>
<html>
<head>
<title>企业管理</title>
</head>

<body>
<%
String forwardUrl=(String)request.getSession().getAttribute("forwardUrl");
if(forwardUrl==null){
    forwardUrl="";
}else{
    request.getSession().setAttribute("forwardUrl",null);
}
com.cesgroup.cesmonitor.service.LoginUser user=com.cesgroup.cesmonitor.common.Util.getLoginUser();
if(user!=null){
%>
<script type="text/javascript">
<%-- //window.location="${ctx}/php/index.php?name=<%=user.getUsername()%>&password=<%=user.getPassword()%>&enter=Sign%20in";
 --%>
 function autoLogin(loginUrl,usernameValue,passwordValue,forwardUrlValue){
    //	alert(loginUrl+username+password);
	    var form = document.createElement("form");
	    document.body.appendChild(form);
	    
	    var username = document.createElement("input");
	    username.type = "hidden";
	    form.appendChild(username);
	    username.value = usernameValue;
	    username.name = "name";
	    
	    var password = document.createElement("input");
	    password.type = "hidden";
	    form.appendChild(password);
	    password.value = passwordValue;
	    password.name = "password";
	    
	    var forwardUrl = document.createElement("input");
	    forwardUrl.type = "hidden";
	    form.appendChild(forwardUrl);
	    forwardUrl.value = forwardUrlValue;
	    forwardUrl.name = "forwardUrl";
	    
	    var enter = document.createElement("input");
	    enter.type = "hidden";
	    form.appendChild(enter);
	    enter.value = 'Sign in';
	    enter.name = "enter";

	    form.method = "POST";
	    form.action = loginUrl;
	    form.submit();
   }
   autoLogin("${ctx}/php/index.php","<%=user.getUsername()%>","<%=user.getPassword()%>","<%=forwardUrl%>");
</script>
<%	
}
%>
</body>
</html>