Ask Java Expert


Home >> Java

Assignment - Using the code in the folder and continue this exercise.

Deploying Jackson with Maven

Step 1: Install Maven

1. Open Netbeans

2. Tools -> Plugins

a. If Maven is under Installed, make sure it is "Activated"

b. Else, find Maven in Available Plugins and click Install

Step 2: Convert your Netbeans project into a Maven Netbeans project

1. Create a new Maven Project (File->New Project->Maven->Java Application)

2. Copy your packages from your old project to the new project

Step 3: Add Jackson as a dependency to your Maven Netbeans project

1. Right click the Dependencies Folder

2. Search for Jackson (you may have to wait awhile as Maven loads its repos for the first time)

3. Choose jackson-annotations, jackson-core, and jackson-databind

4. Right click on your project and click build with dependencies

Step 4: Look up how to actually use Jackson!

1. Jackson's home-page

2. Main documentation page

3. Core JavaDoc page

4. If that doesn't have what you need, looking around on that github page or github.io is a good way to approach learning how to use a new project!

Exercise:

Exercise Part A: Copy the following content into a new file inside a new folder named "public" inside your NetBeans project. Name the file "index.html".

Now, add a new view to your project that loads any file with a given name from inside the "public" directory. Add a static method that checks if some file exists inside that directory. In your controller (which decides which view to serve), you already know how to serve "/ address" and "/list" URL locations. Right now, any other location results in a 404 error. Change this so that it checks, using the new view class, if a file could be served with the name given in the location. For example, if the location "/favicon.ico" is requested, we should check if we have a file "public/favicon.ico", and if so, we should create a view that serves this file. Write the view so it loads the file and serves it.

OK, Let's serve an image.

Now, let's try to do this with a "PNG" or "JPEG" image. Download an image - any image - from the web, store it in your public folder, and try to retrieve it. This may not work perfectly, or not in all browsers. Remember that the HTTP protocol demands we declare the type of data that is being sent: Content-type: text/html. Look up what to declare for PNG and change your code accordingly.

Also, remember that the way you load a text file is different from a binary file (images are binary files). You don't load those line by line. Look up how to load a binary file in Java and store it in a string. That may make your code better.

Exercise Part B: Part B will be a very simple extension / replacement of what you've already done. Ensure your webserver program has the following (some are carry-overs from previous exercises):

1. A method serializeAsJSON that, using the Jackson library, takes an AddressModel as an argument and returns an object from the Jackson library that encodes a JSON

2. A static method deserializeJSON that takes an object encoding a JSON and returns an AddressModel

3. A method serializeAsJSON that takes an AddressListModel as an argument and returns an object from the Jackson library

4. A static method deserializeJSON that takes an object from the Jackson library and returns an AddressListModel

5. A method saveJSONToFile that takes the object from the Jackson library used to encode the AddressListModel and a File object and then writes to a file for persistency

6. A method called readJSONFromFile that takes the File object and returns an AddressListModel

7. A view AddressListDataView that takes and displays the raw data of your own serialized output (i.e., the same thing that's in the text file)

8. A view AddressListJSONView that takes and displays the JSON data produced by Jackson (i.e., what you'll be writing to that text file)

9. A view AddressListTableView that takes an AddressModel and formats it into a table.

Attachment:- Assignment Files.rar

Java, Programming

  • Category:- Java
  • Reference No.:- M92677072
  • Price:- $80

Guranteed 48 Hours Delivery, In Price:- $80

Have any Question?


Related Questions in Java

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As