响应从 servlet 重定向到 jsp 后,jsp 页中的关闭按钮不起作用



我的jsp(Welcome.jsp)页面上有一个提交按钮,我将请求发送到myservlet(导入零件)。我在servlet中做了一些验证,验证失败后,我将用户重定向到错误.jsp页面,该页面给出了合适的消息。此错误.jsp还有一个关闭按钮,在我将响应转发到错误.jsp后不起作用。

如果我直接在浏览器中启动错误.jsp并尝试单击关闭按钮,它会起作用。

// Below is the piece of code written in my Servlet on doPost() method which perform some validation and upon failing the validation check redirects user to error.jsp page.
if(!UserDetails.checkValidUser(asession))  //a Validation method returning true or false
            {
                logger.info("User do not have necessary role");
                request.setAttribute("error", EMSImportConstants.NO_PRIVILEGE_USER_ERR_MESSAGE);
                RequestDispatcher rd = request.getRequestDispatcher("/Error.jsp");
                rd.forward(request, response);
            }
//Below is my error.jsp page code
<% 
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>
<html>
<head>
<title>Error in EMS BOM Import</title>
        <link href="<%=basePath %>/css/netapps.css" rel="stylesheet" type="text/css" /> 
</head>
<body bgcolor="#ffffff" class="borderless">
<form method="post" action="Error.jsp">
 <center>
            <div id="banner">
                <div id="logo"></div>
                <div id="rightbg">
                    <div id="bannerTitle"><br>EMS BOM Import</div>
                </div>
                <div id="bannerImage"> </div>
            </div>
</center>
<br />
<br />
<br />
<br />
<center>
<font size = "2px" color="red">
<%=request.getAttribute("error") %>
</font>
<table>
<tr>
<td align="center"><input type="button" value="Close"  onclick="window.close();"/></td>
</tr>
</table>
</center>
</form>
</body>
</html>

I click on close button but nothing happens.

表单中,要提交详细信息,input类型应submit,但不应button。以这种方式更改代码。它应该:)工作

<form>
  <td align="center"><input type="submit" value="Close" onclick="window.close();" /></td>
</form>

最新更新