Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The main new functionality in this lab is building on what you learned in the last lab. 1. SUMMARY a. You will have two jsp

The main new functionality in this lab is building on what you learned in the last lab.

1. SUMMARY

a.

You will have two jsp pages, one that submits user entries to the other. You will also have a regular

Java class that provides methods for the second JSP page to access.

b. This lab will involve the following new features:

i. Incorporating external Java classes into a web app.

ii. Handling submitted Request values in a separate JSP page.

2. DETAILS

Alrighty... More web app Development!

This week, were going to expand our HTML a bit, and were going to expand our Java out to two pages. Were

also going to make a class and use it in our web pages.

Youll learn how to:

1. Import and use external classes in JSP pages and Tomcat.

2. Submit form data from one JSP page to another.

3. Perform basic formatting of HTML pages using tables.

So were going to make a simple Movie Fan registration site. This is what were going to make:

1. A home registration page.

a.

This page will have first/last name fields to fill out along with favorite movie and actor.

b. This information will be in an HTML form, as you did last week; but this time the form will be

submitting the information to our registration confirmation page.

2. A registration confirmation page.

a.

This page will instantiate a class you will create called FavoritesManager, and call methods on

that class that will compare the users submitted favorites against yours (which youll put into

the class when you code it).

3. A new java class.

a.

This class will have two methods that will check the users favorites against yours.

i. checkFavoriteMovie.

ii. checkFavoriteActor.

b. This class/object is being used by another object (in this case, our compiled JSP page that

becomes a servlet, which is a standard java class/object), so for that reason, we dont have

any beginning method such as init or main.

These are the

three files

youll be turning in.

So now Im going to take you through the details... follow along carefully.

confirm.jsp

a.

I have put the template for this file in the same place as the other files.

b. Put this file in the same place as the register.jsp file above.

c.

Look for the ##### signs for guidance/notes on where you need to add code and what you

need to do

.

d. NOTE: Youll see that Im having you declare a variable and instantiate an object of

FavoritesManager class type, which is the .class file you just added to the web app folder

structure. This line of code is exactly like the other times when weve instantiated a class.

Youll also notice that your external class is imported up at the top of the file, and youll also

notice that the moviefan folder is referenced in that import.

Time to Test. Make sure Tomcats running (stop and restart if already running) and open your browser, and

navigate to your page just like you did last week. Only now, youre editing the url to point to register.jsp.

You should be able to submit values and see the results on the second page. Be patient with the debugging

and work through it. If you have any stumpers, post it to the open dboard or e-mail me.

If you adjust your code in the .class file and build it to make a new .class file, then you will need to restart

Tomcat to see the changes.

Confirm.jsp:

<%@ page import="moviefan.FavoritesManager"%>

<%

//#####################################################################################

//###### Your java code here to declare and instantiate FavoritesManager object. ######

//###### You will be using this variable in the "if" statements lower down. ######

%>

back to Registration page

Welcome,

<%//#################################################################

//###### Your java code here to combine first with last name.######

//###### Don't forget to put a space between first and last. ######

//###### I've given you the first part of the line... ######

//###### (in other words, replace the three periods) ######%>

<%= request.getParameter("firstname") + ... %>

Your favorite movie (<%=request.getParameter("movie")%>)

<%

//#####################################################

//###### Your java code here to call movie check ######

//###step 1: create a String variable and fill it with the

//request parameter called "movie" ...

//Reference the last lab for the syntax on accessing the request object

//or just look above at how we're grabbing the firstname param.

//###step 2: create an if statement.

//Inside the parentheses, not brackets, of the if statement, call

//the movie method on your external class you've created and instantiated

//up towards the top of this file.

//Your passing the string you've created above that has the movie value.

//Now, within the first set of curly brackets of the if statement, only put this line of code:

%>is my favorite movie!<%

//Then do an else statement, and within the brackets, only put this line:

%>is not my favorite movie.<%

//This space is just here for you to put the closing curly bracket of the else statement.

%>

Your favorite actor (<%=request.getParameter("actor")%>)

<%

//#####################################################

//###### Your java code here to call actor check ######

//### For this section, follow the steps up above again, only you're

//substituting actor now instead of movie.

%>

This question has 3 parts so I splited 3 questions already.

so another 2 are:

https://www.chegg.com/homework-help/questions-and-answers/1-summary--two-jsp-pages-one-submits-user-entries--also-regular-java-class-provides-method-q32617442

https://www.chegg.com/homework-help/questions-and-answers/1-summary--two-jsp-pages-one-submits-user-entries--also-regular-java-class-provides-method-q32617693

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions

Question

Why does sin 2x + cos2x =1 ?

Answered: 1 week ago

Question

What are DNA and RNA and what is the difference between them?

Answered: 1 week ago

Question

Why do living creatures die? Can it be proved that they are reborn?

Answered: 1 week ago

Question

Understand why customers are loyal to a particular service firm.

Answered: 1 week ago