Getting Started

You have two choices getting started with JMAGE. For the very impatient, just drop the sample application war file into your favourite servlet 2.3 compliant container and have a look through the code there. All filters have their own documentation and sample page.

If you want to start using JMAGE within your own application directly, just follow the simple steps below. Like alot of frameworks for the servlet container, JMAGE is happy with copying a few jars and editing an xml configuration file.

  1. Copy dist/jmage-x.x.x.jar into the WEB-INF/lib folder of your web app. This is the binary distribution needed to run JMAGE
  2. Now copy all necessary third party libraries from the /lib folder into the same location. JMAGE needs Sun's JAI libs and a few other things like log4j to run.
  3. Copy the jmage.tld into the WEB-INF/lib folder.
  4. If required, edit jmage.xml and then put it into WEB-INF/classes. You can also just start with copying the sample configuration file and edit it later. The standard configuration will easily do for starters.
  5. Configure your web.xml file to include the JMAGE servlet and tag library as follows. This is the only part where you need to change something. First insert the servlet configuration by pasting this block into the appropriate location:


 <servlet>
     <servlet-name>jmage</servlet-name>
     <servlet-class>org.jmage.mapper.ServletMapper</servlet-class>
     <load-on-startup>0</load-on-startup>
 </servlet>

 <servlet-mapping>
     <servlet-name>jmage</servlet-name>
     <url-pattern>/jmage/*</url-pattern>
 </servlet-mapping>

Now add the tld file entry, so you can use the tag library.


 <taglib>
        <taglib-uri>jmage</taglib-uri>
        <taglib-location>/WEB-INF/lib/jmage.tld</taglib-location>
 </taglib>

Optionally, you can also add the servlet filter like this (the sepia filter is a sample configuration, more on filters later)


 <filter>
     <filter-name>imageinterceptor</filter-name>
     <filter-class>org.jmage.mapper.InterceptorMapper</filter-class>
     <init-param>
         <param-name>oldphotos</param-name>
         <param-value>org.jmage.filterchain.other.Sepia</param-value>
     </init-param>
 </filter>

 <filter-mapping>
     <filter-name>imageinterceptor</filter-name>
     <url-pattern>/images/*</url-pattern>
 </filter-mapping>

That already completes basic setup. You can now get started using the tag library, directly invoke the image filtering servlet, or use the servlet filter for bulk image transformation.