Question: In NetBeans create a new Java Web/Web Application project with the name Module 2 Milestone and the context path /store. If you do not have
In NetBeans create a new "Java Web"/"Web Application" project with the name "Module 2 Milestone" and the context path "/store".
If you do not have a "Java Web" option then you need to install the Java Enterprise Edition plugin ("Tools" -> "Plugins" -> "Available Plugins", select "Java EE Base"). Note that installing this plugin will actually install a series of dependent plugins, so it can take some time.
Before you can finish creating your project you will need to add a Server (web server) to your NetBeans installation. Click "Add" next to the Server selector, select "GlassFish Server", check the license agreement checkbox and "Download Now...". After finishing setting up the server you should now be able to finish creating your Web Application.
Copy all of the source code from your Module 1 Project in to your Module 2 Milestone. You will also need to include the citp290-file-util.jar again.
Create a class named "InventoryServlet" which extends HttpServlet. Override the two following methods:
doGet should get the Product list from the InventoryManager and print each product as part of an HTML String to the response PrintWriter. You may format your HTML however you like. Examples will be provided by the instructor.
A doPost should receive the request parameters "upc", "shortDetails", "longDetails", "price", and "stock" and use them to create a new Product. Add the Product to the file using the InventoryManager.
On the line above your InventoryServlet class declaration add the annotation "@WebServlet(name = "InventoryServlet", urlPatterns = {"/inventory"})". This controls the URL where your servlet's webpage is located.
In your project's Web Pages folder create an HTML file (right-click, "New", "HTML") named "inventoryForm.html" which contains an HTML form with the "upc", "shortDetails", "longDetails", "price", and "stock" fields as well as a submit button which will submit those fields to your ContactServlet using POST. An example will be provided by the instructor.
You should be able to view your list of products by running your application and going to http://localhost:8080/store/inventory in a web browser on your computer. You should be able to view and use the form for adding products by going to http://localhost:8080/store/inventoryForm.html
Note that when you build a Java Web Application in NetBeans it will generate a ".war" file instead of a ".jar" file. They are very similar, with the main difference that .wars can also contain web page files (html, css, etc.) and can be deployed to Java web servers.
I have the source code here: http://www.chegg.com/homework-help/questions-and-answers/started-need-help-finishing-last-steps-create-class-named-inventoryservlet-extends-httpser-q10459145
Go to product class and use those classes. Let me know if you need anyhting else. I have the code for the storageutility file too.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
