The NWS Tutorial

Configuration of your Web application



WARNING: This tutorial is being written! Do not hesitate to report any errors or suggestions.

Quick access:
   Global structure of the file WEB-INF/web.xml
   Configuration of the NWS track module
   Configuration of the statistical module
   Configuration of the index engine

Although not using all the web technologies proposed by the J2EE platform, the NWS framework is nonetheless based on the servlet concept. This choice for ensuring that the web pages developed through NWS will be able to run on any J2EE application server (JBoss, ...), even simply with Tomcat. Of this choice derives the fact that a NWS Web application must be deployed in a WAR and have to be configured by the intermediary of the file WEB-INF/web.xml. It is on the content of this file that this chapter will focus its attention.

Global structure of the file WEB-INF/web.xml

The file WEB-INF/web.xml is what the J2EE architecture calls a deployment descriptor: it contains any configuration informations on the various web components to deploy on the Tomcat server (or other). Traditionally this file contains at least two aspects (although the J2EE standard supports more others): the servlets configurations and the parameters definitions of initialization of the associated context with the application. Consider these two points one by one.

The NWS framework is based on an architecture MVC 2 with still some shades of implementation, as compared to other similar Java frameworks (Struts 1, Struts 2 or also JSF). Despite these shades, the approach MVC 2 imposes a common point to all these frameworks. A servlet uses as a main controller: then it will give hand to the secondary controllers (implemented as classes of Web page). The main controller is represented by the class corelib.services.web.server.ControllerServlet. A servlet configuration is required for this controller. This configuration will be, moreover, in relation with all the requests ending with .wp. You can define alternative configurations of servlets, but they will not go into play in the normal functioning of your web pages.

With regard to your configuration settings, they will be introduced via the XML tag XML <context-param>. A parameter will be formed by two parts: its name and its value. The name of a parameter will be introduced through the sub-tag <param-name>. The associated value, will be through a sub-tag <param-value>. The example below (corresponding to the configuration file of the demonstration application of the NWS framework) shows you an example of a parameter definition and the setting up of your main controller (the servlet of type ControllerServlet).

 
01 <?xml version="1.0" encoding="UTF-8"?>
02 <!DOCTYPE web-app PUBLIC
03   "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
04   "http://java.sun.com/dtd/web-app_2_3.dtd">
05 
06 
07 <web-app>
08 
09     <display-name>Virtual Caddy - NWS Sample</display-name>
10     <description>NWS Sample</description>
11 
12     <context-param>
13     	<param-name>TRACE_ENABLED</param-name>
14     	<param-value>true</param-value>
15     </context-param>
16     <context-param>
17     	<param-name>TRACE_LOCALHOST_ONLY</param-name>
18     	<param-value>true</param-value>
19     </context-param>
20     <context-param>
21     	<param-name>TRACE_URI</param-name>
22     	<param-value>Trace.wp</param-value>
23     </context-param>
24 
25 
26     <servlet>
27       <servlet-name>NWS Servlet</servlet-name>
28       <servlet-class>corelib.services.web.server.ControllerServlet</servlet-class>
29     </servlet>
30 
31     <servlet-mapping>
32         <servlet-name>NWS Servlet</servlet-name>
33         <url-pattern>*.wp</url-pattern>
34     </servlet-mapping>
35 
36 </web-app>
File WEB-INF/web.xml

For the association of the extension ".wp" to our main controller (lines 31 to 34), note that there is no requirement in the absolute. if you prefer to use another extension (why not ".toto") that will work very well. But, ".wp" for "Web Page" may not be so bad here.

Configuration of the NWS track module

The NWS framework includes a shades module that create the content history of the requests made by a web application. The configuration of this tracks module is done, of course, from the file WEB-INF/web.xml. The image below shows an example of tracks display for the demonstration application of the framework. And after you will find a table showing all the configuration parameters of the tracks module.

Example of NWS tracks display

Name of the parameter Default value Description
TRACE_ENABLED false Allow to activate or not the tracks module integrated in the framework
TRACE_LOCALHOST_ONLY true Allow to specify if the track is accessible only from the local post (from the web server) or if you allow from a distance the tracks access.
TRACE_URI Trace.wp What is the "pseudo Web page" that allows the tracks access
TRACE_MAX_COUNT 1000 Allow to control the maximum number of tracks that the server can store in memory.

Configuration of the statistical module

The framework also proposes a statistics module to know the number of open sessions per day, the proportions of browsers used on your web application, ... Of course, this module is customizable, although it is at an early stage. Here is the list of the supported parameters at this day.

Name of the parameter Default value Description
STATISTICS_ENABLED false Allow to activate or to inhibit the statistics module
STATISTICS_FILENAME REQUIRED Allows to specify the XML file in which the statistics will be kept. This file is expressed relatively to the root of the web application considered
STATISTICS_DURATION REQUIRED Number of days of statistics stored in the XML file.
STATISTICS_URL REQUIRED URL used for invoking the presentation web page of the statistics

Configuration of the index engine

The NWS framework also proposes an engine for indexing your Web pages. For more information, I referrals you from the technical file associated with this module.

Name of the parameter Default value Description
SEARCH_ENGINE_ENABLED false Allow to activate or inhibit the indexing engine.
SEARCH_ENGINE_EXCLUDES Allow to set the indexing engine for not considering a directory (or more) of the web application.
SEARCH_ENGINE_ADDITIONAL_SCANNERS Allow to add classes that can scan new types of documents contained in your web application.

CAUTION : NWS is proposed to you in BETA version to allow evaluation of this framework. Infini Software is released from any responsibility for the use of framework NWS. In addition, Infini Software can in no way be liable for the use of information contained in these tutorials.

Dominique LIARD - © 2007 SARL Infini Software - All rights reserved
Other brands and product names in these documents are the property of their respective owners.