Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Netbeans Programming Create a web app that has a submit button RegisterTo a

ID: 3906750 • Letter: J

Question

Java Netbeans Programming
Create a web app that has a submit button RegisterTo allow a user to register with the site
it involves entering: username, password, email.
When the user click on the register submit, it should go to a servlet “RegisterServlet” that reads the user information and sends them to a server.
The server should wait for a “register” command to read the user info and save to a file.
then return a message back to the servlet (client) “done” or “undone”
The servlet then sends a message to the users to let them know whether they had been successfully registered or not.

Explanation / Answer

The Backend Database Table is given below:-

CREATE TABLE "REGISTERUSER"
( "NAME" VARCHAR2(4000),
"PASS" VARCHAR2(4000),
"EMAIL" VARCHAR2(4000),
"COUNTRY" VARCHAR2(4000)  
)  
/  

In this question, we have created the 2 files.

register.html

<html>  
<body>  
<form action="servlet/RegisterServlet" method="post">  
  
Name:<input type="text" name="userName"/><br/><br/>  
Password:<input type="password" name="userPass"/><br/><br/>  
Email Id:<input type="text" name="userEmail"/><br/><br/>  
Country:  
<select name="userCountry">  
<option>India</option>  
<option>Pakistan</option>  
<option>other</option>  
</select>  
  
<br/><br/>  
<input type="submit" value="register"/>  
  
</form>  
</body>  
</html>

2. RegisterServlet.java

import java.io.*;  
import java.sql.*;  
import javax.servlet.ServletException;  
import javax.servlet.http.*;  
  
public class Register extends HttpServlet {  
public void doPost(HttpServletRequest request, HttpServletResponse response)  
throws ServletException, IOException {  
  
response.setContentType("text/html");  
PrintWriter out = response.getWriter();  
  
String n=request.getParameter("userName");  
String p=request.getParameter("userPass");  
String e=request.getParameter("userEmail");  
String c=request.getParameter("userCountry");  
  
try{  
Class.forName("oracle.jdbc.driver.OracleDriver");  
Connection con=DriverManager.getConnection(  
"jdbc:oracle:thin:@localhost:1521:xe","system","oracle");  
  
PreparedStatement ps=con.prepareStatement(  
"insert into registeruser values(?,?,?,?)");  
  
ps.setString(1,n);  
ps.setString(2,p);  
ps.setString(3,e);  
ps.setString(4,c);  
  
int i=ps.executeUpdate();  
if(i>0)  
out.print("done...");  
  
  
}catch (Exception e2) {out.print("undone..."); System.out.println(e2);}  
  
out.close();  
}  
  
}  

Please let me know in case of any clarifications required. Thnaks!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote