2012-07-01 61 views
0

我试图从一个JSP页面移动到另一个页面,但在用户点击名称和密码后,它只是保持相同的页面。下面是完整的代码:用户输入输入后,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 and MySQL

当我从浏览器中运行这条线:http://localhost:8080/MyFirstServlet

我进入这个页面,我打homer & simpsonFirst page

然后,我只是停留在同一页面,在这里:

Second pic - the same page

任何想法我做错了什么?谢谢 !

+0

什么servlet代码被执行,什么不是? – BalusC

+0

这在多个层面上被破坏,第一个是对待servlet,比如它们是线程安全的,每个用户/连接/等等。 –

+0

@DaveNewton对不起,但我不完全明白,我做错了什么? – ron

回答

1

你的validate(...)方法将总是荷马辛普森&返回false,尝试其他的用户名/密码在HTML表单形式HTML代码动作参数

+0

半小时前我已将其删除,但未能解决问题。 – ron

+0

你没有在stackoverflow上编辑它,如果你使用IDE,尝试调试它。 – Raman

0

使用适当的行动提交,它应该去

相反变化的行动参数值,并尝试

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

使用本

<form action="student.jsp" method="POST"> 
相关问题