Honda CBR 600RR Forum banner

1 - 8 of 8 Posts

·
Registered
Joined
·
82 Posts
Discussion Starter #1
I am currently taking a class and I am having a really hard time learning the subject material. I have a huge homework assignment due and I can't figure it out for the life of me. (working on it for over 10 hours)

I need help completing the assignment below:

You are required to create:

-a JavaBean class
o 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)

- a HTML Form that lets users enter class data
o 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)


- a Servlet class that processes form inputs
o Servlet: Create a Servlet class to handle form inputs. It should get parameters from the form and then use them to create an instance of the JavaBean. It shouldrecord 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 to the session and forward the request and response to the JSP. (4 points)


- 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.)
o 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)


*** I'm really good at creating the form but I am completely lost when it comes to the servlet, jsp, and javaBean. :crying::dontknow:


Any help would be greatly appreciated
 

·
Beer: does the body good
Joined
·
682 Posts
When is your assignment due? I would recommend checking out this tutorial. It will walk you through the a very basic example. Once you have it working you can modify it to add the additional HTML format elements. Look at th e servlet introduction for Hello world

http://www.simplecodestuffs.com/servlet-jsp-tutorial-beginners/

I'm do Java development for a living. Comment if you get stuck.

Sent from my HTC One M9
 
  • Like
Reactions: CBRicky

·
Beer: does the body good
Joined
·
682 Posts
Think of an example like this. Your jsp with form elements will have input boxes that will all you to enter your mailing address (full name, address, state, postal code) with a submit button. The submit button is going to sent the entered values in the request to the servlet. You will want to get the names of the values of the input boxes And assign them to you Java bean. A Java bean is nothing more then a Java pogo or Java object. This can be a mailing address with those elements as the attributes with getters and setters, yes your constructors to set the elements.

Use that objects and set the values in the results page.

Sent from my HTC One M9
 
  • Like
Reactions: CBRicky

·
Registered
Joined
·
82 Posts
Discussion Starter #5 (Edited)
whats the name of this class?
Whats your major?

java - What is a javabean? - Stack Overflow
JSP JavaBeans

Hope that helps ^^^^
I never heard of JavaBeans, but i took java recently and HTML a while ago ...
When is your assignment due? I would recommend checking out this tutorial. It will walk you through the a very basic example. Once you have it working you can modify it to add the additional HTML format elements. Look at th e servlet introduction for Hello world

Servlet & JSP Tutorial for beginners|SimpleCodeStuffs

I'm do Java development for a living. Comment if you get stuck.

Sent from my HTC One M9
Think of an example like this. Your jsp with form elements will have input boxes that will all you to enter your mailing address (full name, address, state, postal code) with a submit button. The submit button is going to sent the entered values in the request to the servlet. You will want to get the names of the values of the input boxes And assign them to you Java bean. A Java bean is nothing more then a Java pogo or Java object. This can be a mailing address with those elements as the attributes with getters and setters, yes your constructors to set the elements.

Use that objects and set the values in the results page.

Sent from my HTC One M9
Thank you all for the responses! I am a computer information systems major. I really appreciate the responses.

My assignment is due this Sunday 4/17/16

Sofar the HTML form that I completed is asking for First name, Last name as a text field

Motorcycle Type (Honda, Kawasaki, Suzuki, Yamaha) as a drop down box

Phone number as a text field

and gender as a radio button
 

·
Registered
Joined
·
82 Posts
Discussion Starter #6
Think of an example like this. Your jsp with form elements will have input boxes that will all you to enter your mailing address (full name, address, state, postal code) with a submit button. The submit button is going to sent the entered values in the request to the servlet. You will want to get the names of the values of the input boxes And assign them to you Java bean. A Java bean is nothing more then a Java pogo or Java object. This can be a mailing address with those elements as the attributes with getters and setters, yes your constructors to set the elements.

Use that objects and set the values in the results page.

Sent from my HTC One M9
I'm not able because of the assignment requirement to make a JSP with form elements. My form must be a separate HTML form and pass that through the JSP. By the end of my homework assignment I'm suppose to have a JSP, Servlet, Javabean, HTML form.

My professor also wanted us to not mess with the doGet / doPost methods in the Servlet and just use the processRequest method to call the doGet and doPost
 

·
Beer: does the body good
Joined
·
682 Posts
so your bean would look something like this.

package com.somecompany;

public class testclass {
private String firstName;
private String lastName;
private String motorcycleType;
private String telephoneNumber; //or Long if you dont' care about free form text.

public testclass() {
}

public testclass(String firstName, String lastName, String motorcycleType,
String telephoneNumber) {
super();
this.firstName = firstName;
this.lastName = lastName;
this.motorcycleType = motorcycleType;
this.telephoneNumber = telephoneNumber;
}

/**
* @return the firstName
*/
public String getFirstName() {
return firstName;
}

/**
* @param firstName the firstName to set
*/
public void setFirstName(String firstName) {
this.firstName = firstName;
}
/**
* @return the lastName
*/
public String getLastName() {
return lastName;
}
/**
* @param lastName the lastName to set
*/
public void setLastName(String lastName) {
this.lastName = lastName;
}
/**
* @return the motorcycleType
*/
public String getMotorcycleType() {
return motorcycleType;
}
/**
* @param motorcycleType the motorcycleType to set
*/
public void setMotorcycleType(String motorcycleType) {
this.motorcycleType = motorcycleType;
}
/**
* @return the telephoneNumber
*/
public String getTelephoneNumber() {
return telephoneNumber;
}
/**
* @param telephoneNumber the telephoneNumber to set
*/
public void setTelephoneNumber(String telephoneNumber) {
this.telephoneNumber = telephoneNumber;
}

}
 
  • Like
Reactions: CBRicky
1 - 8 of 8 Posts
Top