[opencms-dev] Deployment of 3rd party packages in OpenCms
Stephan Hartmann
hartmann at metamesh.de
Tue May 12 19:34:18 CEST 2009
Hi Yves,
for registering your servlet without editing the web.xml, i suggest the
following approach:
Your servlet class should implement the interface
javax.servlet.jsp.HttpJspPage (and for your convenience extend
GenericServlet):
public abstract class MyJspPage extends javax.servlet.GenericServlet
implements javax.servlet.jsp.HttpJspPage {...}
and implement the methods
- service(ServletRequest req, ServletResoponse res)
- jspInit()
- jspDestroy()
we define the class as abstract because we don't implement the method
_jspService(), which is created by the JSP container and holds the logic
from the body of the JSP.
You can call this method from within your service() method if needed
(e.g. to separate the logic (servlet class) from the view JSP body).
Then, after deploying your jar file and reloading your webapp to make it
known to the webapp class loader, you can use your servlet as a base
class in JSP files by specifying it in the extends attribute of the page
tag:
<%@ page extends="my.package.MyJspPage" %>
You may also extend javax.servlet.http.HttpServlet instead of
GenericServlet and implement doXXX() methods instead of the service()
method.
To make your taglib available in JSPs without placing it in WEB-INF or a
subfolder, this is defined in the JSP Spec (identifying tag library
descriptors):
Just put the tag library descriptor files in the META-INF directory of
your JAR file, or a subdirectory of it.
Best regards,
Stephan
Yves Glodt schrieb:
> On Sunday 10 May 2009, Christian Steinert wrote:
> > Yves Glodt ha scritto:
> > > Hello,
> > >
> > > I have a case where I would like to deploy a selfmade jar-archive in
> > > OpenCms, and I am aware that I can put it in the lib-folder of the
> > > template.
> > >
> > > But my jar contains a servlet and a tag-library. Is there a way to
> > > register them in OpenCms, without editing web.xml (for the servlet) or
> > > putting the .tld file in the real-filesystem? I would like to keep the
> > > jar and all it's dependencies in the vfs, if possible... :)
> >
> > If you need to have your own servlet then I am afraid that you need to
> > edit the web.xml in some way.
>
>
> ok. The servlet-definition should actually never change, so it's not a
> big issue if I have to define it once manually.
>
>
> > But the deployment of your jars is still possible with a module - as
> > soon as a module is published, its jar files will be exported to the
> > opencms lib folder in the RFS automatically
>
>
> Ok, this is good news!
>
>
> But what about the taglib-definition-file? This file might change more
> frequently...
>
>
> Usually the .tld file should go to /WEB-INF/. I could of course put it
> in a web-accessible path (which would be in the vfs then), but I would
> prefer to avoid that :-)
>
>
> Best regards,
> Yves
>
>
> > Best Regards
> > Christian
> ------------------------------------------------------------------------
>
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
More information about the opencms-dev
mailing list