In: Computer Science
Create a Web application that display an animal classification.
For the classification uses the given csv file: test1.csv
(open up the csv file in any no-code insertion text editor like:
notepad, wordpad (windows); or vi, emacs, nano, pico (Macs)
– just plain text editor NOT word processor like Word, Pages, etc).
The csv file contains information on
the types, traits, and examples of animal classification.
Give the user the following options (it can be in radio buttons) to
see the information:
1. The examples of animals in alphabetical order for each
type
2. Any oviparous animal, and
3. Which and how many are cold-blooded?
Note. Implement the application with HTML/Javascript and JSP. The
application should be treated as a client-server application.
SOLUTION :
CONSIDERING THE CONDITIONS AND REQUIREMENTS FROM THE QUESTION.
HERE
Step 1: Create a maven project in intellij idea.
Step 2: Insert the tomcat maven plugin (Optional for Intellij Idea Ultimate users)
Add the following tomcat plugin under the plugins tag in the pom.xml.
Step 3: Creating the web app
3.1 Creating the first web page
Let's create the entry HTML page for our Liquor Shop app. This will be the first page that the users will see when they visit.
Create a directory named webapp under the src/main/ and insert the following index.html file inside the webapp directory.
This page will prompt the user to select the type of liquor and submit the selection. After pressing the submit button the application will send a POST request containing the user selected type of liquor to the SelectLiquor servlet.
3.2. Creating the LiquorType enum class
We’ll use an enum class to hold the liquor types of our app. Create a LiquorType.java class inside the src/main/java/ with a package name com.sample.model.
3.3. Implementing the business logic
Then we’ll have to create a service class to hold the business logic of the app. This is a simple java class that has the required methods defined.
Create a LiquorService.java class inside the src/main/java/ with a package name com.sample
This class has the getAvailableBrands() method which will return a list of brands for the given liquor type.
3.4. Creating the Servlet Class
Next, let's create the SelectLiquorSevlet.java class that handles the user request from the HTML page.
Create a SelectLiquorServlet.java class inside the src/main/java with a package name com.sample
The SelectLiquorServlet class will accept the POST request from the form submission and invoke the doPost() method.
I have overridden the doPost() method to get the “Type” of liquor sent from the form submission done by the index.html and get the available list of brands from the getAvailableBrands() method.
There is also a similar method called doGet() that can be overridden to handle the GET requests.
NOTE : PLEASE UPVOTE ITS VERY MUCH IMPORTANT FOR ME A LOT. PLZZ......