Zimlet Developers Guide:Java and JSP: Difference between revisions

No edit summary
No edit summary
 
(20 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{BC|Community Sandbox}}
__FORCETOC__
<div class="col-md-12 ibox-content">
= Zimlet Developers Guide: Java and JSP =
{{KB|{{Unsupported}}|{{ZCS 8.0}}|{{ZCS 7.0}}|}}
{{Archive}}
{| cellspacing="0" cellpadding="5" style="border: 1px solid rgb(153, 153, 170); margin: 0pt 0.5em 0.5em 0pt; float: none; background-color: rgb(249, 249, 255);"
{| cellspacing="0" cellpadding="5" style="border: 1px solid rgb(153, 153, 170); margin: 0pt 0.5em 0.5em 0pt; float: none; background-color: rgb(249, 249, 255);"
|[[Image:zdg-6-menu-icon-zimbra.jpg|20px]]
|[[Image:zdg-6-menu-icon-zimbra.jpg|20px]]
|[[ZCS 6.0:Zimlet Developers Guide:Introduction|Introduction]]
|[[Zimlet Developers Guide:Introduction|Introduction]]
|style="border-left: 1px solid rgb(153, 153, 170);"|[[Image:zdg-6-menu-icon-green-flag.png|20px]]
|style="border-left: 1px solid rgb(153, 153, 170);"|[[Image:zdg-6-menu-icon-green-flag.png|20px]]
|[[ZCS 6.0:Zimlet Developers Guide:Getting Started|Getting Started]]
|[[Zimlet Developers Guide:Getting Started|Getting Started]]
|style="border-left: 1px solid rgb(153, 153, 170);"|[[Image:zdg-6-menu-icon-terminal.png|20px]]
|style="border-left: 1px solid rgb(153, 153, 170);"|[[Image:zdg-6-menu-icon-terminal.png|20px]]
|[[ZCS 6.0:Zimlet Developers Guide:Dev Environment Setup|Dev Environment Setup]]
|[[Zimlet Developers Guide:Dev Environment Setup|Dev Environment Setup]]
|style="border-left: 1px solid rgb(153, 153, 170);"|[[Image:zdg-6-menu-icon-gear.png|20px]]
|style="border-left: 1px solid rgb(153, 153, 170);"|[[Image:zdg-6-menu-icon-gear.png|20px]]
|[[ZCS 6.0:Zimlet Developers Guide:Developing Zimlets|Developing Zimlets]]
|[[Zimlet Developers Guide:Developing Zimlets|Developing Zimlets]]
|style="border-left: 1px solid rgb(153, 153, 170);"|[[Image:zdg-6-menu-icon-advanced.jpg|20px]]
|style="border-left: 1px solid rgb(153, 153, 170);"|[[Image:zdg-6-menu-icon-advanced.jpg|20px]]
|
|


     {|
     {|
     |[[ZCS 6.0:Zimlet Developers Guide:Advanced Concepts|Advanced Concepts]]
     |[[Zimlet Developers Guide:Advanced Concepts|Advanced Concepts]]
    |-
    |[[Zimlet Developers Guide:Application Context|Application Context]]
     |-
     |-
     |[[ZCS 6.0:Zimlet Developers Guide:Templates|Templates]]
     |[[Zimlet Developers Guide:Templates|Templates]]
     |-
     |-
     |'''Java & JSP'''
     |'''Java & JSP'''
    |-
    |[[Zimlet Developers Guide:Portal|Portal]]
    |-
    |[[Zimlet Developers Guide:Zimlet Tab|Zimlet Tab]]
    |-
    |[[Zimlet Developers Guide:Internationalization|Internationalization]]
     |}
     |}


|style="border-left: 1px solid rgb(153, 153, 170);"|[[Image:zdg-6-menu-icon-library.jpg|20px]]
|style="border-left: 1px solid rgb(153, 153, 170);"|[[Image:zdg-6-menu-icon-library.jpg|20px]]
|[[ZCS 6.0:Zimlet Developers Guide:Zimlet API Specifications|API Specifications]]
|[[Zimlet Developers Guide:Zimlet API Specifications|API Specifications]]
|style="border-left: 1px solid rgb(153, 153, 170);"|[[Image:zdg-6-menu-icon-checkbox.jpg|20px]]
|style="border-left: 1px solid rgb(153, 153, 170);"|[[Image:zdg-6-menu-icon-checkbox.jpg|20px]]
|[[ZCS 6.0:Zimlet Developers Guide:Example Zimlets|Example Zimlets]]
|[[Zimlet Developers Guide:Example Zimlets|Example Zimlets]]
|}
|}






This section describes how to incorporate Java and JSP with your zimlets.
This section describes how to incorporate Java and JSP in your zimlets.


== JSP ==
== 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.
JavaServer Pages (JSP) allow you to create dynamic page content with Java. The JSP files included with your zimlet are executed on the Zimbra server and can call Java APIs to perform server-side data retrieval and manipulation.  


To reference a JSP page from your zimlet, you need the page URL (sometimes referred to as the "resource location").
To reference a JSP file from your zimlet, you need the page URL (sometimes referred to as the "resource location"). The following sections describe how to determine the JSP file resource location.


=== Calling from Zimlet Definition File ===
=== Calling JSP from Zimlet Definition File ===


If you plan to call your JSP page from the [[ZCS_6.0:Zimlet_Developers_Guide:Zimlet_Definition_File_Reference|Zimlet Definition File]] (for example, from an <code><actionUrl></code> element), the path to the JSP is:
If you plan to call your JSP page from the [[Zimlet_Developers_Guide:Zimlet_Definition_File_Reference|Zimlet Definition File]] (for example, from an <code><actionUrl></code> element), the path to the JSP is:


<pre>
<pre>
Line 49: Line 64:
</pre>
</pre>


If using the [[ZCS_6.0:Zimlet_Developers_Guide:Dev_Environment_Setup#Zimlet_Development_Directory|Development Directory]], the path will include <code>_dev</code>. For example:
If using the [[Zimlet_Developers_Guide:Dev_Environment_Setup#Zimlet_Development_Directory|Development Directory]], the path should include <code>_dev</code>. For example:


<pre>
<pre>
Line 55: Line 70:
</pre>
</pre>


=== Calling from Zimlet Handler Object ===
=== Calling JSP from Zimlet Handler Object ===


If you plan to call your JSP page from your Zimlet Handler Object in JavaScript, you can use <code>ZimletBaseObject.getResource()</code>. For example:
If you plan to call your JSP page from your Zimlet Handler Object in JavaScript, you can use <code>ZimletBaseObject.getResource()</code> to determine the JSP page resource location. For example:


<pre>
<pre>
Line 63: Line 78:
</pre>
</pre>


See the [http://files.zimbra.com/docs/zimlet/zcs/6.0/jsdocs/symbols/ZmZimletBase.html JavaScript API Reference] for more information.
See the [http://files.zimbra.com/docs/zimlet/zcs/6.0/jsdocs/symbols/ZmZimletBase.html JavaScript API Reference] for more information on the <code>ZimetBaseObject</code> class and associated methods.


Once you have the JSP resource location, you can invoke the page using <code>AjxRpc.invoke</code>.
Once you have the JSP resource location, you can invoke the page using <code>AjxRpc.invoke</code>.
Line 73: Line 88:
== Java ==
== Java ==


The JSP page can call the Java API code. You can also call your own custom Java classes and those classes need to be included with the zimlet in the form of a JAR file ("Java Archive"). The JAR file format allows you to bundle multiple Java files into a single file.
A JSP page can call Java API code. Additionally, you can also call your own custom Java classes. Those classes need to be included with the zimlet in the form of a JAR file ("Java Archive"). The JAR file format allows you to bundle multiple Java files into a single file.


=== Using a JAR file with Zimlet Bundle ===
=== Using a JAR file with Zimlet Bundle ===


Your JAR file should be included in the root of your Zimlet Bundle ZIP. When you deploy your zimlet using the [[ZCS_6.0:Zimlet_Developers_Guide:Getting_Started|Administration Console (or via the Command Line)]], the JAR file Java classes will be deployed into the Zimbra server. You will need to restart your server for the Java classes to become available.
Your JAR file should be included in the root of your Zimlet Bundle ZIP. When you deploy your zimlet using the [[Zimlet_Developers_Guide:Getting_Started|Administration Console (or via the Command Line)]], the JAR file Java classes will be deployed into the Zimbra server. You will need to restart your server for the Java classes to become available.


=== Using a JAR file with the Development Directory ===
=== Using a JAR file with the Development Directory ===


If using the [[ZCS_6.0:Zimlet_Developers_Guide:Dev_Environment_Setup#Zimlet_Development_Directory|Development Directory]], you need to manually copy the JAR file into place and restart your server for the Java classes to become available.
If using the [[Zimlet_Developers_Guide:Dev_Environment_Setup#Zimlet_Development_Directory|Development Directory]], you need to manually copy the JAR file into place and restart your server for the Java classes to become available.
 
The location to copy the JAR file is: <code>{zcs-install-dir}/jetty/webapps/zimlet/WEB-INF/lib</code>


The location to copy the JAR file to is: <code>{zcs-install-dir}/jetty/webapps/zimlet/WEB-INF/lib</code>
Note: Create the <code>lib</code> directory if it does not exist.


== Useful Links ==
== Links to Examples ==


<ul>
<ul>
<li>[[ZCS_6.0:Zimlet_Developers_Guide:Examples:Simple_JSP_via_Action|Examples > Simple JSP (via Action)]]</li>
<li>[[ZCS 6.0:Zimlet_Developers_Guide:Examples:Simple_JSP_via_Action|Examples > Simple JSP (via Action)]]</li>
<li>[[ZCS_6.0:Zimlet_Developers_Guide:Examples:Simple_JSP_via_Handler|Examples > Simple JSP (via JavaScript Handler Object)]]</li>
<li>[[ZCS 6.0:Zimlet_Developers_Guide:Examples:Simple_JSP_via_Handler|Examples > Simple JSP (via JavaScript Handler Object)]]</li>
<li>[[ZCS_6.0:Zimlet_Developers_Guide:Examples:Simple_JSP_via_Ajax|Examples > Simple JSP (via HTTP GET)]]</li>
<li>[[ZCS 6.0:Zimlet_Developers_Guide:Examples:Simple_JSP_via_Ajax|Examples > Simple JSP (via HTTP GET)]]</li>
<li>[[ZCS_6.0:Zimlet_Developers_Guide:Examples:Simple_JSP_via_Ajax_Async|Examples > Simple JSP (via Ajax Asynchronous)]]</li>
<li>[[ZCS 6.0:Zimlet_Developers_Guide:Examples:Simple_JSP_via_Ajax_Async|Examples > Simple JSP (via Ajax Asynchronous)]]</li>
<li>[[ZCS_6.0:Zimlet_Developers_Guide:Examples:JSP_with_custom_Java_classes|JSP with custom Java classes]]</li>
<li>[[ZCS 6.0:Zimlet_Developers_Guide:Examples:JSP_with_custom_Java_classes|JSP with custom Java classes]]</li>
</ul>
</ul>






{{Article Footer|Zimbra Collaboration Suite 6.0|12/22/2009}}
{{Article Footer|Zimbra Collaboration Server 7.0|12/22/2009}}
 
 
[[Category:Developers]]
[[Category:Zimlets]]
[[Category:ZCS 7.0]]
[[Category:ZCS 6.0]]

Latest revision as of 12:40, 16 July 2015

Zimlet Developers Guide: Java and JSP

   KB 3269        Last updated on 2015-07-16  




0.00
(0 votes)


Zdg-6-menu-icon-zimbra.jpg Introduction Zdg-6-menu-icon-green-flag.png Getting Started Zdg-6-menu-icon-terminal.png Dev Environment Setup Zdg-6-menu-icon-gear.png Developing Zimlets Zdg-6-menu-icon-advanced.jpg
Advanced Concepts
Application Context
Templates
Java & JSP
Portal
Zimlet Tab
Internationalization
Zdg-6-menu-icon-library.jpg API Specifications Zdg-6-menu-icon-checkbox.jpg Example Zimlets


This section describes how to incorporate Java and JSP in your zimlets.

JSP

JavaServer Pages (JSP) allow you to create dynamic page content with Java. The JSP files included with your zimlet are executed on the Zimbra server and can call Java APIs to perform server-side data retrieval and manipulation.

To reference a JSP file from your zimlet, you need the page URL (sometimes referred to as the "resource location"). The following sections describe how to determine the JSP file resource location.

Calling JSP 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" />

If using the Development Directory, the path should include _dev. For example:

<actionUrl method="get" target="/service/zimlet/_dev/com_zimbra_simplejspaction/jspfile.jsp" />

Calling JSP from Zimlet Handler Object

If you plan to call your JSP page from your Zimlet Handler Object in JavaScript, you can use ZimletBaseObject.getResource() to determine the JSP page resource location. For example:

var jspUrl = this.getResource("jspfile.jsp");

See the JavaScript API Reference for more information on the ZimetBaseObject class and associated methods.

Once you have the JSP resource location, you can invoke the page using AjxRpc.invoke.

var response = AjxRpc.invoke(null, jspUrl, null, null, true);

Java

A JSP page can call Java API code. Additionally, you can also call your own custom Java classes. Those classes need to be included with the zimlet in the form of a JAR file ("Java Archive"). The JAR file format allows you to bundle multiple Java files into a single file.

Using a JAR file with Zimlet Bundle

Your JAR file should be included in the root of your Zimlet Bundle ZIP. When you deploy your zimlet using the Administration Console (or via the Command Line), the JAR file Java classes will be deployed into the Zimbra server. You will need to restart your server for the Java classes to become available.

Using a JAR file with the Development Directory

If using the Development Directory, you need to manually copy the JAR file into place and restart your server for the Java classes to become available.

The location to copy the JAR file is: {zcs-install-dir}/jetty/webapps/zimlet/WEB-INF/lib

Note: Create the lib directory if it does not exist.

Links to Examples


Verified Against: Zimbra Collaboration Server 7.0 Date Created: 12/22/2009
Article ID: https://wiki.zimbra.com/index.php?title=Zimlet_Developers_Guide:Java_and_JSP Date Modified: 2015-07-16



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