0

我编写了一个链接到 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 谁能帮帮我!

4

1 回答 1

0

更改 Servlet 的服务方法中的代码。

PrintWriter out = response.getWriter();
String emailid=request.getParameter("user");
out.println("<a href=\"mahi6.jsp?emailid=" + emailid + "\">Send information to someone</a>");
于 2012-08-18T12:23:52.823 回答