Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用url在jsp页面之间发送变量_Jsp_Variable Assignment - Fatal编程技术网

使用url在jsp页面之间发送变量

使用url在jsp页面之间发送变量,jsp,variable-assignment,Jsp,Variable Assignment,我通过URL将一个变量值传递给另一个jsp页面,但是当我在第二个jsp页面上运行System.out.println来检查变量值时,它总是空的 感谢您的帮助 下面的代码是我的原始程序的片段,以使其不那么冗长。 Testsend.jsp <%@ page import ="java.sql.*" %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=IS

我通过URL将一个变量值传递给另一个jsp页面,但是当我在第二个jsp页面上运行
System.out.println
来检查变量值时,它总是空的

感谢您的帮助

下面的代码是我的原始程序的片段,以使其不那么冗长。

Testsend.jsp

<%@ page import ="java.sql.*" %>  
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
    <!-- Prints out Table header  -->
    <table border="1">
    <tr>
    <td>Title</td>
    </tr>
<%

PreparedStatement pstmt;

pstmt = conn.prepareStatement("Select * from tadot");

ResultSet rs = pstmt.executeQuery();

while(rs.next()){

    out.println("<form action ='Testsend.jsp' method='post'");
    out.println("<tr>");
    out.println("<td>" + rs.getString("Title") + "</td>");
    out.println("<td> <input type='hidden' name='hidden' value='"+rs.getString("Title")+"'> <input type='submit' name='editm' value='Edit'>  </td>");
    out.println("</tr>");
    out.println("</form>");
    }

String ed="";

// Check if edit button is clicked
if(request.getParameter("editm") != null) {
    String getmov3 = request.getParameter("hidden");
    // DEBUG - PRINTS OUT VALUE CORRECTLY
    System.out.println("Testsend.jsp"+getmov3);
    ed = getmov3;
    // DEBUG - PRINTS OUT VALUE CORRECTLY
    System.out.println(ed);

// Passes variable ed to Testrec.jsp    
response.sendRedirect("Testrec.jsp?ed"+ed);

}

%>  
</table>

</body>
</html>

在此处插入标题
标题
Testrec.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
        <%@ page import ="java.sql.*" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

<%

    String getmov2 = request.getParameter("ed");
    // DEBUG - NULL VALUE PRINTED. ERROR.
    System.out.println("Testrec.jsp"+getmov2);

%>
</body>
</html>

在此处插入标题

看来您错过了
“=”


谢谢。该死的,我刚刚错过了一个标点符号,这让我很头疼。
response.sendRedirect("Testrec.jsp?ed="+ed);