Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[equinox-dev] JSP support in the servlet bridge incubator project


I have spent a little time investigating supporting JSPs within the server side OSGi incubator project. Having taken a look at what Harald Niesche had achieved with his JasperBundle I felt that instead of having to prefix all my JSP requests with "/jasper-jsp" it would be preferable to support JSP's just as requests for static resources are handled.

Here is what I have put together :

1.) Created a org.apache.jasper bundle containing the required Jasper jars to run the JSP Container (commons-el.jar, jasper-compiler.jar, jasper-compiler-jdt.jar and jasper-runtime.jar). This bundle is also a fragment bundle whose bundle host is org.eclipse.equinox.servlet.bridge.http bundle. This allows references to the Jasper classes to be made without having to add explicit imports to the org.eclipse.equinox.servlet.bridge.http manifest.

2.) In the org.eclipse.equinox.servlet.bridge.http bundle I created a JspEnabledProxyServlet class that extends the ProxyServlet class. Within this new class a single JSPServletRegistration object is created that wrappers the Jasper org.apache.jasper.servlet.JspServlet. Also a specialized JspServletHtpContext class has been created to handle setting the correct resouce http context for the bundle that contains the JSP resource.

3.) In the org.eclipse.equinox.servlet.bridge.http bundle I created a JspEnabledResourceRegistration class that extends the existing ResourceRegistration class and overides the handleRequest method. When created it is passed a reference to the JSPServletRegistration object .When the  handleRequest method is called if the supplied alias has an extension identified as a JSP extension the JSPServletRegistration object is used to handle the request instead of the standard ResourceRegistration.

4) All of the above is enabled by making some slight modifications to some of the org.eclipse.equinox.servlet.bridge.http classes, specifically the Activator class and the ProxyServlet class. The ProxyServlet changes were simply changing some of the class attributes and methods to protected access. The change to the Activator class was to invoke the new JspEnabledProxyServlet instead of the standard ProxyServlet. The manifest for the org.eclipse.equinox.servlet.bridge.extensionbundle was also modified to filter the javax.servlet.jsp classes down from the running webcontainer.
 
So this works nicely for any JSP resources configure via the standard resources extension point but what if the JSP's reference Custom Tag Libraries ? The solution I have come up with allows Custom Tag Libraries to be created as standard OSGi bundles. They register their provided TLD's via a TldProvider service I added to the org.eclipse.equinox.http.registry bundle. The JspEnabledProxyServlet class tracks the registered services and adds their  TLD uri's to the Jasper JSP Servlet. via an extended URLClassloader  I could have achieved the registration of the TLDProviders by using a new extension point added to the org.eclipse.equinox.http.registry bundle but getting access to the registry details seemed as though it would be quite hard to achieve in simple manor.

Thoughts ?

Richard Backhouse

Back to the top