Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A mistery for me...

Status
Not open for further replies.

alextilt

MIS
Feb 21, 2012
2
PT
Hi
Consider a servelet that returns a html page with embedded javascript:


<head>
...

<script src="./js/foo/jfoo.js?seq=2" type="text/javascript"></script>
...
</head>
...

<body onload="javascript:FooOnLoad();" onunload="javascript:FooOnUnload();">
...

</body>

</html>

_________________________-


jf.js

...

function fInit()
{
if (jf == null)
{
jfElem = document.getElementById(F_ID);
if (jfpElem != null) {
try {
jf = new Jf(jfElem);
jfoo.JSDraw(null, RECENTER_ZOOM, 0);
} catch (e) {
alert("Error [jfInit]:\n" + e);
}
} else {
alert("Error [jfInit]:\nDiv '" + F_ID + "' not found");
}
}
};

and the javascript creates an instance of Jf. Jf is declared ina Java file...

Can this be possible?
Can javascript call java (non-applet) code?
If nor, which technologies could be used to make this?

Thanks a lot

Alex
 
Hi

As Java runs on the server and JavaScript runs on the client machine, they can only change text data through HTTP requests. That text can be JSON, from which the most elementary objects will be instantiated.

Regarding the transfer, see forum1600.

By the way, do not specify [tt]javascript:[/tt] pseudo-protocol in event handlers. It should be used only when putting JavaScript code somewhere where an URL is expected.


Feherke.
 
Ok, thanks
But in that perspective how can javascript ask to create an object and that object is created on the server?!
Any simple sample for this?
Thanks a lot

Alex
 
Hi

Alex said:
But in that perspective how can javascript ask to create an object and that object is created on the server?!
Sorry, I do not understand this.

Your above question sounds like you have something like Java remote method invocation in mind. Never used JRMI, but if it is based on the same principle as RPC, then what I wrote earlier still applies : only text will be transferred, with the possibility to automate some simple object instantiations after that.

I am quite sure your heading towards a dead end. But for now I have no idea what to suggest instead. Tell us about that Jf object so we understand you goal.


Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top