0

如何在成功注册后显示的页面中显示用户名和密码。

我为注册开发的代码如下

<%@page import="java.io.*,java.sql.*;" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!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=UTF-8">
    <title>Halcyon Technologies Pvt. Ltd.</title>
</head>
<body bgcolor="#D9EEFB">
    <p
      <% try
      {
       String Username;
       String Password;
       ResultSet rs;
       Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
       Connection con=DriverManager.getConnection("jdbc:odbc:OnlineExam");
       Statement st=con.createStatement();
       Statement st2=con.createStatement();
       Statement st3=con.createStatement();
       String status="s";
       st2.executeUpdate("insert into Login values('"+request.getParameter("username")+"','"
                                                     +request.getParameter("password")+"','"
                                                     +status+"')");
       st.executeUpdate("insert into Details values('"+request.getParameter("username")+"','"
                                                      +request.getParameter("name")+"','"
                                                      +request.getParameter("gender")+"','"
                                                      +request.getParameter("sel_cat")+"')");
       if(request.getParameter("sel_cat").equals("Experienced"))
       {
                  st3.executeUpdate("insert into Experienced values('"+request.getParameter("username")+"','"+request.getParameter("expyears")+"','"+request.getParameter("company")+"','"+request.getParameter("designation")+"','"+request.getParameter("salary")+"','"+request.getParameter("comAddress")+"')");
       }
        String s1 = request.getParameter("username");
        String s2 = request.getParameter("password");

        session.setAttribute("s1", s1);
        session.setAttribute("s2", s2);
        rs = st.executeQuery("select Username, Password from Login where Username='" + s1 + "'");

       if (rs.next()) 
        {
            Username=rs.getString(1);
            Password=rs.getString(2);
            System.out.println(Username);
            System.out.println(Password);
        }
       st.close();
       st2.close();
       st3.close();
       }

       catch(Exception e)
               {
           out.println(e);
               }
%>
  <font color="red" size="5"> You have registered successfully!!!<br></font>
  <font color="red" size="5"> Username :  <br></font>
  <font color="red" size="5"> Password :  <br></font>
  <p><a href="Login.jsp"><strong>Go Forward</strong></a></p>
</body>
</html>

我可以在控制台上获取用户名和密码,但是如何在 JSP 上显示它们。

这里要在控制台上显示的代码是

if (rs.next()) 
        {
            Username=rs.getString(1);
            Password=rs.getString(2);
            System.out.println(Username);
            System.out.println(Password);
        }

显示 JSP 的代码如下。在这个 JSP 中,我想显示用户名和密码。

 <font color="red" size="5"> You have registered successfully!!!<br></font>
  <font color="red" size="5"> Username :  <br></font>
  <font color="red" size="5"> Password :  <br></font>
  <p><a href="Login.jsp"><strong>Go Forward</strong></a></p>

如何编写代码以在 JSP 中显示用户名和密码?

4

1 回答 1

0

你试过这样

<font color="red" size="5"> Username : <%= Username%> <br></font>
  <font color="red" size="5"> Password : <%=Password%> <br></font>
于 2013-06-04T12:28:53.230 回答