Zimlet Developers Guide:Java and JSP
Introduction | Getting Started | Dev Environment Setup | Developing Zimlets |
|
API Specifications | Example Zimlets |
This section describes how to incorporate Java and JSP with your zimlets.
JSP
JavaServer Pages (JSP) allow you to create dynamic page content with Java. The JSP pages included with your zimlet are executed on the Zimbra server.
To reference a JSP page from your zimlet, you need the page URL (sometimes referred to as the "resource location").
Calling from Zimlet Definition File
If you plan to call your JSP page from the Zimlet Definition File (for example, from an <actionUrl>
element), the path to the JSP is:
/service/zimlet/{zimlet-name}/{jsp-file-name}.jsp
For example, calling a JSP file named "jspfile.jsp" (located at the root of your zimlet package) from an <actionUrl>
element:
<actionUrl method="get" target="/service/zimlet/com_zimbra_simplejspaction/jspfile.jsp" />
Note: if using the Development Directory, the path will include _dev
. For example:
<actionUrl method="get" target="/service/zimlet/_dev/com_zimbra_simplejspaction/jspfile.jsp" />
Calling from Zimlet Handler Object
If you plan to call your JSP page from your Zimlet Handler Object in JavaScript, you can use ZimletBaseObject.getResource()
. For example:
var jspUrl = this.getResource("jspfile.jsp");
See the JavaScript API Reference for more information.
Once you have the JSP resource location, you can invoke the page using AjxRpc.invoke
.
var response = AjxRpc.invoke(null, jspUrl, null, null, true);
Useful Links
- Examples > Simple JSP (via Action)
- Examples > Simple JSP (via JavaScript Handler Object)
- Examples > Simple JSP (via HTTP GET)
- Examples > Simple JSP (via Ajax Asynchronous)
- JSP with custom Java classes