JSP validation
Hello,
I have just started learning JSP....... So i hv very basic doubts........
This is simple JSP form ........
<html>
<head>
<title>new user</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<h1>Please enter your details</h1>
<form action="valid_1st_user.jsp" method="post">
<table cellspacing="5" cellpadding="5" border="1">
<tr>
<td align="right">Name:</td>
<td><input type="text" name="NewName"></td>
</tr>
<tr>
<td align="right">Email Address:</td>
<td><input type="text" name="EmailAddress"></td>
</tr>
<tr>
<td align="right">Nationality:</td>
<td><input type="text" name="Nationality"></td>
</tr>
<tr>
<td align="right">User Name:</td>
<td><input type="text" name="UserName"></td>
</tr>
<tr>
<td align="right">Password:</td>
<td><input type="password" name="Password"></td>
</tr>
</table>
<input type="submit" value="Submit">
</form>
</body>
</html>
After i enter all the details in the form, it should be validated & the code is,
<html>
<head>
<title>Validate New User</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page import="java.sql.*" %>
<%
Connection con = null;
String names = request.getParameter("NewName");
String eaddress = request.getParameter("EmailAddress");
String nation = request.getParameter("Nationality");
String userid = request.getParameter("UserName");
String pw = request.getParameter("Password");
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection Con=DriverManager.getConnection("jdbc:odbc:conect" );
Statement st=Con.createStatement();
ResultSet rst = stat.executeQuery(queryText);
String queryText = ("INSERT INTO studentinfo "+('"+Names+"', '"+EAddress+",'
'"+Nation+"', '"+userid+"','"+password+"')
"values("+names+","+eaddress+","+nation+","+userid +","+pw+")");
rst.close();
st.close();
Con.close();
}
catch(Exception e)
{}
// response.sendRedirect("success.htm");
%>
But i get error in this code.. Can you please hepl me find the error & i should be abble 2 update my database as well.
Aparna.
|