So when some action is performed on my Zimlet (e.g. user right clicks on the icon), I want the JSP to be able to get at the users username, or email address, or some other attribute....and then return some data to the Zimlet based on who they are.
So how does one get at that Zimbra data from a JSP?
I've tried to use the SalesForce Zimlet as an example and have added some of it to my JSP app...
Code:
<%@ page language="java" import="com.sun.jndi.ldap.*, java.io.*, java.util.*, javax.naming.*, javax.naming.dir
ectory.*"%>
<%@ page import="com.zimbra.cs.account.Provisioning" %>
<%@ page import="com.zimbra.cs.account.Account" %>
<%@ page import="com.zimbra.cs.account.AuthToken" %>
<%@ page import="com.zimbra.cs.mailbox.Mailbox" %>
<%@ page import="com.zimbra.cs.index.MailboxIndex" %>
<%@ page import="com.zimbra.cs.account.AuthTokenException" %>
<%@ page import="com.zimbra.cs.service.ServiceException" %>
<%@ page import="com.zimbra.cs.index.queryparser.ParseException" %>
<%@ page import="com.zimbra.cs.index.ZimbraQueryResults" %>
<%@ page import="com.zimbra.cs.index.ZimbraHit" %>
<%@ page import="com.zimbra.cs.index.MessageHit" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.util.Collection" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="com.zimbra.cs.mailbox.Appointment" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Calendar" %>
....OTHER CODE IN HERE.....
Cookie[] cookies = request.getCookies();
String authTokenString = "";
for (Cookie cooky : cookies) {
if (cooky.getName().equals("ZM_AUTH_TOKEN")) {
authTokenString = cooky.getValue();
}
}
try {
AuthToken authToken = AuthToken.getAuthToken(authTokenString);
Account acct = Provisioning.getInstance().getAccountById(authToken.getAccountId());
Mailbox mbox = Mailbox.getMailboxByAccount(acct);
output.println("<br/><br/>" + acct + " " + mbox);
} catch (AuthTokenException e) {
e.printStackTrace();
} catch (ServiceException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
} But I get errors like such....
Code:
HTTP ERROR: 500
PWC6033: Unable to compile class for JSP
PWC6199: Generated servlet error:
Only a type can be imported. com.zimbra.cs.service.ServiceException resolves to a package
PWC6197: An error occurred at line: 35 in the jsp file: /zimlet/_dev/edu_wiu_email_starnum/ldap.jsp
PWC6199: Generated servlet error:
The method getAccountById(String) is undefined for the type Provisioning
PWC6197: An error occurred at line: 35 in the jsp file: /zimlet/_dev/edu_wiu_email_starnum/ldap.jsp
PWC6199: Generated servlet error:
The method getMailboxByAccount(Account) is undefined for the type Mailbox
PWC6197: An error occurred at line: 35 in the jsp file: /zimlet/_dev/edu_wiu_email_starnum/ldap.jsp
PWC6199: Generated servlet error:
ServiceException cannot be resolved to a type
PWC6197: An error occurred at line: 35 in the jsp file: /zimlet/_dev/edu_wiu_email_starnum/ldap.jsp
PWC6199: Generated servlet error:
e cannot be resolved
RequestURI=/service/zimlet/_dev/edu_wiu_email_starnum/ldap.jsp
Any ideas?
Thanks,
Matt