Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.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
Java JSP页面赢得';在用户输入后,不要移动另一页_Java_Mysql_Jsp_Jdbc - Fatal编程技术网

Java JSP页面赢得';在用户输入后,不要移动另一页

Java JSP页面赢得';在用户输入后,不要移动另一页,java,mysql,jsp,jdbc,Java,Mysql,Jsp,Jdbc,我试图从一个JSP页面移动到另一个页面,但是在用户点击名称和密码后,它就保持在同一个页面上。以下是完整的代码: 这里是index.jsp:我从这个页面开始 <%@ page language="java" contentType="text/html; charset=windows-1255" pageEncoding="windows-1255"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional/

我试图从一个JSP页面移动到另一个页面,但是在用户点击名称和密码后,它就保持在同一个页面上。以下是完整的代码:

这里是index.jsp:我从这个页面开始

<%@ page language="java" contentType="text/html; charset=windows-1255"
    pageEncoding="windows-1255"%>
<!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=windows-1255">
<title>Insert title here</title>
</head>
<body>
<form action="LoginServlet" method="POST">
        First Name: <input type="text" name="firstName" size="20"><br>
        Last Name: <input type="text" name="lastName" size="20">
        <br><br>
        <input type="submit" value="Submit">
</form> 

</body>
</html>

在此处插入标题
名字:
姓氏:

这里是student.jsp:我想转到这个页面

<%@ page contentType="text/html; charset=utf-8" language="java"%>
<jsp:useBean id="userBean" class="UserBean" scope="session" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet"  type="text/css" href="css/style2.css" />
<title>Student Access Details</title>
</head>

<body>
<table>
    <tr>
        <td rowspan="4" class="align_top"><img src="img/photo.jpg" width="120" height="120" /></td>
        <td class="align_top">Student name: </td>
        <td class="bold"><%= userBean.getFirstName() %> <%= userBean.getLastName() %></td>
    </tr>
    <tr>
        <td class="align_top">University ID: </td>
        <td><%= userBean.getUid() %></td>
    </tr>       
    <tr>
        <td class="align_top">Address: </td>
        <td><%= userBean.getAddress1() %><br />
            <%if(userBean.getAddress2() != null)
                {%>
                <%= userBean.getAddress2() %><br /><%}%>            
            <%= userBean.getCity() %><br />
            <%= userBean.getPostCode() %><br />
        </td>
    </tr>
    <tr>
        <td class="align_top">Contact: </td>
        <td>Tel: <%= userBean.getPhone() %><br />
            Email: <%= userBean.getEmail() %>
        </td>
    </tr>            
</table>
</body>
</html>

学生访问详细信息
学生姓名:
大学编号:
地址:




联系人: 电话:
电邮:
我使用的是
Tomcat、JDBC、XAMPP和MySQL

当我从浏览器运行时,这一行:
http://localhost:8080/MyFirstServlet

我进入这个页面,点击荷马和辛普森:

然后我就停留在同一页,这里:


知道我做错了什么吗?谢谢

对于homer&simpson,您的validate(…)方法将始终返回false,请尝试其他用户名/密码

在HTML表单中的HTML代码操作参数中使用适当的操作,以便表单提交到应该提交的位置

而不是更改动作参数值并重试

<form action="LoginServlet" method="POST">

用这个

<form action="student.jsp" method="POST">


执行了哪些servlet代码,哪些没有执行?这在多个层面上都被打破了,第一个层面是将servlet视为线程安全和每个用户/连接的独占性等@DaveNewton抱歉,但我没有完全理解,我做错了什么?Dave是对的,servlet类设计完全错误,但这并不能解释为什么它似乎没有被调用。设计是一个不同的问题,仔细阅读这个答案可以更好地理解这个问题:如果您使用IDE调试它,那么您没有在stackoverflow上编辑它。