我正在尝试在文本框中显示数据库中的用户ID。在输入中,我试图检索有效的用户ID,但是当我尝试在文本框中显示它时,它没有出现吗?如果我的代码正常工作,那么Java部分却不确定如何在文本框中显示结果集?任何帮助,不胜感激。
<!DOCTYPE html>
<html>
<head>
<title>JPage</title>
</head>
<body>
<%
try{
String session_id =null;
HttpSession session1=request.getSession(false);
if(session1!=null){
session_id=(String)session1.getAttribute("name");
}
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/alt", "root", "");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from register where uid='"+session_id+"'");
rs.next();
String uid = rs.getString("uid");
%>
<form action="register_1.jsp" method="post">
<input type="text"name="TestType" value="Chemical">
<imput type="text" value=" <%out.print(uid);%> " name="uid" >
<input value="Create" type="submit" class="btn" style="width: 100px;">
</form>
<%
}catch(Exception e){
out.println(e);
}
%>
</body>
</html>
`