Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

"ReferenceError: "myIpAddr" is not defined, when call JavaScript from java

843790Mar 11 2010 — edited Mar 11 2010
Hi developers,

My java application was trying to issue a http request via proxy auto-config. So, I did below jobs

1. Read URL of *.pac from registry
2. Call FindProxyForURL from java, the code is like below
ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName("JavaScript");
engine.eval(autoProxyScript);
Invocable inv = (Invocable) engine;
Object obj = inv.invokeFunction("FindProxyForURL",
"http://java.sun.com/",
"java.sun.com");

However, I got "ReferenceError: "myIpAddress" is not defined

I can not change the script on server to add a function like "myIpAddress", I am wordering why IE or mozilla can call it successfully and get proxy server, while Java failed to do that.

I got a ugly solution by calling "pacparser" by jni. But I really hope I can get a better solution.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 8 2010
Added on Mar 11 2010
1 comment
347 views