Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
Showing results for 
Search instead for 
Did you mean: 
You may have heard recently that we announced the readiness of the SAP Web IDE Full-Stack version, and that we recommend migrating your projects to it from the former version of SAP Web IDE.

This is great news because SAP Web IDE Full-Stack contains new and exciting capabilities, one of them being Java development.

In this blog series, I will show you how to develop a simple Java servlet in SAP Web IDE Full-Stack, covering all aspects of the software development lifecycle.

This blog describes the steps necessary to Develop a simple "Hello World" servlet which produces a WAR file containing a basic "Hello World" application.

The life-cycle continues in Part 2, where you will learn how easy it is to Build and Test the generated application.

Finally, in Part 3 I will describe how to Run and Debug the application. I will also show you our new Hot Deployment feature.

Let's get started!



Let’s start by creating a new MTA project with a Java module.
MTA stands for Multi-Target-Application and it is SAP’s approach for developing full-stack applications that can be comprised by various modules.
One of the big advantages of MTA is the one, common lifecycle of the app.
Please refer to this SAP document for more information.

  1. Create an MTA project by clicking File→New→Project from Template

  2. Select Multi-Target Application and click Next

  3. Name the project mtaproj, and then click Next and FinishNow, let's create a Java module.
    A Java module is a collection of related Java files and service definitions.
    Java modules implement the business logic of your application.
    A Java module can be packaged either as a Java Web Archive (WAR) or a Java Archive (JAR) built with Apache Maven.

  4. Right-click the project you just created and select New→Java Module.
    SAP Web IDE Full-Stack provides several Java module types depending on your application needs.
    For more information on the available types, see Developing Java Modules.

  5. Select the Simple Web Application template and then click Next

  6. Enter web as the module name, and click Next

  7. Enter Group ID, Artifact ID and Package, or just use the default values, then click Finish.

A new web folder is generated under your mtaproj project. The folder represents a simple web application with a standard Maven directory layout. It also contains a file representing a sample HTTP Servlet which writes "Hello World" as its output.

You can also add your own Java Class, Enum or Interface by right-clicking any sub-folder under the Java Module.

Let's extend our auto generated Servlet code to also print out the HTTP response status.
The SAP Web IDE Full-Stack code editor includes our Code Completion feature.
This is how it works:

  1. Open the java file.

  2. Jump to line 28 and start typing "int iStatus = response.set".

  3. Press <CTRL>+<Space>.
    A popup showing all the available Java method of type HttpservletResponse is displayed.

  4. Hover over the first option – setStatus(int sc, String..).
    A detailed description of the function is displayed.

  5. Select the first option and complete the line - setStatus();

    • The editor now displays syntax errors because we did not provide the relevant parameters for our new method.

    • We can see more detailed information regarding the error by opening the Problems view. Learn more about the Problems view.

  6. Click on the Problems view button on the right-side pane. The error from line 28 is displayed

  7. We can fix the error quickly using the Autofix

    • Right-click on the first line and select the first option – Change to 'getStatus(..)'

    • Line 28 of the file is updated to response.getStatus();

  8. A new warning message appears stating that the iStatus variable is not used

  9. To fix that we add a new line after line 36: writer.write("\n\nStatus is: " + iStatus);

  10. This adds also the response status to our application's output.



We have created a new MTA project with a Java module containing an HTTP Servlet application.
We have also started to edit the code using the code editor and fixed it using the Problems view and Autofix features.

In our next part of the series, we will compile our web Java Module by using the Build option.







1 Comment