Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
 
Go Back   Zimbra - Forums > Zimbra Collaboration Suite > Zimlets

Welcome to the Zimbra - Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-16-2009, 12:26 AM
Junior Member
 
Posts: 8
Default Getting a response from a local JSP page

I cannot get my JavaScript to successfully get a response from a JSP file.

The Javascript is
Code:
function Com_Mydomain_Test() {} ;
Com_Mydomain_Test.prototype = new ZmZimletBase() ;
Com_Mydomain_Test.prototype.constructor = Com_Mydomain_Test ;

Com_Mydomain_Test.prototype.init = function ()
{
  var url = this.getResource('test.jsp') ;
  var result = AjxRpc.invoke(null, url, null, null, true) ;
  console.log(result) ;
}
The JSP file is test.jsp:
Code:
<html>
<body>
<p>Hello.</p>
</body>
</html>
Using Firebug, I see that the response comes back
Code:
Date	Mon, 16 Feb 2009 07:11:08 GMT
Content-Type	text/html
Content-Length	0
I know that the JSP file is being accessed because if I misspell the JSP file (e.g., "testx.jsp") I get a 404 error. Looking at the variable result using the Firebug console.log function, the value of its success property is "true" but its text property is the empty string.
Reply With Quote
  #2 (permalink)  
Old 02-19-2009, 06:17 AM
Active Member
 
Posts: 49
Default

Try with the PrintWriter.println function, you've got more control when debuggin.

Code:
        PrintWriter pw = response.getWriter();
        pw.println(msg);

And try to call your JSP from a JS, like this:
Code:
[...]
    AjxRpc.invoke(requestParams, serverURL, reqHeader,  new AjxCallback(this, this._resultCallback), false);
[...]
It_Open1_Zimlet.prototype._resultCallback = function(result) {
    this.displayStatusMessage(result.text);
};
You gotta peek around the Zimbra source code a bit to get the hang of it... Try by first checking ZmZimletBase.js, one of the most important ones.
Reply With Quote
  #3 (permalink)  
Old 02-19-2009, 06:50 AM
Junior Member
 
Posts: 8
Default

It appears that even with a _dev Zimlet the JSP is compiled and cached; see post Debugging Zimlet JSP.

That being said, it would be helpful for _dev Zimlets that any JSP files be re-compiled at each browser F5 hard refresh. Or at the very least, make the recompilation each refresh a configuration option.
Reply With Quote
  #4 (permalink)  
Old 02-19-2009, 08:26 AM
Junior Member
 
Posts: 6
Default

Yep, it's being cached somewhere, so apparently you have to do a zmmailboxdctl restart every time you change the jsp
Reply With Quote
  #5 (permalink)  
Old 02-20-2009, 01:30 AM
Active Member
 
Posts: 49
Default

I usually do two things: when working on the js and xml file I go the _dev way.
Otherwise I fully deploy from a zip file, because when working with a jsp you gotta restart mailboxd anyways(guess there's a possible shortcut to it, but I'm not aware of it yet...:-( ). Therefore it's better to avoid _dev, because when fully deploying you gain the following:

- working .properties substitution
- getConfig working
- no jsp path problems (I used to make a symlink in _dev to the jsp file once - I could have hardcoded the _dev jsp filepath as well in the source)
- more production-like testing (of course supposing you've got a dedicated test box for this!)
- and maybe more, but don't recall any further pros right now...

Try doing zimlet programming without too many JSP-JS hoppings then ;-)

About reloading and jsp caching, I set an alias in ~/.bashrc (remember to source it or relogin the first time)

Code:
alias zimrest='rm -rf /opt/work/temp/it_005fopen1_005fzimlet ; mv /opt/zimbra/jetty-6.1.5/work/service/jsp/org/apache/jsp/zimlet/it_005fopen1_005fzimlet/ /opt/work/temp/ && zmmailboxdctl restart'
checky your zimlet path first, and modify the alias accordingly. Could have used a script as well, but this way I solved my need faster. Anyways we don't need mission-critical checks here. The && is sufficient enough ;-9
Reply With Quote
Reply


Thread Tools
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

Zimbrablog.com




 

Search Engine Optimization by vBSEO 3.1.0