Skip to content

Commit df28a6e

Browse files
committed
Updating webapp with v4 SDK sample
1 parent 8c17f2d commit df28a6e

File tree

1 file changed

+36
-22
lines changed

1 file changed

+36
-22
lines changed

articles/cosmos-db/sql-api-java-application.md

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ms.service: cosmos-db
66
ms.subservice: cosmosdb-sql
77
ms.devlang: java
88
ms.topic: tutorial
9-
ms.date: 11/05/2019
9+
ms.date: 05/12/2020
1010
ms.author: anfeldma
1111

1212
---
@@ -31,10 +31,10 @@ This Java application tutorial shows you how to create a web-based task-manageme
3131

3232
> [!TIP]
3333
> This application development tutorial assumes that you have prior experience using Java. If you are new to Java or the [prerequisite tools](#Prerequisites), we recommend downloading the complete [todo](https://github.com/Azure-Samples/documentdb-java-todo-app) project from GitHub and building it using [the instructions at the end of this article](#GetProject). Once you have it built, you can review the article to gain insight on the code in the context of the project.
34-
>
35-
>
34+
>
3635
3736
## <a id="Prerequisites"></a>Prerequisites for this Java web application tutorial
37+
3838
Before you begin this application development tutorial, you must have the following:
3939

4040
* If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
@@ -47,36 +47,48 @@ Before you begin this application development tutorial, you must have the follow
4747

4848
If you're installing these tools for the first time, coreservlets.com provides a walk-through of the installation process in the quickstart section of their [Tutorial: Installing TomCat7 and Using it with Eclipse](http://www.coreservlets.com/Apache-Tomcat-Tutorial/tomcat-7-with-eclipse.html) article.
4949

50-
## <a id="CreateDB"></a>Step 1: Create an Azure Cosmos DB account
50+
## <a id="CreateDB"></a>Create an Azure Cosmos DB account
51+
5152
Let's start by creating an Azure Cosmos DB account. If you already have an account or if you are using the Azure Cosmos DB Emulator for this tutorial, you can skip to [Step 2: Create the Java JSP application](#CreateJSP).
5253

5354
[!INCLUDE [create-dbaccount](../../includes/cosmos-db-create-dbaccount.md)]
5455

5556
[!INCLUDE [keys](../../includes/cosmos-db-keys.md)]
5657

57-
## <a id="CreateJSP"></a>Step 2: Create the Java JSP application
58+
## <a id="CreateJSP"></a>Create the Java JSP application
59+
5860
To create the JSP application:
5961

6062
1. First, we'll start off by creating a Java project. Start Eclipse, then click **File**, click **New**, and then click **Dynamic Web Project**. If you don't see **Dynamic Web Project** listed as an available project, do the following: click **File**, click **New**, click **Project**…, expand **Web**, click **Dynamic Web Project**, and click **Next**.
6163

6264
![JSP Java Application Development](./media/sql-api-java-application/image10.png)
63-
2. Enter a project name in the **Project name** box, and in the **Target Runtime** drop-down menu, optionally select a value (e.g. Apache Tomcat v7.0), and then click **Finish**. Selecting a target runtime enables you to run your project locally through Eclipse.
64-
3. In Eclipse, in the Project Explorer view, expand your project. Right-click **WebContent**, click **New**, and then click **JSP File**.
65-
4. In the **New JSP File** dialog box, name the file **index.jsp**. Keep the parent folder as **WebContent**, as shown in the following illustration, and then click **Next**.
65+
66+
1. Enter a project name in the **Project name** box, and in the **Target Runtime** drop-down menu, optionally select a value (e.g. Apache Tomcat v7.0), and then click **Finish**. Selecting a target runtime enables you to run your project locally through Eclipse.
67+
68+
1. In Eclipse, in the Project Explorer view, expand your project. Right-click **WebContent**, click **New**, and then click **JSP File**.
69+
70+
1. In the **New JSP File** dialog box, name the file **index.jsp**. Keep the parent folder as **WebContent**, as shown in the following illustration, and then click **Next**.
6671

6772
![Make a New JSP File - Java Web Application Tutorial](./media/sql-api-java-application/image11.png)
68-
5. In the **Select JSP Template** dialog box, for the purpose of this tutorial select **New JSP File (html)**, and then click **Finish**.
69-
6. When the index.jsp file opens in Eclipse, add text to display **Hello World!** within the existing `<body>` element. The updated `<body>` content should look like the following code:
70-
71-
<body>
72-
<% out.println("Hello World!"); %>
73-
</body>
74-
7. Save the index.jsp file.
75-
8. If you set a target runtime in step 2, you can click **Project** and then **Run** to run your JSP application locally:
76-
77-
![Hello World – Java Application Tutorial](./media/sql-api-java-application/image12.png)
7873

79-
## <a id="InstallSDK"></a>Step 3: Install the SQL Java SDK
74+
1. In the **Select JSP Template** dialog box, for the purpose of this tutorial select **New JSP File (html)**, and then click **Finish**.
75+
76+
1. When the index.jsp file opens in Eclipse, add text to display **Hello World!** within the existing `<body>` element. The updated `<body>` content should look like the following code:
77+
78+
```html
79+
<body>
80+
<% out.println("Hello World!"); %>
81+
</body>
82+
```
83+
84+
1. Save the index.jsp file.
85+
86+
1. If you set a target runtime in step 2, you can click **Project** and then **Run** to run your JSP application locally:
87+
88+
![Hello World – Java Application Tutorial](./media/sql-api-java-application/image12.png)
89+
90+
## <a id="InstallSDK"></a>Install the SQL Java SDK
91+
8092
The easiest way to pull in the SQL Java SDK and its dependencies is through [Apache Maven](https://maven.apache.org/).
8193

8294
To do this, you will need to convert your project to a maven project by completing the following steps:
@@ -104,7 +116,8 @@ To do this, you will need to convert your project to a maven project by completi
104116
6. Click **OK** and Maven will install the SQL Java SDK.
105117
7. Save the pom.xml file.
106118

107-
## <a id="UseService"></a>Step 4: Using the Azure Cosmos DB service in a Java application
119+
## <a id="UseService"></a>Using the Azure Cosmos DB service in a Java application
120+
108121
1. First, let's define the TodoItem object in TodoItem.java:
109122

110123
@Data
@@ -338,7 +351,7 @@ To do this, you will need to convert your project to a maven project by completi
338351
return true;
339352
}
340353

341-
## <a id="Wire"></a>Step 5: Wiring the rest of the of Java application development project together
354+
## <a id="Wire"></a>Wiring the rest of the of Java application development project together
342355
Now that we've finished the fun bits - all that's left is to build a quick user interface and wire it up to our DAO.
343356

344357
1. First, let's start with building a controller to call our DAO:
@@ -710,7 +723,7 @@ Now that we've finished the fun bits - all that's left is to build a quick user
710723
5. Awesome! Now all that's left is to test the application. Run the application locally, and add some Todo items by filling in the item name and category and clicking **Add Task**.
711724
6. Once the item appears, you can update whether it's complete by toggling the checkbox and clicking **Update Tasks**.
712725

713-
## <a id="Deploy"></a>Step 6: Deploy your Java application to Azure Web Sites
726+
## <a id="Deploy"></a>Deploy your Java application to Azure Web Sites
714727
Azure Web Sites makes deploying Java applications as simple as exporting your application as a WAR file and either uploading it via source control (e.g. Git) or FTP.
715728

716729
1. To export your application as a WAR file, right-click on your project in **Project Explorer**, click **Export**, and then click **WAR File**.
@@ -750,3 +763,4 @@ All the samples in this tutorial are included in the [todo](https://github.com/A
750763
21. In a browser, navigate to `http://localhost:8080/azure-documentdb-java-sample/` and start adding to your task list. Note that if you changed your default port values, change 8080 to the value you selected.
751764
22. To deploy your project to an Azure web site, see [Step 6. Deploy your application to Azure Web Sites](#Deploy).
752765

766+
## Next steps

0 commit comments

Comments
 (0)