Hi,
I have been trying out some other features and trying to get access to the HttpServletRequest in a script block in my server-side DS definition. I am using Isomorphic
(v10.1p_2016-02-28/Pro Deployment (I also tested 2015-12-10 and couldn't get that to work either)
When I make the request for the following I get the following error in my server logs (Jetty):
I also tried writing my script in groovy and using a different AppServer (WebSphere) and got the following stack trace:
According to the documentation for OperationBinding.script: " Scriptlets also have access to a set of contextual variables related to the Servlets API, as follows:
Can you suggest what I might be doing wrong?
Thanks!
I have been trying out some other features and trying to get access to the HttpServletRequest in a script block in my server-side DS definition. I am using Isomorphic
(v10.1p_2016-02-28/Pro Deployment (I also tested 2015-12-10 and couldn't get that to work either)
Code:
<operationBinding operationType="fetch" operationId="fetchEncoding"> <script language="javascript"> var response = servletRequest.getHeader("Accept-Encoding"); response; </script> </operationBinding>
Code:
=== 2016-02-29 14:00:42,990 [9-22] WARN RequestContext - dsRequest.execute() failed: javax.script.ScriptException: ReferenceError: "servletRequest" is not defined in nashorn:mozilla_compat.js at line number 67 at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:467) at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:451) at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:403) at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:399) at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155) at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
Code:
[29/02/16 14:11:54:079 GMT] 00000273 SystemOut O === 2016-02-29 14:11:54,079 [ : 1] WARN RequestContext - dsRequest.execute() failed: groovy.lang.MissingPropertyException: No such property: servletRequest for class: Script1 at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50) at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231) at Script1.run(Script1.groovy:10)
- servletRequest: the current ServletRequest"
Can you suggest what I might be doing wrong?
Thanks!
Comment