成功注册后,JSP中的用户名和密码

时间:2013-06-04 11:59:27

标签: jsp

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

我为注册开发的代码如下

<%@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中显示用户名和密码的代码?

1 个答案:

答案 0 :(得分:0)

你有没有试过这个

<font color="red" size="5"> Username : <%= Username%> <br></font>
  <font color="red" size="5"> Password : <%=Password%> <br></font>