Java

HTTP Headers Filter

A Java Servlet Filter that sets HTTP headers.
Implementation of javax.servlet.Filter used to set HTTP headers. The filter parameters are treated as HTTP headers. The parameter name becomes the header name, while the parameter value becomes the header value. The parameter value may contain EL expressions. If the expression evaluates to a java.util.Date or a java.lang.Long object the header is considered to be a Date header and formatted according to the HTTP spec.

These are the implicit objects available to the EL context:

now
A java.util.Date object the represents the current time.

Init-params:

negativeMapping
A regular expression matching request URIs to be ignored. The URI is obtained using HttpServletRequest.getRequestURI(). See also the regular expression documentation

This is a typical usage example:

<filter>
  <filter-name>httpHeaders</filter-name>
  <filter-class>
    org.ft.servlet.filters.httpheaders.HTTPHeadersFilter
  </filter-class>
  <init-param>
    <param-name>Expires</param-name>
    <param-value>${now.time + 1000 * 60}</param-value>
  </init-param>
  <init-param>
    <param-name>Last-Modified</param-name>
    <param-value>${now}</param-value>
  </init-param>
</filter>
<filter-mapping>
  <filter-name>httpHeaders</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

Requirements

Download

Legal

This is Open Source software distributed under the Apache License Version 2.0.

Juseppe, a simple JSP framework

Juseppe is a simple framework for JSP development. I wrote it to speed up my (and my colleagues’) work, but you can use it too. Juseppe is implemented as a Java Servlet Filter and meant to be used in a JSP 2.0 + JSTL environment.

Goals

Clean URIs

With Juseppe, your URIs will not reveal the underlying technology. This is both a security advantage and a wise naming design: when you’ll reimplement your site with a new technology chances are you’ll be able to preserve the old URIs and break no links. Your URIs will look like:

http://www.dumbnews.com/politics
http://www.dumbnews.com/article/4321

and not:

http://www.dumbnews.com/politics.jsp
http://www.dumbnews.com/article.jsp?id=4321

Site structure

Juseppe simplifies JSP development and mantainance by providing a navigation system among web application resources. Instead of hardcoding links and site sections inside JSPs, Juseppe puts the website structure in a freeform XML file. URIs are then mapped to XML nodes and to JSPs using XPath expressions. This makes adding and removing sections much easier than delving inside spaghetti JSP code.

This is a typical XML configuration:

<page name="." resource="/home.jsp" display="Homepage">
<page name="politics" resource="/politics.jsp" display="Politics"/>
<page name="technology" resource="/technology.jsp" display="Technology"/>
<page name="article" resource="/article.jsp"/>
</page>

Take a look to the demo!

The quickest way to grasp the concept behind this project is trying the sample webapp included in the distribution.

Starting a new web application from scratch

  1. Drop juseppe-x.x.x.war found in the binary distribution in your servlet container web application directory.

Using Juseppe in an existing web application

  1. Extract juseppe-x.x.x.war using the jar utility (or any other zip utility).
  2. Copy the libraries found in WEB-INF/lib to your application WEB-INF/lib directory.
  3. Copy WEB-INF/juseppe.xml to your application WEB-INF directory.
  4. Open WEB-INF/web.xml, then cut’n’paste the Juseppe Filter definition and mapping to your web.xml.
  5. Customize WEB-INF/juseppe.xml according to your website structure.
  6. Possibly customize Juseppe Filter init-params in WEB-INF/web.xml.

For reference documentation see the Javadocs included in the distribution.

Status

Juseppe is production ready. It is currently used on the following (italian) sites:

Legal

Juseppe is Open Source software distributed under the Apache License Version 2.0.

Requirements

Download

JSTL patch

This is a patched version of the Jakarta Standard Tag Library
which implements the JSTL 1.1 specification. This patch makes the XML tags run 100 times faster. I wrote almost no code, I just reverted the XPathUtil class to a previous version and managed to compile the whole thing.

Originally the Standard Taglib used the Jaxen XPath processor. With version 1.1 the project switched to Xalan, decreasing performance by a factor of 100. At my company we chose to use JSTL and we’re really happy about it. But our sites must work now, so I put together this patched version. I hope to be able to use the official version very soon. In the meanwhile, if you’re using JSTL in a production environment give this version a try.

I submitted this patch to the Standard Taglib developers but it was refused because it implies a dependency on Jaxen. Here’s the original thread on the taglibs-dev at jakarta.apache.org mailing list.

To install over an existing webapp just drop in the standard-*.*.*-patched.jar and remove standard.jar.
You also need jaxen-*.*.jar from the Jaxen project.

Requirements

Download

XSLT Servlet

This servlet transforms an XML document using an XSLT stylesheet. Probably there are other Servlet implementations of this kind, but I couldn’t find one with the features I need available under an Open Source license, so I wrote this one.

Features

  • the XML document and the stylesheet can be retrieved from the local webapp or from the network (using java.net).
  • Stylesheet is preloaded at startup and then periodically reloaded in the background in order to optimize performance.
  • JSP EL expressions can be used in the Servlet init params.
  • Parameters can be passed to the stylesheet.
  • XSLT output properties can be controlled by the Servlet.
  • Not tied to a specific XML parser or XSLT processor.
    This Servlet uses javax.xml.transform (aka TrAX) for XSLT processing.

This is a sample web.xml configuration:

<servlet>
  <servlet-name>myTransformation</servlet-name>
  <servlet-class>it.kataweb.xslt.servlet.XSLTServlet</servlet-class>
  <init-param>
    <param-name>xml</param-name>
    <param-value>http://domain.org/service?param=${param.myParam}</param-value>
  </init-param>
  <init-param>
    <param-name>xslt</param-name>
    <param-value>/WEB-INF/xslt/myStylesheet.xslt</param-value>
  </init-param>
  <init-param>
    <param-name>xsltReloadInterval</param-name>
    <param-value>60</param-value>
  </init-param>
</servlet>

    

For reference documentation see the Javadocs included in the distribution.

Legal

This Servlet is Open Source software distributed under the Apache License Version 2.0.

Requirements

Download

Arale, a Java web spider

Arale can download entire web sites or specific resources from the web. Arale can also render dynamic sites to static pages. I wrote this utility in 2001 to familiarize myself with the java.net.* package. I’m not actively maintaining it anymore, the code is rather messy but the spider is working fine.

Areas of interest

  • Web development
  • Advanced web browsing

Features

  • Download and scan user-defined file types.
  • Rename dynamic resources. Encode query strings into filenames.
  • Set the number of simultaneous connections.
  • Options for minimum and maximum file size.
  • Domain depth support.

While many bots around are focused on page indexing, Arale is primarly designed for personal use. It fits the needs of advanced web surfers and web developers. Some real life cases are:

  • downloading only images, videos, mp3 or zip files from a site.
  • manuals, articles, ebooks fragmented in many files to discourage download.
  • user-unfriendly sites. Popups, banners and tricky scripts annoying you before you can download a resource.

Multithreaded means that Arale can download more than one file simultaneously. Arale can easily saturate your bandwidth, thus providing the fastest possible download speed for your internet connection.

If you’re developing dynamic sites using technologies such as JSP, PHP, ASP or whatever, you may be interested in rendering dynamic pages to static files.
Arale supports URL renaming: query string is encoded in the static filename and .html extension is appended. let’s make an example:

  • original URL: mypage.jsp!myparam=myvalue.html
  • static filename: mypage.jsp!myparam=myvalue.html

Existing links to renamed URLs are substituted with modified links. This preserves navigation among static files. Once a dynamic site is trasformed into a set of static files it can be deployed on a server that does not support dynamic pages. For example you may deploy a JSP site in a free web space.

Currently Arale is a command-line tool. It would be nice to develop a GUI for it. I’d like to have some feedback from users, so if you think it’s worth send me an email and tell me what you think. ;)

Requirements

Download