0
即时尝试设置请求范围内的值,并获得另一个jsp,因为我点击按钮弹出窗口打开并获取空值,导致我的要求是获取按钮的值在其他JSP来验证码两个部分,如果用户对按钮1,则find by id
文本区域开放,如果点击按钮2,然后find by name
文本区开那么弹出窗口应被关闭设置请求范围的按钮值并获取其他jsp
<HTML>
<HEAD>
<TITLE>Using Buttons</TITLE>
<script type="text/javascript">
function button1()
{
var mywindow= window.open("file.jsp", "file","status=1,width=350,height=150");
}
</SCRIPT>
</HEAD>
<BODY>
<H1>Using Buttons</H1>
<INPUT TYPE="BUTTON" name="butto" VALUE="Button 1" ONCLICK="button1()"/>
<% request.setAttribute("button1" ,"butto");%>
<% request.setAttribute("button1" ,"butto");%>
</BODY>
</HTML>
,这是我的文件.jsp
<!
DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"%>
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql"%>
<%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml"%>
<%@page
import="com.nousinfo.tutorial.employee.service.model.bo.EmployeeBO"%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<%= (String)request.getAttribute("button1") %>
<body>
</body>
</html>
这是为什么我得到空值的错误
MuraliPrasanth如果我在我的index.jsp THN它使用直接着工作文件.jsp <%request.setAttribute(“button1”,“butto”); request.getRequestDispatcher(“/ file.jsp”)。forward(request,response);%>我想单击按钮弹出将打开然后值将显示通过文件.jsp –
而不是在您的方案中使用请求作用域对象你可以像session.setAttribute()和session.getAttribute()那样简单地使用session scope对象, –