Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > J2EE
|
J2EE General J2EE (Java 2 Enterprise Edition) discussions. Questions not specific to EE will be redirected elsewhere.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the J2EE section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 4th, 2004, 10:36 AM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Calling Java Method via javascript

Dear ALL,
 Please can you help me. Please.........

i want to call java function from Javascript. i will send a string from javascript to Java file and the Java will return for me the Same String follow by "!!!".

iam using <OBJECT> and to call the CAB file.

Please i need an example.



 
Old August 5th, 2004, 06:38 AM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i want to call java function from Javascript.
i will send a string from javascript to Java file.
********************
Ans :
<script language="javascript">
function call() {

document.form[0].action="loginAction.do?str=" + "HelloWorld";
document.form[0].submit();

}
</script>
********************

i will send a string from javascript to Java file and the Java will return for me the Same String follow by "!!!".
****************
Ans :

public LoginAction {

public execute() {
    String str = (String)request.getParameter ("str");
    str += "!!!";

...........
}


}
****************
 
Old August 6th, 2004, 10:00 AM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Really Thanks for your help.

please i tried but it is not working, please i thought i did not get the solution.

please send to me a complete example . Please Please.

Thank you

Quote:
quote:Originally posted by malar
 i want to call java function from Javascript.
i will send a string from javascript to Java file.
********************
Ans :
<script language="javascript">
function call() {

document.form[0].action="loginAction.do?str=" + "HelloWorld";
document.form[0].submit();

}
</script>
********************

i will send a string from javascript to Java file and the Java will return for me the Same String follow by "!!!".
****************
Ans :

public LoginAction {

public execute() {
    String str = (String)request.getParameter ("str");
    str += "!!!";

...........
}


}
****************

 
Old August 6th, 2004, 10:29 AM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, this is my Java file :
============================
import javax.swing.*;
class TestJava
{
public static void main (String args[])
{}
    public String SendStr (String lStr)
    {
      return lStr + "!!!";
    }
}

============================
And This is my HTML and Javascript code:
============================
<OBJECT ID="Test" height=0 width=0
CLASSID="CLSID:18F79884-E141-49E4-AB97-99FF47F71C9E" CODEBASE="TestJava.CAB" VIEWASTEXT>
</OBJECT>

<script language="Javascript">
var Installed;
Installed = false;
try
{
  if (Test==null)
    Installed = false;
  else
    Installed = true;
}
catch (e)
{
  Installed = false;
}

alert ("Installed :- " + Installed);
TestStr = Test.SendStr("Basil")
alert (TestStr);

</script>

============================

Pleae is this correct ????
Quote:
quote:Originally posted by malar
 i want to call java function from Javascript.
i will send a string from javascript to Java file.
********************
Ans :
<script language="javascript">
function call() {

document.form[0].action="loginAction.do?str=" + "HelloWorld";
document.form[0].submit();

}
</script>
********************

i will send a string from javascript to Java file and the Java will return for me the Same String follow by "!!!".
****************
Ans :

public LoginAction {

public execute() {
    String str = (String)request.getParameter ("str");
    str += "!!!";

...........
}


}
****************

 
Old August 6th, 2004, 10:59 AM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, this is my Java file :
============================
import javax.swing.*;
class TestJava
{
public static void main (String args[])
{}
    public String SendStr (String lStr)
    {
      return lStr + "!!!";
    }
}

============================
And This is my HTML and Javascript code:
============================
<OBJECT ID="Test" height=0 width=0
CLASSID="CLSID:18F79884-E141-49E4-AB97-99FF47F71C9E" CODEBASE="TestJava.CAB" VIEWASTEXT>
</OBJECT>

<script language="Javascript">
var Installed;
Installed = false;
try
{
  if (Test==null)
    Installed = false;
  else
    Installed = true;
}
catch (e)
{
  Installed = false;
}

alert ("Installed :- " + Installed);
TestStr = Test.SendStr("Basil")
alert (TestStr);

</script>

============================

Please is this correct ????

Really i need help ASAP.

Thanks



 
Old October 16th, 2008, 12:00 AM
Registered User
 
Join Date: Oct 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

what is the location of the cab file ?
where do we need to place it so that javascript call gets executed.
Please help?






Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling a btn_click method dhirajDac ASP.NET 2.0 Professional 2 April 18th, 2008 07:52 AM
Calling ActiveX component method from JavaScript Pera Pisar Javascript 3 September 7th, 2007 07:58 AM
Error calling a method in the webservice madhusrp .NET Web Services 1 April 12th, 2007 08:54 AM
calling private method from another class jack_3 C# 3 December 16th, 2005 07:56 PM
calling java servlet from javascript bearfacts Javascript How-To 1 August 26th, 2004 04:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.