我编写了一个链接到servlet并再次链接到servlet的jsp代码。 代码, mahi1.jsp
<form action="mahi5" method="post">
<center>
<table>
<tr>
<td>
<h1><center> SIGN IN </center></h1>
</td>
</tr>
<tr>
<td>
Email:<nbsp> <nbsp>
</td>
<td>
<input type="text" name="user" value="" size="20" />
</td>
</tr>
<tr>
<td>Password:<nbsp> <nbsp></td>
<td>
<input type="password" name="pass" value="" size="20" />
</td>
</tr>
<tr>
<td>
<input type="submit" value="submit" />
</td>
</tr>
</table>
</center>
</form>
servlet-mahi5.java
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
String emailid=request.getParameter("user");
String password=request.getParameter("pass");
out.println("<a href=\"a2?m="+emailid+"\">");
out.println("Send information to someone</a>");
}
的jsp-mahi6.jsp
<%
String e1=(String)request.getParameter("emailid");
if(e1!=null)
{
%>
<br>
Enter the email id of the user you wanna send info to
<input type="text" name="user1" value="" size="15"/>
<input type="hidden" name="u1" value=<%=u1%> />
<input type="hidden" name="e1" value=<%=e1%> />
<input type="submit" value="proceed"/>
<%
}
%>
当我点击第一个jsp页面中的提交按钮时,它会显示一个空白页面。 网址上写着mahi5 有人可以帮我吗!
答案 0 :(得分:0)
更改Servlet服务方法中的代码。
PrintWriter out = response.getWriter();
String emailid=request.getParameter("user");
out.println("<a href=\"mahi6.jsp?emailid=" + emailid + "\">Send information to someone</a>");