无法在javascript中读取表单提交上的ResponseHeader值
当我尝试使用servlet进行用户登录时。我无法读取我在筛选器中添加的响应标头值 Login.html:-无法在javascript中读取表单提交上的ResponseHeader值,javascript,jquery,html,servlet-filters,Javascript,Jquery,Html,Servlet Filters,当我尝试使用servlet进行用户登录时。我无法读取我在筛选器中添加的响应标头值 Login.html:- <div class="container"> <form class="form-signin" id="loginForm" name="loginForm" action="/JerseyPageRedirection/login/RedirectDemo" method="post" onsubmit="pwd_handler(t
<div class="container">
<form class="form-signin" id="loginForm" name="loginForm"
action="/JerseyPageRedirection/login/RedirectDemo" method="post" onsubmit="pwd_handler(this);">
<div class="errmsg text-center"></div>
<label for="inputEmail">Email address</label> <input type="email"
id="emailId" class="form-control" name="emailId"
placeholder="Email address" required autofocus> <br> <label
for="inputPassword">Password</label> <input type="password"
id="password" class="form-control" name="password"
placeholder="Password" required>
<input type="hidden" name="epassword" value="" /><br>
<button type="submit" class="btn btn-lg btn-primary btn- block">Sign in</button>
</form>
</div>
<script>
function pwd_handler(form)
{
if (form.password.value != '')
{
form.epassword.value = window.btoa(form.password.value);
form.password.value = '';
}
}
</script>
<html>
<head>
<meta charset="UTF-8">
<title>main</title>
</head>
<body>
<script>
console.log(window);
//Here need to read ResponseHeader
</script>
<p>Hello main page</p>
LoginServlet:-
public class RedirectDemo extends HttpServlet {
private static final long serialVersionUID = -8230594616794095241L;
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.sendRedirect("../main.html");
}
}
重定向请求和响应头之后:-
现在我想用javascript读取授权头。请有人帮我读取授权头
main.html:-
<div class="container">
<form class="form-signin" id="loginForm" name="loginForm"
action="/JerseyPageRedirection/login/RedirectDemo" method="post" onsubmit="pwd_handler(this);">
<div class="errmsg text-center"></div>
<label for="inputEmail">Email address</label> <input type="email"
id="emailId" class="form-control" name="emailId"
placeholder="Email address" required autofocus> <br> <label
for="inputPassword">Password</label> <input type="password"
id="password" class="form-control" name="password"
placeholder="Password" required>
<input type="hidden" name="epassword" value="" /><br>
<button type="submit" class="btn btn-lg btn-primary btn- block">Sign in</button>
</form>
</div>
<script>
function pwd_handler(form)
{
if (form.password.value != '')
{
form.epassword.value = window.btoa(form.password.value);
form.password.value = '';
}
}
</script>
<html>
<head>
<meta charset="UTF-8">
<title>main</title>
</head>
<body>
<script>
console.log(window);
//Here need to read ResponseHeader
</script>
<p>Hello main page</p>
主要的
控制台日志(窗口);
//这里需要阅读ResponseHeader
你好主页