AnsweredAssumed Answered

Java Web Script first steps

Question asked by nm_santos on Jun 6, 2012
Latest reply on Jun 11, 2012 by abarisone
Hi everyone,

I've managed to complete the tutorial regarding java-based web scripts.

Now, I tried modifying the Javadir class so I could try out some things.

Here's how it looks now:

public class JavaDir extends DeclarativeWebScript
   protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
      String user = null;
      user = req.getParameter("username");
      Map<String, Object> model = new HashMap<String, Object>();
      model.put("username", user);
      return model;

Here are my descriptors and template files:

  <shortname>Folder Listing Utility</shortname>
  <description>Java-backed implementation of listing folder contents

  <title>Folder java funciona</title>
      ${username} funciona
All I want now, is to display the username received. (the URI is ttp://localhost:8080/alfresco/service/javadir/{username}

however, when I run the script, I get the following error:

500 Description:    An error inside the HTTP server which prevented it from fulfilling the request.

Message:   05060023 Wrapped Exception (with status template): 05060003 Error during processing of the template 'Expression username is undefined on line 5, column 19 in org/example/javadir.get.html.ftl.'. Please contact your system administrator.

Exception:   freemarker.core.InvalidReferenceException - Expression username is undefined on line 5, column 19 in org/example/javadir.get.html.ftl.

Which is in regards to ${username}.

What am I doing wrong?