
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<style type="text/css">
<!--
.style1 {
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
font-size: 18px;
}
-->
</style>
</head>
<body>
<p>Â </p>
<p>Â </p>
<p>Â </p>
<p>Â </p>
<table width="498" height="177" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#666666">
<tr>
<td width="184" height="51"> <div align="center" class="style1">
<div align="justify">NAME </div>
</div></td>
<td width="187"><label>
<input type="text" name="textfield" size="30">
</label></td>
</tr>
<tr>
<td height="48" class="style1"> <div align="justify">EMAIL</div></td>
<td><input name="textfield2" type="text" size="30"></td>
</tr>
<tr>
<td height="39"><div align="justify" class="style1">PASSWORD</div></td>
<td><input name="textfield3" type="text" size="30"></td>
</tr>
<tr>
<td height="39">Â </td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
<h1>Â </h1>
<form action="http://localhost:8080/WebApplication1/faces/jsp1.jsp">
<%@page language="java" %>
<%@ page import ="java.sql.*" %>
<% String name=request.getParameter("textfield");
String email=request.getParameter("textfield2");
String password=request.getParameter("textfield3");
try{
//String query ="INSERT INTO demodb VALUES('"+name+"','"+email+"','"+password+"')";
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@Nayna-PC:1521:orcl","scott","tiger");
//Statement stmt=conn.createStatement();
PreparedStatement ps=conn.prepareStatement("insert into demodb(name,email,password) values(?,?,?)");
ps.setString(1,name);
ps.setString(2,email);
ps.setString(3,password);
int rs=ps.executeUpdate();
//conn.close();
if(rs!=0){
System.out.println("successful");
}
else{
System.out.println("unsuccessful");
}
}
catch(Exception e){
System.out.println("error in connection"+e);
}
%>
</form>
</body>
</html>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.