Member 12756458 Ответов: 0

Как получить данные из полей jsp и отправить их в базу данных. здесь register - это основной файл jsp, а файл действий-register1.jsp


This is the Registration Page. All the Details given in the Fields are to be Retrieved. 

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ``"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>Register</title>
	<meta charset="utf-8" />
	<link href="style.css" rel="stylesheet" type="text/css" />
	
</head>
<body>
<p>&nbsp;</p>

<div id="login">
<center>
<h1><font color="black">&nbsp;&nbsp;&nbsp;&nbsp;Welcome! Please Register</font></h1>
</center>

<form action="register1.jsp" method="get">
<fieldset>
<p><input name="fn" onblur="if(this.value=='')this.value='Firstname'" onfocus="if(this.value=='Firstname')this.value='' " required="" type="text" value="Firstname" /></p>

<p><input name="ln" onblur="if(this.value=='')this.value='Lastname'" onfocus="if(this.value=='Lastname')this.value='' " required="" type="text" value="Lastname" /></p>

<p><input name="un" onblur="if(this.value=='')this.value='Username'" onfocus="if(this.value=='Username')this.value='' " required="" type="text" value="Username" /></p>

<p><input name="pwd" onblur="if(this.value=='')this.value='Password'" onfocus="if(this.value=='Password')this.value='' " required="" type="password" /></p>

<p><input name="email" onblur="if(this.value=='')this.value='Email'" onfocus="if(this.value=='Email')this.value='' " required="" type="text" value="Email" /></p>

<p><input name="phno" onblur="if(this.value=='')this.value='PhoneNo'" onfocus="if(this.value=='PhoneNo')this.value='' " required="" type="text" value="PhoneNo" /></p>

<p><input type="submit" value="Register" /></p>
</fieldset>
</form>
</div>

<p>&nbsp;</p>

<div id="background"><img alt="" class="stretch" src="bg.jpg" /></div>
</body>
</html>

This is the Action Jsp Page
<%@ page import = "java.sql.*" %>
<%@ include file="DbConnection.jsp"%>




<%

String first = request.getParameter("fn");
String last = request.getParameter("ln");
String user = request.getParameter("un");
String password = request.getParameter("pwd");
String email = request.getParameter("email");
String phone = request.getParameter("phno");





pst = con.prepareStatement("insert into Registration_Services values(?,?,?,?,?,?)");

pst.setString(1,first);
pst.setString(2,last);
pst.setString(3,user);
pst.setString(4,password);
pst.setString(5,email);
pst.setString(6,phone);

int result = pst.executeUpdate();(error is here)

RequestDispatcher rd = request.getRequestDispatcher("login.jsp");
rd.include(request,response);

%>
The Error that i am getting is http error 500

What I have tried:

I have tried to use all the execute kind of commands like executeQuery, eececute and also executeUpdate but i couldnt find the solution

0 Ответов