Hi,
Am Samstag, den 31.05.2008, 14:16 +0530 schrieb janandith jayawardena:
> Hi ,
>
> Scala has an interpreter which I intend to call in the eval method of my
> script engine to run scripts.
Sounds good.
> To check whether it's loading I did the following,
>
> I have set the mime type using "setMimeTypes" as "text/scala" and name using
> "setNames" as "scala" in the Script Factory. Using the example provided in
> discover Sling in 15 minutes as a reference I edited the html.esp as
> follows,
>
> <html>
> <body>
> <script type="text/scala" name="scala">
> document.write("<p><b>Hello World!<\/b>")
> </script>
> </body>
> </html>
>
> then I renamed it as html.scala.
That may only work if the scala interpreter supports templated scripts
like JSP does. If the scala interpreter expects pure Scala code, this
will most probably blow it away ... The JavaScript support has both:
plain Java Script (indicated by the file extension .ecma) and templated
script (extension .esp). When reading .esp data, all template text is
on-the-fly converted to pure java by wrapping in out.write() statements.
But, naming the script as html.scala is correct provided your
ScriptEngine provider supports the .scala extension.
>
> using curl I deployed the html.scala file to content/mynode.
>
> when i navigate to "http://localhost:8888/content/mynode.html" the browser
> doesn't show the "Hello World!" message .
>
> 1. I think there's something wrong in this approach though I can't figure it
> out. Should I change some setting in sling to display the message ?.
No, probably the code is just not Scala code and your Scala interpreter
bombs. Try to wrap the above HTML code with Scala output generation
statements and try again.
I assume you have got some Exceptions from the Scala interpreter when
running above file as a Scala script. Have a look at the log file.
>
> 2. How can I run scripts written in languages other than javascript that's
> currently supported by sling ?
Provided your ScriptEngineFactory is registered for the right file
extension, it should work out of the box.
Hope this helps.
Regards
Felix