Skip to Content

End-to-End Weather App Scenario Part 1

By akula86

Create a basic Java app in SAP HANA Cloud Platform

You will learn

In this tutorial series you will start from zero and develop a fully operational weather application. In total there are 10 parts to the series, each building on top of its predecessor. The entire source code of both the final and all intermediate parts are available on GitHub.


The constituent parts of this tutorial series cover the following:

  • How to create a simple web application on HCP
  • How to apply authentication and authorization
  • How to expose business functionality as an external RESTful API
  • How to add JPA-based persistence to your web app
  • How to leverage the multi-tenancy features of SAP HANA Cloud Platform
  • How to use the connectivity service to consume external services
  • How to add a mobile-friendly UI5-based user interface to the web application

In Part 1, you will develop a basic Java app to ensure that both Eclipse IDE and the local SAP HANA Cloud Platform (HCP) tooling have been properly installed and configured.

  1. Create a new dynamic web project by selecting the File > New > Dynamic Web Project menu entry and enter the following information:

    • Name: weatherapp
    • Target Runtime: Java Web
    • Dynamic Web Module Version: 2.5

    Click on Next

    Creating a new dynamic web project
  2. Remove the standard src Source folder and add a new one called src/main/java to create a project that adheres to the standard Maven Directory Layout.

    Change the default output folder to target/classes

    Click on Next.

    Configuring java project
  3. Change the Content Directory from WebContent to src/main/webapp (again, to adhere to Maven conventions)

    Click on Finish.

    specifying output directory to comply with Maven conventions
  4. Make sure you have your weatherapp project folder selected, and then create a new Servlet by selecting the File > New > Servlet menu entry and enter the following information:

    • Package name:
    • Class name: HelloWorldServlet

    Click on Next.

    Creating a new servlet
  5. Change the URL Mapping from /HelloWorldServlet to /hello to make it a bit easier to memorize.

    Click on Finish and the file will open in the editor.

    Changing the Servlet URL mapping
  6. Now we need to do our first bit of coding. Navigate to the servlet’s doGet() method and replace the TODO comment with the following line of code and save your changes:

    response.getWriter().println("Hello World!");
    Modifying the doGet() method
  7. Deploy the application to your local server by using the Run as > Run on Server context menu of the HelloWorldServlet node in the Project Explorer view.

  8. Choose the Manually define a new Server option and select the SAP / Java Web Server option from the server selection. Make sure to select Java Web as the server runtime environment.

    Click on Finish. The internal browser is now started and displays the traditional message marking the first step into a new programmer’s journey.

    Creating a new local Java Server to run your app

Next Steps

Updated 01/16/2017

Time to Complete

10 min




Back to top