Hello Java experts! I need help creating a project in NetBeans (or any Java IDE)
ID: 3699874 • Letter: H
Question
Hello Java experts! I need help creating a project in NetBeans (or any Java IDE) that follows these very loose requirements:
As you can see, the requirements are extremely broad. Please help me create something that follows these requirements!
HW5 FORM, JavaBean, Servlet & JSP (9 points) Instructions: This homework assesses your knowledge of the MVC model. You are required to create a JavaBean class, a HTML Form that lets users enter class data, a Servlet class that processes form inputs, and a JSP that receives processing results from the Servlet and display them back to users. (You can refer to the examples we did in class and in the textbook.) JavaBean class: Create a Java class in a package under the Source Packages folder. This Java class should qualify as a JavaBean class, i.e., meet all the JavaBean requirements. It should have at least 2 Constructors, 4 private data fields, including one boolean type, and their corresponding get and set methods. Note: you CANNOT use the User bean from the book. (2 points) HTML Form: Create an html page that contains a Form that let users enter the data field values for the JavaBean class The form action should request a Servlet class (using the Servlet's URL pattern). (1 point Servlet: Create a Servlet class to handle the form inputs. It should get parameters from the form and then use them to create an instance of the JavaBean. It should record the JavaBean data field values in a .txt file in the WEB-INF folder with one record per line. After that, it should add the JavaBean instance as an attribute of the session and forward the request and response to the JSP. (4 points) JSP: Create a JSP page to display processing results sent by the Servlet. You can use JSP standard tags or JSP Expression Language. (Please refer to the text book and slides for details on JSP standard tags and JSP Expression Language.) (2 points) This HW is worth 9 points. Please check Canvas for the rubric.Explanation / Answer
As per your requirement the below one is solution please follow it step by step
registration.html : ----------------------->>>>>>>>>>>>>>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Registration</title>
</head>
<body>
<div>
<div>
<div>
<b><font>
Register Student
</font></b></div>
<div>
<form method="post" action="RegistrationServer_1">
<p>
<label>Name : -</label> <input type="text" name="name"></p>
<p>
<label>Sex : -</label> <input type="text" name="sex"style="float:right"></p>
<p>
<label>Guardian Name : -</label> <input type="text" name="gname"></p>
<p>
<label>Permanent Address : -</label> <input type="text" name="padd"></p>
<p>
<label>Guardian Address : -</label> <input type="text" name="gadd"></p>
<p>
<label>Student Number : -</label> <input type="text" name="sno"></p>
<p>
<label>Guardian Number : -</label> <input type="text" name="gno"></p>
<p>
<label>Food Type : -</label> <input type="text" name="food"></p>
<p>
<label>Password : -</label> <input type="text" name="pass"></p>
<p><input type="submit" name="submit" value="Register"></p>
</form>
</div>
</div>
</div>
</body>
</html>
RegistrationServer_1.java :--------------------------->>>>>>>>>>>>>>>>
package src;
import java.io.IOException;
//import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import beans.StudentBean;
/**
* Servlet implementation class RegistrationServer_1
*/
@WebServlet("/RegistrationServer_1")
public class RegistrationServer_1 extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public RegistrationServer_1() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.setContentType("text/html;charset=UTF-8");
HttpSession sessionactual=request.getSession(false);
String NAME=request.getParameter("name").toString().toUpperCase();
String SEX=request.getParameter("sex").toString().toUpperCase();
String GNAME=request.getParameter("gname").toString().toUpperCase();
String ADDRESS=request.getParameter("padd").toString().toUpperCase();
String GNUMBER=request.getParameter("gno").toString();
String CONTACT=request.getParameter("sno").toString();
String DETAILS=request.getParameter("gadd").toString().toUpperCase();
String FOODTYPE=request.getParameter("food").toString().toUpperCase();
String PASSWORD=request.getParameter("pass").toString();
StudentBean sb=new StudentBean();
sb.setNAME(NAME);
sb.setSEX(SEX);
sb.setGUARDIAN_NAME(GNAME);
sb.setGUARDIAN_NO(GNUMBER);
sb.setMOBILE_NUMBER(CONTACT);
sb.setPERMANENT_ADDRESS(ADDRESS);
sb.setFOOD_TYPE(FOODTYPE);
sb.setLOCAL_GUARDIAN_DETAILS(DETAILS);
sb.setPASSWORD(PASSWORD);
sb.register();
int REG_ID = sb.getREG_ID();
sessionactual.setAttribute("reg_id",REG_ID);
sessionactual.setAttribute("msg", "Registration successfull your registration id = ");
response.sendRedirect("status.jsp");
}
}
StudentBean.java :-------------------->>>>>>>>>>>>>>>>>>>
package src;
import java.io.*;
import java.util.Random;
public class StudentBean {
//variable declaration
int REG_ID;
String PASSWORD; //VARCHAR2(10)
String NAME ; // VARCHAR2(30)
String GUARDIAN_NAME; //VARCHAR2(30)
String GUARDIAN_NO; //NUMBER(10)
String PERMANENT_ADDRESS ; // VARCHAR2(200)
String MOBILE_NUMBER; //NUMBER(10)
String LOCAL_GUARDIAN_DETAILS; //VARCHAR2(200)
String FOOD_TYPE; //VARCHAR2(6)
String SEX;
boolean check=false;
Random rand;
//constructor
public StudentBean(){}
//getter setter methods
public String getSEX() { return SEX; }
public void setSEX(String SEX) { this.SEX = SEX; }
public String getNAME() { return NAME; }
public void setNAME(String NAME) { this.NAME = NAME; }
public String getGUARDIAN_NAME() { return GUARDIAN_NAME; }
public void setGUARDIAN_NAME(String GUARDIAN_NAME) { this.GUARDIAN_NAME = GUARDIAN_NAME; }
public String getGUARDIAN_NO() { return GUARDIAN_NO; }
public void setGUARDIAN_NO(String GUARDIAN_NO) { this.GUARDIAN_NO = GUARDIAN_NO; }
public String getMOBILE_NUMBER() { return MOBILE_NUMBER; }
public void setMOBILE_NUMBER(String MOBILE_NUMBER) { this.MOBILE_NUMBER = MOBILE_NUMBER; }
public String getPERMANENT_ADDRESS() { return PERMANENT_ADDRESS; }
public void setPERMANENT_ADDRESS(String PERMANENT_ADDRESS) { this.PERMANENT_ADDRESS = PERMANENT_ADDRESS; }
public String getLOCAL_GUARDIAN_DETAILS() { return LOCAL_GUARDIAN_DETAILS; }
public void setLOCAL_GUARDIAN_DETAILS(String LOCAL_GUARDIAN_DETAILS) { this.LOCAL_GUARDIAN_DETAILS = LOCAL_GUARDIAN_DETAILS; }
public String getFOOD_TYPE() { return FOOD_TYPE; }
public void setFOOD_TYPE(String FOOD_TYPE) { this.FOOD_TYPE = FOOD_TYPE; }
public boolean getCheck() { return check; }
public void setCheck(int check) { this.check = check; }
public void setRs(ResultSet rs) { this.rs = rs; }
public int getREG_ID() { return REG_ID; }
public void setREG_ID(int REG_ID) { this.REG_ID = REG_ID; }
public String getPASSWORD() { return PASSWORD; }
public void setPASSWORD(String PASSWORD) { this.PASSWORD = PASSWORD; }
//business methods
public void register() {
try{
REG_ID = rand.nextInt((1000 - 1) + 1) + 1;
File file = new File ("file.txt");
FileWriter fw = new FileWriter(file,true);
BufferedWriter bw = new BufferedWriter(fw);
PrintWriter out = new PrintWriter (bw);
out.println(REG_ID+" "+NAME+" "+GUARDIAN_NAME+" "+GUARDIAN_NO+" "+PERMANENT_ADDRESS+" "+MOBILE_NUMBER+" "+LOCAL_GUARDIAN_DETAILS+" "+FOOD_TYPE+" "+SEX+" "+PASSWORD);
check = true;
}catch(Exception e){ e.printStackTrace(); }
}
}
status.jsp : ------------------>>>>>>>>>>>>.
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%!
int reg;
String msg;
%>
<%
msg=session.getAttribute("msg").toString();
reg = Integer.parseInt(session.getAttribute("reg_id").toString());
%>
<div></div>
<div>
<%=msg%><%=reg%>
</div>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.