Page tree
Skip to end of metadata
Go to start of metadata

This guide tells how to embed MoSKito-WebUI into your application.

After embedding and before you start working, we encourage you to look through the User Guide.

This guide contains info for versions below 2.4.0. With version 2.4.0 and servlet spec 3.0 no changes of the web.xml are needed.

The libs

If you are not using maven or ivy, you'll need to add following libs:

  • ano-util.jar - StringUtils from ano* open source projects.
  • commons-beanutils.jar - Needed by tasks.
  • log4j.jar - Logging.
  • moskito-core.jar - Core MoSKito functionality.
  • moskito-util.jar - MoSKito Utils.
  • moskito-web.jar - Core MoSKito functionality.
  • moskito-webui.jar - MoSKito Utils.

All these jars are parts of MoSKito distribution package. You can also get the latest version in our ivy repository:

svn://svn.anotheria.net/opensource/ivy-shared-repository

.
or from our nexus:

http://nexus.anotheria.net

If you checkout the project for building, you'll find additional three jars, which are not needed at runtime:
jsp-api.jar, junit.jar and servlet-api.jar

The web.xml

MoSKito is configured via web.xml.
Here is the least needed snipplet:

	<!--  Moskito -->
	<!--  Adding filter to moskito ui which redirects requests to /mui/* to moskito user interface -->	
   	<filter>
        <filter-name>MoskitoUIFilter</filter-name>
       	<filter-class>net.anotheria.moskito.webui.MoskitoUIFilter</filter-class>
		<init-param>
			<param-name>path</param-name>
			<param-value>/mui/</param-value>
		</init-param>
   	</filter>
   	<filter-mapping>
       	<filter-name>MoskitoUIFilter</filter-name>
   	    <url-pattern>/mui/*</url-pattern>
    </filter-mapping>

This will force all requests to <context>/mui/ to be redirected to MoSKito WebUI. Feel free to choose another path at your will.
It's generally also a good idea to add some default MoSKito filters:

    <!--  adding moskito measurement and command filters -->
    <filter>
        <filter-name>RequestURIFilter</filter-name>
        <filter-class>net.anotheria.moskito.web.filters.RequestURIFilter</filter-class>
                <init-param>
                        <param-name>limit</param-name>
                        <param-value>1500</param-value>
                </init-param>
    </filter>
	<filter>
        <filter-name>MoskitoCommandFilter</filter-name>
        <filter-class>net.anotheria.moskito.web.filters.MoskitoCommandFilter</filter-class>
    </filter>
        <filter>
        <filter-name>JourneyFilter</filter-name>
        <filter-class>net.anotheria.moskito.web.filters.JourneyFilter</filter-class>
    </filter>

   	<filter-mapping>
       	<filter-name>RequestURIFilter</filter-name>
   	    <url-pattern>/*</url-pattern>
    </filter-mapping>
   	<filter-mapping>
       	<filter-name>MoskitoCommandFilter</filter-name>
   	    <url-pattern>/*</url-pattern>
    </filter-mapping>
   	<filter-mapping>
       	<filter-name>JourneyFilter</filter-name>
   	    <url-pattern>/*</url-pattern>
    </filter-mapping>
<!--  /Moskito END -->

And than there are some listeners:

    <!-- this listener will init moskito with the context name and cleanup jmx beans and timers on undeploy -->
    <listener>
		<listener-class>
			net.anotheria.moskito.webui.util.StartStopListener
		</listener-class>
	</listener>
    <!-- provides information about created sessions -->
    <listener>
		<listener-class>
			net.anotheria.moskito.web.session.SessionCountProducer
		</listener-class>
    </listener>
    <!-- prepared some useful accumulators -->
    <listener>
		<listener-class>
			net.anotheria.moskito.webui.util.SetupPreconfiguredAccumulators
		</listener-class>
	</listener>
    <!-- here you will usually configure your thresholds and accumulators -->

Styles, Images, JSPs...

Finally you have to put MoSKito styles, jsps and images in your webapp (don't worry, there are few of them). They are all contained in the supplied moskito-webui.jar. Following ant script copies everything where it should be:

<?xml version="1.0"?>

<project name="moskitoui" basedir=".">
	
    <property name="moskito.lib" value="moskito"/> <!-- folder in which moskito libs are located -->
    <property name="webapp.tmp.dir" value="build/war"/> <!-- target folder for the webapp -->
	
    <target name="inject-moskitoui-webxml">
	<echo>Replacing web.xml</echo>
    	<copy file="${moskito.lib}/web.xml" tofile="${webapp.tmp.dir}/WEB-INF/web.xml" overwrite="true"/>
    </target>

    <target name="inject-moskitoui-data">
  	<echo>Adding moskito classes, images and jsps.</echo>
    	<copy todir="${webapp.tmp.dir}/WEB-INF/lib">
            <fileset dir="${moskito.lib}">
                <include name="**/*.jar"/>
            </fileset>
    	</copy>
    	
	<unjar src="${moskito.lib}/moskito-webui.jar" dest="${webapp.tmp.dir}" >
	    <patternset>
	        <include name="**/*.jsp"/>
	    </patternset>
	</unjar>
	<unjar src="${moskito.lib}/moskito-webui.jar" dest="${webapp.tmp.dir}/WEB-INF/static/msk" >
	    <patternset>
	        <include name="img/*.jpg"/>
	        <include name="img/*.gif"/>
	    </patternset>
	</unjar>
	<unjar src="${moskito.lib}/moskito-webui.jar" dest="${webapp.tmp.dir}" >
	    <patternset>
	        <include name="css/*.css"/>
	    </patternset>
	</unjar>
	<unjar src="${moskito.lib}/moskito-webui.jar" dest="${webapp.tmp.dir}" >
	    <patternset>
	        <include name="js/*.js"/>
	    </patternset>
	</unjar>
	<unjar src="${moskito.lib}/moskito-webui.jar" dest="${webapp.tmp.dir}/WEB-INF/" >
	    <patternset>
	        <include name="tld/*"/>
	    </patternset>
	</unjar>
    </target>
    <target name="inject-moskitoui" depends="inject-moskitoui-webxml,inject-moskitoui-data"/>

Of course you may simply put extracted versions in your project and adopt changes in your web.xml permanently.

MoSKito can't find the JSPs ?

Some people map everything to a single servlet, and some of the servlets and dispatchers out there are just crap. For example Spring MVC Servlet. The dispatcher it provides can't resolve jsps or other existing resources properly. If you have such a case, you can still map all jsps and resources manually in the web.xml. It doesn't look nice, but it works. And its optional, in 99% of cases you won't need it:

   <!--  Moskito JSP Mapping, due to /* to spring servlet the jsps have to be mapped by fully qualified name to ensure the jsp servlet working properly -->
   
	<servlet-mapping>
	    <servlet-name>jsp</servlet-name>
	    <url-pattern>/net/anotheria/moskito/webui/jsp/Producers.jsp</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
	    <servlet-name>jsp</servlet-name>
	    <url-pattern>/net/anotheria/moskito/webui/jsp/ProducersXML.jsp</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
	    <servlet-name>jsp</servlet-name>
	    <url-pattern>/net/anotheria/moskito/webui/jsp/ProducersCSV.jsp</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
	    <servlet-name>jsp</servlet-name>
	    <url-pattern>/net/anotheria/moskito/webui/jsp/Producer.jsp</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
	    <servlet-name>jsp</servlet-name>
	    <url-pattern>/net/anotheria/moskito/webui/jsp/ProducerXML.jsp</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
	    <servlet-name>jsp</servlet-name>
	    <url-pattern>/net/anotheria/moskito/webui/jsp/ProducerCSV.jsp</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
	    <servlet-name>jsp</servlet-name>
	    <url-pattern>/net/anotheria/moskito/webui/jsp/InspectProducerXML.jsp</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
	    <servlet-name>jsp</servlet-name>
	    <url-pattern>/net/anotheria/moskito/webui/jsp/InspectProducer.jsp</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
	    <servlet-name>jsp</servlet-name>
	    <url-pattern>/net/anotheria/moskito/webui/jsp/Explanations.jsp</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
	    <servlet-name>jsp</servlet-name>
	    <url-pattern>/net/anotheria/moskito/webui/jsp/UseCases.jsp</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
	    <servlet-name>jsp</servlet-name>
	    <url-pattern>/net/anotheria/moskito/webui/jsp/RecordedUseCase.jsp</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
	    <servlet-name>jsp</servlet-name>
	    <url-pattern>/net/anotheria/moskito/webui/jsp/MonitoringSessions.jsp</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
	    <servlet-name>jsp</servlet-name>
	    <url-pattern>/net/anotheria/moskito/webui/jsp/MonitoringSessionCall.jsp</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
	    <servlet-name>jsp</servlet-name>
	    <url-pattern>/net/anotheria/moskito/webui/jsp/MonitoringSession.jsp</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
	    <servlet-name>jsp</servlet-name>
	    <url-pattern>/net/anotheria/moskito/webui/jsp/Menu.jsp</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
	    <servlet-name>jsp</servlet-name>
	    <url-pattern>/net/anotheria/moskito/webui/jsp/CSS.jsp</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
	    <servlet-name>jsp</servlet-name>
	    <url-pattern>/net/anotheria/moskito/webui/jsp/IntervalSelection.jsp</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
	    <servlet-name>jsp</servlet-name>
	    <url-pattern>/net/anotheria/moskito/webui/jsp/UnitSelection.jsp</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
	    <servlet-name>jsp</servlet-name>
	    <url-pattern>/net/anotheria/moskito/webui/jsp/CategorySelection.jsp</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
	    <servlet-name>jsp</servlet-name>
	    <url-pattern>/net/anotheria/moskito/webui/jsp/SubsystemSelection.jsp</url-pattern>
	</servlet-mapping>
        <servlet-mapping>
	    <servlet-name>default</servlet-name>
	    <url-pattern>/js/wz_tooltip.js</url-pattern>
	</servlet-mapping>
	<!--  /Moskito JSP  -->

Accessing your app with WebUI is described in WebUI User Guide

  • No labels

2 Comments

  1. Just wanted to let you know, that by simply adding the <mvc:default-servlet-handler /> to my Spring MVC servlet context I could skip the part of mapping all the JSPs.

    1. Hello Alexander, 

      thank you very much, I will forward your comment to people who have this problem. Hopefully, this will reduce their web.xml a lot.