How to call standard Java classes from Ecmascript
To import Java classes from Ecmascript, use importPackage() statement on top of your script. For example, with Ecmascript:

importPackage(Packages.java.net);
importPackage(Packages.java.io);
importPackage(Packages.java.lang);

Java classes can then be instatiated directly:

var url = new java.net.URL("http://www.google.com");
var connection = url.openConnection();
var reader = new java.io.BufferedReader(new java.io.InputStreamReader( connection.getInputStream()));
var response = new StringBuilder();
...
...

How to import external libraries into scripts

To extend GreasySpoon with external jar libraries, simply copy your jar files into $gs/lib and import them in your scripts.

For example, saying you want to add html parser from http://htmlparser.sourceforge.net:

  • download and copy htmlparser.jar and htmllexer.jar to $gs/lib. Libraries will be added in real time to GreasySpoon engine (no restart needed).
  • Import and call your libraries in your scripts using

    import org.htmlparser.*;


Note: Adding external packages does not require to restart GreasySpoon, except when upgrading an already loaded lib. In that case, stop greasyspoon, include the new library version then restart greasyspoon.
Can I use my preferred editor to developp scripts (vim, eclipse, ...) ?
Yes. Scripts are located in $gs/serverscripts directory, and can be edited directly whatever the edition tool you want to use.

Just take care not to alter control header and to use UTF-8 encoding when saving your script.

Changes made by that way will also be detected in real time.

How to synchronize scripts between several GS servers ?
GreasySpoon scripts are located by default in $gs/serverscripts directory, and scripts modifications are monitored by GS.

To synchronize multiple instances, easiest way is to use a shared directory using NFS for example.

Any alternative like rsync or similar solutions will also work.
Squid authenticated user is not displayed in GS
In squid.conf, uncomment or add following line:

icap_client_username_header X-Client-Username


On GreasySpoon side, in services.properties file, configure following line:

SpoonScript.icapuserheader=x-client-username


Reload both to make changes effective.
Can I call services on https ?
Yes, using an HTTP proxy supporting this feature and specific configurations.

This feature is supported since Squid 3.1.x, see Squid configuration for details.

WARNING: SSL bump might be illegal or create security flaw for your users. It should not be done without end-user's knowledge and agreement, or for domains which you are not the authority owner.
Can I work on binary content ?
No, GreasySpoon was designed to only handle textual content.
If you need to handle binary content, consider using L3WS WebflowAdapter ICAP Server instead.
Help ! GreasySpoon is too slow
While GreasySpoon engine was able to provide production compatible performances, the core engine has not evolved since several years now.

If you are getting poor performances with GreasySpoon, consider using WebflowAdapter instead.
I'm getting an error with GreasySpoon / Squid / ...
GreasySpoon project is no longer maintain/supported since several years now. In case of issue, you can check its source code to to fix it by yourself, as L3WS will by no mean provide support or maintenance on Greasyspoon. Otherwise, consider using L3WS WebflowAdapter ICAP Server instead.
I can't find any documentation for GreasySpoon
Please take time to browse and read this site.

If you don't know where to start, install GS and have a look on provided samples, which provides short still complete enough examples to give you the basics to build up your first services.

If you don't have time to do that, please consider switching to L3WS WebflowAdapter ICAP Server solution.