<html>
<head>
<title>Registration form </title>
<script>
<form name="register" onsubmit="return validateForm()" action='register.jsp' method='get'>
<table>
<tr><td><font face="Times New Roaman">First Name*:</font></td><td><input type='text' name='fname' maxlength='30'></td></tr>
<tr><td><font face="Times New Roaman">Middle Name:</font></td><td><input type='text' name='mname' maxlength='30'></td></tr>
<tr><td><font face="Times New Roaman">Last Name*:</font></td><td><input type='text' name='lname' maxlength='30'></td></tr>
<tr><td><font face="Times New Roaman">Date of birth*</font></td>
<td><select name='date'>
<option value='0'>DD</option>
</select>
<select name='month'>
<option value='0'>MM</option>
</select>
<select name='year'>
<option value='0'>YYYY</option>
</select>
</td></tr>
<tr><td><font face="Times New Roaman">Mobile Number*</font></td><td><input type='text' name='mob' value='10 digit' onblur="if (this.value == '') {this.value = '10 digit';}"
onfocus="if (this.value == '10 digit') {this.value = '';}" maxlength='10'></td></tr>
<tr><td><font face="Times New Roaman">Email Address*</font></td><td><input type='text' name='email' value='example@domain.com' onblur="if (this.value == '') {this.value = 'example@domain.com';}"
onfocus="if (this.value == 'example@domain.com') {this.value = '';}"></td></tr>
<tr><td><font face="Times New Roman">Address*</font></td><td><textarea rows="4" name="address"></textarea></td></tr>
<tr><td></td><td><input type='submit' value='submit'><input type='reset' value='reset'></td></tr>
</table>
</form>
</body>
</html>
当我在 jsp 页面中输入值时,不要想到这段代码,它正在调用另一个名为 register.jsp 的页面,下面给出了我如何为用于将值插入数据库的休眠程序的代码
<html>
<body>
<%@page import="devmanuals.model.UserDao"%>
<jsp:useBean id="link" scope="application" class = "devmanuals.model.User" />
<%
String fname=request.getParameter("fname");
String lname=request.getParameter("lname");
String mobile=request.getParameter("mob");
String email=request.getParameter("email");
out.print("Welcome "+fname);
int i=UserDao.register(link);
if(i>0)
{
out.println("sucessfully registered");
}
%>
当我使用上面的代码时,它显示除此之外的错误我们如何将值传递给休眠