Hello World in Echo3 framework

Since "Hello World" example is everyone's favorite example therefore we will start our tutorial of Echo3/Echo Web Framework with the "Hello World" example in Echo3.

Hello World in Echo3 framework

Hello World in Echo3 framework

     

Since "Hello World" example is everyone's favorite example therefore we will start our tutorial of Echo3/Echo Web Framework with the "Hello World" example in Echo3. We have illustrated the first "Hello World" example in Echo3 with the server-side API. To create the first application you will need jar files of the Echo3. You can download Echo3 jar files from the following link:
http://echo.nextapp.com/site/echo3/download

In this example we have created two java files HelloWorldApp.java and HelloWorldServlet.java. HelloWorldApp represents the user instance of the the application and the HelloWorldServlet prcoess the HTTP connection and instantiate the HelloWorldApp application.

 

 

 

 

HelloWorldServlet.java

package helloworld;

import nextapp.echo.app.ApplicationInstance;
import nextapp.echo.webcontainer.WebContainerServlet;

public class HelloWorldServlet extends WebContainerServlet {

  public ApplicationInstance newApplicationInstance() {
  return new HelloWorldApp();
  }
}

HelloWorldApp.java

package helloworld;

import nextapp.echo.app.*;
import nextapp.echo.app.Label;
import nextapp.echo.app.Window;
import nextapp.echo.app.ContentPane;
import nextapp.echo.app.ApplicationInstance;

import nextapp.echo.app.event.ActionListener;
import nextapp.echo.app.event.ActionEvent;

public class HelloWorldApp extends ApplicationInstance {

 private WindowPane windowPane;

 public Window init() {
  Window window = new Window();
  window.setTitle("Hello World");
  ContentPane contentPane = new ContentPane();
  Label label=new Label("HelloWorld Application");
  contentPane.add(label);
  window.setContent(contentPane);
  return window;
  }  

One more thing you have to do before executing the application is that do the servlet mapping and servlet entry in the deployment descriptor web.xml

web.xml

<!DOCTYPE web-app 
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

<display-name>Interactive Test Application</display-name>
<description>
An interactive application to test features of the Echo Platform.
</description>

<servlet>
<servlet-name>HelloWorldServlet</servlet-name>
<servlet-class>helloworld.HelloWorldServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>HelloWorldServlet</servlet-name>
<url-pattern>/app</url-pattern>
</servlet-mapping>

</web-app>

To run this example follow these steps as given below:

  • Download Echo3 jar files
  • Place these jar files into the lib /WEB-INF/lib folder
  • Create java files, compile them and place into the  /WEB-INF/classes folder
  • Create and save web.xml file
  • Start your web server (e.g Tomcat Server)
  • Type the URL into the address bar http://localhost:8080/echo3/app

Output

Download Source Code