A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.oracle.com/javaee/7/tutorial/jsonp006.htm below:

19.6 The jsonpmodel Example Application

Java Platform, Enterprise Edition: The Java EE Tutorial

19.6 The jsonpmodel Example Application

This section describes how to build and run the jsonpmodel example application. This example is a web application that demonstrates how to create an object model from form data, how to parse JSON data, and how write JSON data using the object model API.

The jsonpmodel example application is in the tut-install/examples/web/jsonp/jsonpmodel directory.

19.6.1 Components of the jsonpmodel Example Application

The jsonpmodel example application contains the following files.

The code used in ObjectModelBean.java to create an object model from the data in the form is similar to the example in Creating an Object Model from Application Code. The code to write JSON output from the model is similar to the example in Writing an Object Model to a Stream. The code to navigate the object model tree is similar to the example in Navigating an Object Model.

19.6.2 Running the jsonpmodel Example Application

This section describes how to run the jsonpmodel example application using NetBeans IDE and from the command line.

19.6.2.1 To Run the jsonpmodel Example Application Using NetBeans IDE
  1. Make sure that GlassFish Server has been started (see Starting and Stopping GlassFish Server).

  2. From the File menu, choose Open Project.

  3. In the Open Project dialog box, navigate to:

    tut-install/examples/web/jsonp
    
  4. Select the jsonpmodel folder.

  5. Click Open Project.

  6. In the Projects tab, right-click the jsonpmodel project and select Run.

    This command builds and packages the application into a WAR file (jsonpmodel.war) located in the target directory, deploys it to the server, and opens a web browser window with the following URL:

    http://localhost:8080/jsonpmodel/
    
  7. Edit the data on the page and click Create a JSON Object to submit the form. The following page shows a JSON object that contains the data from the form.

  8. Click Parse JSON. The following page contains a table that lists the nodes of the object model tree.

19.6.2.2 To Run the jsonpmodel Example Application Using Maven
  1. Make sure that GlassFish Server has been started (see Starting and Stopping GlassFish Server).

  2. In a terminal window, go to:

    tut-install/examples/web/jsonp/jsonpmodel
    
  3. Enter the following command to deploy the application:

    mvn install
    
  4. Open a web browser window and enter the following address:

    http://localhost:8080/jsonpmodel/
    
  5. Edit the data on the page and click Create a JSON Object to submit the form. The following page shows a JSON object that contains the data from the form.

  6. Click Parse JSON. The following page contains a table that lists the nodes of the object model tree.

Table of Contents Java Platform, Enterprise Edition: The Java EE TutorialExpand

|

Collapse

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.3