Results 1 to 5 of 5

Thread: Getting a response from a local JSP page

  1. #1
    Join Date
    Jan 2009
    Posts
    12
    Rep Power
    6

    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.

  2. #2
    Join Date
    Mar 2007
    Location
    Ferrara, Italy
    Posts
    55
    Rep Power
    8

    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.

  3. #3
    Join Date
    Jan 2009
    Posts
    12
    Rep Power
    6

    Default

    It appears that even with a _dev Zimlet the JSP is compiled and cached; see post http://www.zimbra.com/forums/zimlets...tml#post117155.

    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.

  4. #4
    Join Date
    Jan 2009
    Location
    Denmark
    Posts
    7
    Rep Power
    6

    Default

    Yep, it's being cached somewhere, so apparently you have to do a zmmailboxdctl restart every time you change the jsp

  5. #5
    Join Date
    Mar 2007
    Location
    Ferrara, Italy
    Posts
    55
    Rep Power
    8

    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

Similar Threads

  1. postfix transport maps
    By pheonix1t in forum Administrators
    Replies: 12
    Last Post: 01-17-2009, 11:42 PM
  2. Zimbra fails after working for 2 weeks
    By Linsys in forum Administrators
    Replies: 10
    Last Post: 10-07-2008, 01:42 AM
  3. [SOLVED] Edit Button in Documents Gray After Upgrade
    By weathertation in forum Administrators
    Replies: 10
    Last Post: 05-14-2008, 01:47 PM
  4. Reference a local jsp page in a zimlet
    By newtonh20 in forum Zimlets
    Replies: 4
    Last Post: 01-29-2008, 06:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •