将jsp链接到servlet,再将其链接到servlet则显示出一些问题 [英] linking jsp to servlet and that to servlet again shows some problems
本文介绍了将jsp链接到servlet,再将其链接到servlet则显示出一些问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我编写了一个jsp代码,该代码链接到servlet,并且再次链接到servlet. 代码, mahi1.jsp
I have written a jsp code which links to a servlet and that links to a servlet again. The code, 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
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
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 有人可以帮我吗!
When i click the submit button in the first jsp page, it displays a blank page. The url says its mahi5 Could anyone help me please!
推荐答案
更改Servlet服务方法中的代码.
Change the code in Servlet's service method.
PrintWriter out = response.getWriter();
String emailid=request.getParameter("user");
out.println("<a href=\"mahi6.jsp?emailid=" + emailid + "\">Send information to someone</a>");
这篇关于将jsp链接到servlet,再将其链接到servlet则显示出一些问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文