Zimlet JSP: Difference between revisions

No edit summary
Line 78: Line 78:


After we factor out the client side stuff from server side stuff and sever the dependency to zimbrastore.jar (bug 10704), we could make the tags available to zimlet webapp.  Until then, the tag libraries are semi-public API that you are welcomed to use but you'll need to do some work to set it up and get it running.
After we factor out the client side stuff from server side stuff and sever the dependency to zimbrastore.jar (bug 10704), we could make the tags available to zimlet webapp.  Until then, the tag libraries are semi-public API that you are welcomed to use but you'll need to do some work to set it up and get it running.
== JSP support in ZCS 9.0.0 ==
zimbraZimletJspEnabled needs to be set to TRUE to enable JSP in a zimlet.
<pre>
$ zmprov mcf zimbraZimletJspEnabled TRUE
or
$ zmprov ms <hostname> zimbraZimletJspEnabled TRUE
</pre>
If your jsp imports a zimbra java class, necessary jar file(s) in /opt/zimbra/lib/jars/ needs to be added as a link.
<pre>
$ mkdir /opt/zimbra/jetty/webapps/zimlet/WEB-INF/lib
$ ln -s /opt/zimbra/lib/jars/zimbracommon.jar /opt/zimbra/jetty/webapps/zimlet/WEB-INF/lib/
$ ln -s /opt/zimbra/lib/jars/zimbrasoap.jar /opt/zimbra/jetty/webapps/zimlet/WEB-INF/lib/
$ ln -s /opt/zimbra/lib/jars/zimbraclient.jar /opt/zimbra/jetty/webapps/zimlet/WEB-INF/lib/
$ ln -s /opt/zimbra/lib/jars/zimbrastore.jar /opt/zimbra/jetty/webapps/zimlet/WEB-INF/lib/
</pre>
If your jsp uses a tag defined in zimbra webapp, taglib and tags needs to be added as a link.
<pre>
$ ln -s /opt/zimbra/jetty/webapps/zimbra/WEB-INF/lib/zm-taglib-*.jar /opt/zimbra/jetty/webapps/zimlet/WEB-INF/lib/
$ ln -s /opt/zimbra/jetty/webapps/zimbra/WEB-INF/tags /opt/zimbra/jetty/webapps/zimlet/WEB-INF
$ ln -s /opt/zimbra/jetty/webapps/zimbra/WEB-INF/tlds /opt/zimbra/jetty/webapps/zimlet/WEB-INF
</pre>
mailboxd needs to restart after the change.
<pre>
$ zmmailboxdctl restart
</pre>
See also the caveat described in [[#JSP support in 6.0 (CHANGED FROM 5.x)]]


== See also ==
== See also ==

Revision as of 06:43, 24 February 2021

Zimlet JSP

   KB 2957        Last updated on 2021-02-24  




0.00
(0 votes)

A Zimlet JSP implements any server side data retrieval and manipulation for the actions to be performed on the client. The Zimlet JSP code may use any protocol or API needed to fetch data or act on a user’s selection.

For example, for a UPS package tracking Zimlet, a Zimlet JSP implementation may make a call to the UPS’ tracking information API with the matched tracking number in order to get package status and/or delivery information for displaying to the user. The tracking information would be returned to the client for possible display in a context object tool tip.

Custom Zimbra Tag Library

A Zimlet JSP implementation can include custom tags provided by the Zimbra Tag Library. Such tags can be used to build powerful server side plug-ins based on JSP, which complements the Zimlets by off-loading expensive tasks from the browser, providing better performance, and simplifying client-server communication. Many of the Zimbra resources are made available by Zimbra Tag Library. Refer to zimbra.tld for the details.

Available resources

  • message
  • conversation
  • contact
  • note
  • property
  • zimletconfig

In order to use the tags from Zimbra Tag Library, the tag library description file has to be declared at the top of JSP.

<%@ taglib uri="/WEB-INF/zimbra.tld" prefix="z" %>> Then the Zimbra custom tags can be used in the JSP.

Then the Zimbra custom tags can be used in the JSP


 <table border="1">
    <tr>
      <td>id</td>
      <td>subject</td>
      <td>from</td>
      <td>to</td>
      <td>cc</td>
      <td>bcc</td>
    </tr>
 <%
   String msgid;
   String[] msgids = { "488", "489", "405" };
     for (int i = 0; i < msgids.length; i++) {
         msgid = msgids[i];
 %>
    <tr>
      <td><%= msgid %></td>
      <td><z:message id='<%= msgid %>' field="subject"/></td>
      <td><z:message id='<%= msgid %>' field="from"/></td>
      <td><z:message id='<%= msgid %>' field="to"/></td>
      <td><z:message id='<%= msgid %>' field="cc"/></td>
      <td><z:message id='<%= msgid %>' field="bcc"/></td>
   </tr>
  <%
     }
  %>
     </table>

JSP support in 6.0 (CHANGED FROM 5.x)

Here's what you need to do to use the new taglib in zimlet jsp files.

ln -s /opt/zimbra/jetty/webapps/zimbra/WEB-INF/lib /opt/zimbra/jetty/webapps/zimlet/WEB-INF

ln -s /opt/zimbra/jetty/webapps/zimbra/WEB-INF/tags /opt/zimbra/jetty/webapps/zimlet/WEB-INF

ln -s /opt/zimbra/jetty/webapps/zimbra/WEB-INF/tlds /opt/zimbra/jetty/webapps/zimlet/WEB-INF

Copy five <env-entry> sections from /opt/zimbra/jetty/webapps/zimbra/WEB-INF/web.xml to /opt/zimbra/jetty/etc/zimlet.web.xml.in

The <env-entry> to copy are :

httpPort, httpsPort, mailUrl, adminUrl and trustedIps

After that restart jetty (zmmailboxdctl restart) and the tag libraries you reference in zimlet supplied jsp files will resolve correctly and start working.

Here's the caveat. Linking the jar files to zimlet webapp makes them available to all jsp files in zimlet webapp. You need to make sure that jsp files are well behaved. i.e. Don't try to use critical shared resources like db connection. Using ZClient/ZMailbox in JSP is safe, and that's the recommended way to access any mail items in jsp. When you upgrade or install patch to ZCS, you'll need to repeat the steps again.

The copying of <env-entry> to web.xml is awkward. We have filed a bug for this (bug 41046) so we don't have that dependency any more.

After we factor out the client side stuff from server side stuff and sever the dependency to zimbrastore.jar (bug 10704), we could make the tags available to zimlet webapp. Until then, the tag libraries are semi-public API that you are welcomed to use but you'll need to do some work to set it up and get it running.

JSP support in ZCS 9.0.0

zimbraZimletJspEnabled needs to be set to TRUE to enable JSP in a zimlet.

$ zmprov mcf zimbraZimletJspEnabled TRUE
or
$ zmprov ms <hostname> zimbraZimletJspEnabled TRUE

If your jsp imports a zimbra java class, necessary jar file(s) in /opt/zimbra/lib/jars/ needs to be added as a link.

$ mkdir /opt/zimbra/jetty/webapps/zimlet/WEB-INF/lib
$ ln -s /opt/zimbra/lib/jars/zimbracommon.jar /opt/zimbra/jetty/webapps/zimlet/WEB-INF/lib/
$ ln -s /opt/zimbra/lib/jars/zimbrasoap.jar /opt/zimbra/jetty/webapps/zimlet/WEB-INF/lib/
$ ln -s /opt/zimbra/lib/jars/zimbraclient.jar /opt/zimbra/jetty/webapps/zimlet/WEB-INF/lib/
$ ln -s /opt/zimbra/lib/jars/zimbrastore.jar /opt/zimbra/jetty/webapps/zimlet/WEB-INF/lib/

If your jsp uses a tag defined in zimbra webapp, taglib and tags needs to be added as a link.

$ ln -s /opt/zimbra/jetty/webapps/zimbra/WEB-INF/lib/zm-taglib-*.jar /opt/zimbra/jetty/webapps/zimlet/WEB-INF/lib/
$ ln -s /opt/zimbra/jetty/webapps/zimbra/WEB-INF/tags /opt/zimbra/jetty/webapps/zimlet/WEB-INF
$ ln -s /opt/zimbra/jetty/webapps/zimbra/WEB-INF/tlds /opt/zimbra/jetty/webapps/zimlet/WEB-INF

mailboxd needs to restart after the change.

$ zmmailboxdctl restart

See also the caveat described in #JSP support in 6.0 (CHANGED FROM 5.x)

See also

  • ZimletJSP contains outdated information about ZCS 4.5 and before.
Verified Against: Date Created: 7/16/2009
Article ID: https://wiki.zimbra.com/index.php?title=Zimlet_JSP Date Modified: 2021-02-24



Try Zimbra

Try Zimbra Collaboration with a 60-day free trial.
Get it now »

Want to get involved?

You can contribute in the Community, Wiki, Code, or development of Zimlets.
Find out more. »

Looking for a Video?

Visit our YouTube channel to get the latest webinars, technology news, product overviews, and so much more.
Go to the YouTube channel »

Jump to: navigation, search