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對象, –