First step

In this showcase you can find details how to start working with FireWeb framework. I assume that you have installed Tomcat in the environment or any other application server and tools such as Eclipse. Here i refer to my favorite Eclipse.


OK, so we start build first application.

  1. Add Tomcat container to workspace. In Java EE view select Servers tab and follow the steps in the wizard.

    Add serwer to workspace
  2. Create Dynamic Web Project with name "firststep".

    New project

    New project properties

    Twice press button Next, go to tab Web module and check option Generate web.xml deployment descriptor.

    New project web module

    Press button Finish.

  3. Covert project to Maven Project.

    To maven project

    To maven option

    Press Finish button with default values.

    If you want to use sources from SVN repository, skip this and next step. Core FireWeb module sources are available at https://svn.code.sf.net/p/fireweb/svn/eclipse/fireweb-core.

  4. Add Maven dependency of FireWeb Core. In pom.xml editor switch to tab Dependencies and press Add button. Next fill form

    Add maven module

    or simply edit pom.xml file adding to section dependencies element dependency shown at the end of page.
  5. Setup project build path. In order to build working war file or to deploy project at server in tool, we have to change project build path.

    Project bulid path

    Switch to tab Order and Export and select option Maven Dependencies.


    Order and Export
  6. Create package and application class.

    From project context menu select option New / Package.

    Add package

    Package properties

    Leave defaults and press button Finish.

    Next, from project context menu select option New / Class.

    Add class

    Class properties

    Fill form as on picture above and press button Finish.

  7. Setup FireWebServlet in war.xml.

    Open web.xml file.

    Open web.xml

    Edit file as below example. Optional elements are: <load-on-startup>, <welcome-file>.

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    	id="WebApp_ID" version="3.0">
    	<display-name>firststep</display-name>
    	<servlet>
    		<description>FireWeb First Step</description>
    		<display-name>FireWeb First Step cookbook</display-name>
    		<servlet-name>firststep</servlet-name>
    		<servlet-class>org.fireweb.FireWebServlet</servlet-class>
    		<init-param>
    			<description>FireWeb class implemented application</description>
    			<param-name>class</param-name>
    			<param-value>firststep.Main</param-value>
    		</init-param>
    		<load-on-startup>1</load-on-startup>
    		<async-supported>true</async-supported>
    	</servlet>
    	<servlet-mapping>
    		<servlet-name>firststep</servlet-name>
    		<url-pattern>/firststep</url-pattern>
    	</servlet-mapping>
    	<welcome-file-list>
    		<welcome-file>firststep</welcome-file>
    	</welcome-file-list>
    </web-app>
    


    Save changes.

  8. Add some code to application, the Main class.

    public class Main extends FireWebApplication {
    
    	/**
    	 * 
    	 */
    	private static final long serialVersionUID = 2169862264662104969L;
    
    	/**
    	 *  Default constructor
    	 */
    	public Main() {
    
    		/*
    		 * Simple text with some HTML includes
    		 */
    		setText("Hello world !!! FireWeb is easy :)");
    
    		/*
    		 * Setup head/title text of browser tab name.
    		 */
    		setApplicationTitle("The First Step app");
    	}
    
    }

  9. Deploy module and start server.

    From Tomacat server context menu select option Add and Remove....

    Add to server Add to server dialog

    On left select "firststep" project and press buttton Add, next Finish.

    Server start

    Go to Servers tab, select line with Tomcat server and press Restart the server button on toolbar.

    At console tab you should see below log line.

    Server console

  10. Expected result.

    At browser address bar write http://localhost:8080/firststep/ and press Enter.

    Result in browser

    You should see result as above.


Code of this show case in Eclipse format you can download form here.


FireWeb core module is available at Maven repository:

<dependency>
	<groupId>net.sf.fireweb</groupId>
  	<artifactId>fireweb-core</artifactId>
  	<version>RELEASE</version>
</dependency>

You can find all maven releases at Maven Central Repository