Apache Http Server Java Example

  
  1. Apache Http Server Java Example Code
  2. What Is An Apache Server

The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows. The goal of this project is to provide a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards. Apache HTTP Server 2.4.46 (httpd): 2.4.46 is the latest available version 2020-08-07.

Introduction

To integrate ONLYOFFICE online editors into your own website on Java you need to download and install ONLYOFFICE editors on your local server and use the Java Example for their integration.

You can choose any appropriate way how to run the Java example code. We will show how to run the Java code using the Apache Tomcat web server on Windows OS and Linux OS.

The integration examples are used to demonstrate document editors functions and the ways to connect Document Server to your own application. DO NOT USE these examples on your own server without PROPER CODE MODIFICATIONS!

This guide will show you the sequence of actions to integrate the editors successfully.

Running the example on Windows OS

Step 1. Download and Install Document Server

First, download the ONLYOFFICE Editors (the ONLYOFFICE Document Server).

See the detailed guide to learn how to install Document Server for Windows.

Step 2. Download the Java code for the editors integration

Download the Java example from our site.

You need to connnect the editors to your web site. For that specify the path to the editors installation in the srcmainresourcessettings.properties file:

Http

where the documentserver is the name of the server with the ONLYOFFICE Document Server installed.

If you want to experiment with the editor configuration, modify the parameters it the srcmainwebappeditor.jsp file.

Step 3. Install the prerequisites

To run the Java example code you will need to install the Java version appropriate for your OS and web server Apache Tomcat:

  • Java (download from the Oracle official web site);
  • Apache Tomcat (download from the official website).

Step 4. Running Apache Tomcat

  1. After you have installed Java in Windows, you must set the JAVA_HOME environment variable to point to the Java installation directory.

    Find out where Java is installed. If you didn't change the path during installation, it will be something like this:

    In Windows 7 right click My Computer and select Properties, then click Advanced.

    In Windows 8 go to Control Panel ->System ->Advanced System Settings.

    Click the Environment Variables button.

    Under System Variables, click New.

    In the Variable Name field, enter:

    JAVA_HOME if you installed the JDK (Java Development Kit) or JRE_HOME if you installed the JRE (Java Runtime Environment).

    In the Variable Value field, enter your JDK or JRE installation path, for example C:Program FilesJavajdk1.8.0_65.

    Check if the variable created successfully by echo command in the Command Prompt:

  2. Run the Command Prompt. Change the current directory for the Apache Tomcat installation directory:

  3. Use the bin startup.bat script to start Apache Tomcat:

    You will see the new Tomcat console window displayed that provides the information and mesages about Tomcat startup:

    Test your Tomcat installation using the address in a web browser:

    If everything is correct, you will see the Tomcat web page in the browser as shown below.

Step 5 . Running the Java code

  1. Open Tomcat Web Application Manager by clicking Manager App:

  2. Tomcat Web Application Manager will request the username and the password:

    For that you will need to specify user data in tomcat-users.xml file in the Apache Tomcat installation folder. Define the manager-gui user role, specify the user name and password values:

  3. Upload the Java project in Tomcat Web Application Manager. For that click Choose File in the WAR file to deploy section and find the .war file in the Java project folder, then click Deploy.

  4. You will see the project in the Application List:

  5. Click the link with the application name to run it.

Step 6. Checking accessibility

In case the example and Document Server are installed on different computers, make sure that your server with the example installed has access to the Document Server with the address which you specify instead of documentserver in the configuration files. And you must also make sure that the Document Server in its turn has access to the server with the example installed with the address which you specify instead of example.com in the configuration files.

If you integrated the editors successfully the result should look like the demo preview on our site.

Running the example on Linux OS

Step 1. Download and Install Document Server

First, download the ONLYOFFICE Editors (the ONLYOFFICE Document Server).

See the detailed guide to learn how to install Document Server for Linux.

Apache Http Server Java Example Code

Step 2. Install the prerequisites and run the web site with the editors

  1. Install Java: sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java8-installer
  2. Download the archive with the Java example and unpack the archive: wget https://api.onlyoffice.com/app_data/editor/Java%20Example.zipunzip Java Example.zip
  3. Change the current directory for the project directory:
    cd Java Example/
  4. Edit the settings.properties configuration file. Specify the name of your local server with the ONLYOFFICE Document Server installed.

    Edit the following lines:

    Where the documentserverMacos drawing software. is the name of the server with the ONLYOFFICE Document Server installed.

  5. Install Maven:
    sudo apt-get install maven
  6. Build:
  7. Install Tomcat with the administration page:
    sudo apt-get install tomcat8 tomcat8-admin
  8. Configure the admin user on Tomcat: Insert the line:

    Where the USERNAME and PASSWORD are your own credentials data.

    Restart timcat:
    systemctl restart tomcat8
  9. Open the tomcat administration page in browser with the admin user credentions:
  10. Select the WAR file to upload from target/OnlineEditorsExampleJava-1.0.war.
  11. See the result in your browser using the address:
    http://localhost:8080/OnlineEditorsExampleJava-1.0/

Step 3. Checking accessibility

In case the example and Document Server are installed on different computers, make sure that your server with the example installed has access to the Document Server with the address which you specify instead of documentserver in the configuration files. And you must also make sure that the Document Server in its turn has access to the server with the example installed with the address which you specify instead of example.com in the configuration files.

If you integrated the editors successfully the result should look like the demo preview on our site.

The Apache HTTP Server Project is an effort to develop and maintain anopen-source HTTP server for modern operating systems including UNIX andWindows. The goal of this project is to provide a secure, efficient andextensible server that provides HTTP services in sync with the current HTTPstandards.

Program

The Apache HTTP Server ('httpd') was launched in 1995 and it has been the most popular web server on the Internet sinceApril 1996. It has celebrated its 25th birthday as a project in February 2020.

The Apache HTTP Server is a project of The Apache SoftwareFoundation.

The Apache Software Foundation and the Apache HTTP Server Project arepleased toannounce therelease of version 2.4.46 of the Apache HTTP Server ('httpd').

This latest release from the 2.4.x stable branch represents the best availableversion of Apache HTTP Server.

Apache HTTP Server version 2.4.43 or newer is required in order to operate a TLS 1.3 web server with OpenSSL 1.1.1.

Download ChangeLog for2.4.46 Complete ChangeLog for2.4 New Features in httpd2.4

What Is An Apache Server

As previously announced, the Apache HTTP Server Project has discontinuedall development and patch review of the 2.2.x series of releases.

The Apache HTTP Server Project had long committed to provide maintenancereleases of the 2.2.x flavor through June of 2017. The final release 2.2.34was published in July 2017, and no further evaluation of bug reports orsecurity risks will be considered or published for 2.2.x releases.

Great! We have updated our download page in an effort tobetter utilize our mirrors. We hope that by making it easier to use our mirrors, we will be able to provide a better download experience.

Please ensure that you verify your downloads usingPGP or MD5 signatures.

Awesome! Have a look at our current 'Help Wanted' listings then: