I'm a newbie to Java and this is part of my college assignment, which needs to be handed in soon. The following is a jsp page which accesses a database using userID to find the data on that user. The problem is the variable firstname is recognised in the rs, but is not recognised as a value in the form. Thanking you in advance for your help.
<%@ page import="java.sql.*" %>
<%
String userID = request.getParameter("userID");
String connectionURL = "jdbc:mysql://localhost/cms_college";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
%>
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "root", "");
statement = connection.createStatement();
rs = statement.executeQuery("SELECT * FROM users WHERE userID="+userID);
while (rs.next()) {
String firstname=rs.getString("firstname");
String surname = rs.getString("surname");
out.println(firstname);
}
rs.close();
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="main.css">
<title>Add User</title>
</head>
<div class="wrapper">
<img src="banner.png" />
<div id="nav-menu">
<ul>
<li>
Home</li>
<li>
Products</li>
<li>
Contact us</li>
<li>
Opening</li>
<li>
Subscribe</li>
<li>
Log In</li>
<li>
Admin</li>
</ul>
<body>
<div class="homebox">
<form method="Post" action="AddUserServlet">
<h2>Edit Employee </h2>
First Name:<input type ="text" name = "firstname" value=<% out.println(firstname); %> /><br />
Surname:<input type ="text" name = "surname" />
Group: <input type ="text" name = "thegroup" />
Username: <input type ="text" name = "user" />
Password: <input type ="text" name = "pass" />
Email: <input type ="text" name = "email" />
<input type = "submit" value ="Add User" />
</form>
</div>
</body>
</div>
</html>