How to execute Applet method from jsp?

Hi ,
I have a query.I have a jsp page
on loading the jsp page the applet should be
loaded.And i have a button in my jsp page on clicking
the button a method written in the applet class should
be executed .How can i do this.Iam attaching the
classes also.There r two java files.One is EXPosApplet.java and other is EXPos.java
In the EXPosApplet.java i have a method called
RunNotepad().This method should be executed when i click the
button in my jsp page.Pls provide me with some code to load the applet and execute the method of applet.It is a bit urgent.
Thanks
Naveen
The following is my
EXPos.java class.Following this is my EXPosApplet.java class.
EXPos.java
package SumberPutra.External;
import java.io.*;
public class EXPos extends Object {
* Constructor
public EXPos() {
private static void RunIt(String fileName){
try {
Runtime.getRuntime().exec(fileName);
catch (SecurityException e) {
System.out.println("ExecFile: caught security exception: " + e) ;
catch (IOException ioe) {
System.out.println("ExecFile: caught i/o exception: " + ioe);
public void RunNotepad(){
String fname = "notepad.exe";
RunIt(fname);
EXPosApplet.java
package SumberPutra.External;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class EXPosApplet extends JApplet {
boolean isStandalone = false;
private EXPos expos = new EXPos();
JButton jButton1 = new JButton();
JLabel jLabel1 = new JLabel();
* Constructs a new instance.
* getParameter
* @param key
* @param def
* @return java.lang.String
public String getParameter(String key, String def) {
if (isStandalone) {
return System.getProperty(key, def);
if (getParameter(key) != null) {
return getParameter(key);
return def;
public EXPosApplet() {
* Initializes the state of this instance.
* init
public void init() {
try {
jbInit();
catch (Exception e) {
e.printStackTrace();
private void jbInit() throws Exception {
this.setSize(new Dimension(400, 156));
jButton1.setText("jButton1");
jLabel1.setText("jLabel1");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton1_actionPerformed(e);
this.getContentPane().add(jButton1, BorderLayout.NORTH);
this.getContentPane().add(jLabel1, BorderLayout.SOUTH);
* start
public void start() {
* stop
public void stop() {
* destroy
public void destroy() {
* getAppletInfo
* @return java.lang.String
public String getAppletInfo() {
return "Applet Information";
* getParameterInfo
* @return java.lang.String[][]
public String[][] getParameterInfo() {
return null;
static {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
catch(Exception e) {
e.printStackTrace();
public void ExecNotepad(){
expos.RunNotepad();
/* void jButton1_actionPerformed(ActionEvent e) {
try
Runtime.getRuntime().exec("notepad.exe");
catch (SecurityException ex) {
// strMsg = "ExecFile: caught security exception: " + e ;
jLabel1.setText("ExecFile: caught security exception: " + ex) ;
catch (IOException ioe) {
// strMsg = "ExecFile: caught i/o exception: " + ioe;
jLabel1.setText("ExecFile: caught i/o exception: " + ioe);

hie Naveen
I don't have time to read your code.
just telling you the way i did it.
I used javascript for this
apply onClick() event on button.
function invokeApplet() {
app = document.applets[0].methodName(param1,param2);
hope this helps
if you still face the problem
I'll look in to your code

Similar Messages

  • How to execute applets method from jsp?

    Hi ,
    I have a query.I have a jsp page
    on loading the jsp page the applet should be
    loaded.And i have a button in my jsp page on clicking
    the button a method written in the applet class should
    be executed .How can i do this.Iam attaching the
    classes also.There r two java files.One is EXPosApplet.java and other is EXPos.java
    In the EXPosApplet.java i have a method called
    RunNotepad().This method should be executed when i click the
    button in my jsp page.Pls provide me with some code to load the applet and execute the method of applet.It is a bit urgent.
    Thanks
    Naveen
    The following is my
    EXPos.java class.Following this is my EXPosApplet.java class.
    EXPos.java
    package SumberPutra.External;
    import java.io.*;
    public class EXPos extends Object {
         * Constructor
         public EXPos() {
    private static void RunIt(String fileName){
         try {
         Runtime.getRuntime().exec(fileName);
              catch (SecurityException e) {
    System.out.println("ExecFile: caught security exception: " + e) ;
    catch (IOException ioe) {
    System.out.println("ExecFile: caught i/o exception: " + ioe);
    public void RunNotepad(){
         String fname = "notepad.exe";
    RunIt(fname);
    EXPosApplet.java
    package SumberPutra.External;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    public class EXPosApplet extends JApplet {
         boolean isStandalone = false;
         private EXPos expos = new EXPos();
         JButton jButton1 = new JButton();
         JLabel jLabel1 = new JLabel();
         * Constructs a new instance.
         * getParameter
         * @param key
         * @param def
         * @return java.lang.String
         public String getParameter(String key, String def) {
              if (isStandalone) {
                   return System.getProperty(key, def);
              if (getParameter(key) != null) {
                   return getParameter(key);
              return def;
         public EXPosApplet() {
         * Initializes the state of this instance.
         * init
         public void init() {
              try {
                   jbInit();
              catch (Exception e) {
                   e.printStackTrace();
         private void jbInit() throws Exception {
              this.setSize(new Dimension(400, 156));
              jButton1.setText("jButton1");
              jLabel1.setText("jLabel1");
              jButton1.addActionListener(new java.awt.event.ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        jButton1_actionPerformed(e);
              this.getContentPane().add(jButton1, BorderLayout.NORTH);
              this.getContentPane().add(jLabel1, BorderLayout.SOUTH);
         * start
         public void start() {
         * stop
         public void stop() {
         * destroy
         public void destroy() {
         * getAppletInfo
         * @return java.lang.String
         public String getAppletInfo() {
              return "Applet Information";
         * getParameterInfo
         * @return java.lang.String[][]
         public String[][] getParameterInfo() {
              return null;
         static {
              try {
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              catch(Exception e) {
                   e.printStackTrace();
    public void ExecNotepad(){
         expos.RunNotepad();
    /*     void jButton1_actionPerformed(ActionEvent e) {
    try
              Runtime.getRuntime().exec("notepad.exe");
              catch (SecurityException ex) {
    // strMsg = "ExecFile: caught security exception: " + e ;
    jLabel1.setText("ExecFile: caught security exception: " + ex) ;
    catch (IOException ioe) {
    // strMsg = "ExecFile: caught i/o exception: " + ioe;
    jLabel1.setText("ExecFile: caught i/o exception: " + ioe);

    Iam new to java .Can u please give me the code to load the applet and execute applets method
    Thankyou

  • How to execute batch file from JSP

    hi frens !
    i wanna know how to execute batch file from my JSP.i am using exec() method to get call the batch file. but its not working ....plz help
    here mine code:-
    File F = new File("C:/var.bat");
         try{
          if (F.exists())
            Runtime rt = Runtime.getRuntime();
            String url=F.getAbsolutePath();
             Process proc = rt.exec(url);
            proc.waitFor();
            proc.destroy();
            catch(Exception IOEx){
           System.out.println(IOEx);
      }Thanks and Regards
    Allwyn

    You might improve your chances of getting help if you do two things:
    1) Explain what "not working" means.
    2) ChangeSystem.out.println(IOEx); to IOEx.printStackTrace(); (in the eventhat is in fact related to "not working").

  • How to execute a method from String object?

    I have some methods in String objects, example:
    String methodOne = "someMethod1";
    String methodTwo = "someMethod2";
    public void someMethod1() {
    public void someMethod2() {
    How can i execute that methods, when the method names i have only in String objects?

    You can get the method directly from the name and parameter types if you want to avoid using the loop:public class Foo27 {
      public static void main (String[] args) throws Exception{
        String methodOne = "someMethod1";
        String methodTwo = "someMethod2";
        Object foo = new Foo27();
        Method method1 = foo.getClass().getMethod(methodOne, new Class[]{});
        method1.invoke(foo, null);
        Method method2 = foo.getClass().getMethod(methodTwo, null);
        method2.invoke(foo, null);
      public void someMethod1() {
        System.out.println("someMethod1");
      public void someMethod2() {
        System.out.println("someMethod2");
    }The parameter types are required as there could be more than one method with the same name.
    For somereason when I tried to create a new Method object and invoke it, an exception was thrownThere isn't a public constructor for Method, so how did you create a new one?
    Pete

  • Invoking Applet methods from Javascript for Netscape 6

    Hi,
    I am trying to invoke an applet method from javascript, but it is failing with Netscape 6 browser:
    I am doing it the following way-
    function test(form)
    var i = document.myapplet.getname();
    where myapplet is the name of the applet and getname is a method within the applet. This is
    working with Ie but not with netscape 6.
    I would appreciate it if someone could tell me how should I invoke the applet method for netscape browsers.
    Thanks.
    Jay Srin.

    Not working with NS 6 - and will not i guess till they upgrade to Mozilla Version 1.0 - Live Connect is not implemented 100% correct yet - if you want you can download the 7.0 Pre Release Netscape - since its using mozilla 1.0 it should work , see :
    http://forum.java.sun.com/thread.jsp?forum=30&thread=272975

  • How to access java method in JSP

    Hi all,
    I need to access java class (abstract portal component) method doContent() in a JSP which is under PORTAL-INF/jsp folder.
    I did
    <%@ page import = "com.mycompany.Aclass" %>
    <%com.mycompany.Aclass a = new com.mycompany.Aclass (); %>
    Aclass is coming as autofill/prepopulated with cntrl+space
    Till this time, it is working. no errors. But when I do
    a.
    a. (a dot) no methods are populating (autofill..cntrl+space) or If I forcebly add method a.doContent(req,res)... at runtime its giving error.
    It's not only with doContent method... Its with any simple methods in that class or any other class.
    (Other than doContent method in the APC java class are prepopulating/autofilling but giving error in runtime)
    Can anyone help me... how to access java method in JSP.
    I already gone through many SDN forum post... and implemented too---but no use I refered below forum thread
    Retrieve values from Java class to JSP
    URGENT! How to call a java class from JSP.
    Calling a java method from jsp file -
    this thread is same as my issue
    Thanks,
    PradeeP

    1st. The classes must be in packages. 2nd, the package that they are in must be under the WEB-INF/classes directory. 3rd Look on google and/or this site for web application deployment

  • How to load java class from jsp page?

    hi all!
    Does anyone know how to load java class from jsp page?
    I try to load java class from jsp page.
    Is it possible to load java class fom jsp page?
    thanks and have a good day!

    What I mean is How to load/open java class file from jsp page?
    I think we can open Applet from jsp page by using
    <applet code=helloApplet.class width=100 height=100>
    </applet>
    but, how to open java class which is an application made by Frame?
    thanks and have a good day

  • How to execute a method after page Load?

    My question is very similar to what was discussed in following thread:
    How to execute a method after page Load?
    My requirement is that I want to run a method in backing bean of a page, immediately after the page gets loaded. In that method I want to invoke one of the method action included in the pagedef of this page, conditionally.
    I tried using the approach given in the above thread, i.e to use <f:view afterPhase="#{backing_security.setPermPriv}">, but the problem is that our page is not using 'f:view' , so I explicitly added one f:view with afterPhase property set , but it is not working, page it self is not getting loaded, it is throwing the error:
    Root cause of ServletException.
    java.lang.IllegalStateException: <f:view> was not present on this page; tag [email protected]e8encountered without an <f:view> being processed.
         at org.apache.myfaces.trinidad.webapp.UIXComponentELTag.setProperties(UIXComponentELTag.java:108)
         at javax.faces.webapp.UIComponentClassicTagBase.findComponent(UIComponentClassicTagBase.java:733)
         at javax.faces.webapp.UIComponentClassicTagBase.doStartTag(UIComponentClassicTagBase.java:1354)
         at org.apache.myfaces.trinidad.webapp.UIXComponentELTag.doStartTag(UIXComponentELTag.java:71)
         at oracle.adfinternal.view.faces.taglib.UIXQueryTag.doStartTag(UIXQueryTag.java:41)
         at oracle.adfinternal.view.faces.unified.taglib.UnifiedQueryTag.doStartTag(UnifiedQueryTag.java:51)
         at oracle.jsp.runtime.tree.OracleJspBodyTagNode.executeHandler(OracleJspBodyTagNode.java:50)
         at oracle.jsp.runtime.tree.OracleJspCustomTagNode.execute(OracleJspCustomTagNode.java:262)
         at oracle.jsp.runtime.tree.OracleJspNode.execute(OracleJspNode.java:89)
         at oracle.jsp.runtimev2.ShortCutServlet._jspService(ShortCutServlet.java:89)
         at oracle.jsp.runtime.OracleJspBase.service(OracleJspBase.java:29)
         at oracle.jsp.runtimev2.JspPageTable.compileAndServe(JspPageTable.java:665)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:387)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:822)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:746)
    Please help to resolve this issue, or am I doing anything wrong?

    Hi,
    I assume that your view is a page fragment and here - indeed - the f:view tag cannot be used. If you use ADF then one option would be to use a custom RegionController on the binding layer to listen for the render phase to invoke the method. Another option would be to use a hidden field (output text set to display="false" and have this component value referencing a managed bean property. The managed bean property's getter method can now be used to invoke the method you want to run upon view rendering
    Frank

  • How to use protected method in jsp code

    Could anyone tell me how to use protected method in jsp code ...
    I declare a Calendar class , and I want to use the isTimeSet method ,
    But if I write the code as follows ..
    ========================================================
    <%
    Calendar create_date = Calendar.getInstance();
    if (create_date.isTimeSet) System.out.println("true");
    %>
    ============================================================
    when I run this jsp , it appears the error wirtten "isTimeSet has protected access in java.util.Calendar"

    The only way to access a protected variable is to subclass.
    MyCalendar extends Calendar
    but I doubt you need to do this. If you only want to tell if a Calendar object has a time associated with it, try using
    cal.isSet( Calendar.HOUR );

  • How to execute ODI scenario from a web application

    Hi
    I need to execute ODI scenario from ApEx form.
    how to execute ODI scenario from application. Using 10.1.3.5.5
    -app

    In the SQL property of the TQuery object, enter the call as an anonymous block:
    begin
      pkg_name.procedure_name(true);
    end;

  • How to execute a workflow from a webdynpro application???

    hi friends....
    How to execute a workflow from a webdynpro application???
    we are using ep6, ecc5????

    If you want to start a workflow in the backend, you need to call a RFC that starts it.

  • How to call java method from workflow script?

    Hi
    I have a requirement of updating field value 'Document Status' based on review/approve of content from Workflow and hence need to update the version number. For that I need to call my java method from workflow during submit of review/approve condition. Please let me know how to call java method from workflow?
    Is there any alternative better way to achive this requirement from workflow? Please suggest.
    Thanks,
    Sarang

    OK. So, I think we can all conclude that you don't need to call any Java method, can't we? And, that wfUpdateMetadata is the command that will update your metadata.
    Now, the question is what are its arguments. It has two - the first is the name of a custom metadata field to be updated (let's suppose that one field is called xMinorVersion, and the other xMajorVersion), the other is the new value, e.g. <$wfUpdateMetaData("xMinorVersion", "New value.")$>As for new value - do you insist on using strings? Since you want to increase the value, it would be more convenient to work with numbers. For instance, with integers you could go with <$wfUpdateMetaData("xMinorVersion", xMinorVersion + 1)$>With strings you will need to convert it to numbers and back to strings. Besides, what happens if you have more than 100 minor versions? (you mentioned you want to add 0.01, but that would finally increase the major version, wouldn't it?) So, I think these two numbers are independent (perhaps, with exception that increase on the major version set the minor version to .00).
    If you want to present it, you can use profiles that will construct for you the representation 2.304 out of MajorVersion = 2, MinorVersion = 304
    Solved?

  • How to execute the method of a class loaded

    Hi,
    I have to execute the method of com.common.helper.EANCRatingHelper" + version
    version may be 1,2, etc
    if version = 1 the class is com.common.helper.EANCRatingHelper1;
    Iam able to load the class using following code.But iam unable to execute the method of the above class
    Can anybody help me how to execute the method of the class loaded.
    Following is the code
    String version = getHelperClassVersion(requestDate);
    String helperClass = "com.redroller.common.carriers.eanc.helper.EANCRatingHelper" + version;
    Class eancRatingHelper = Class.forName(helperClass);
    eancRatingHelper.newInstance();
    eancRatingHelper.saveRating(); This is not executing throwing an error no method.
    Thanks

    eancRatingHelper.newInstance();Ok, that creates an instance, but you just threw it away. You need to save the return of that.
    Object helper = eancRatingHelper.newInstance();
    eancRatingHelper.saveRating(); This is not executing throwing an error no method.Of course. eancRatingHelper is a Class object, not an instance of your EANCRatingHelper object. The "helper" object I created above is (though it is only of type "Object" right now) -- you have to cast it to the desired class, and then call the method on that.
    Hopefully EANCRatingHelper1 and 2 share a common interface, or you're up the creek.

  • How to execute Linux command from Java app.

    Hi all,
    Could anyone show me how to execute Linux command from Java app. For example, I have the need to execute the "ls" command from my Java app (which is running on the Linux machine), how should I write the codes?
    Thanks a lot,

    You can use "built-in" shell commands, you just need to invoke the shell and tell it to run the command. See the -c switch in the man page for your shell. But, "ls" isn't built-in anyays.
    If you use exec, you will want to set the directory with the dir argument to exec, or add it to the command or cmdarray. See the API for the variants of java.lang.Runtime.exec(). (If you're invoking it repeatedly, you can most likely modify a cmdarray more efficiently than having exec() decompose your command).
    You will also definitely want to save the returned Process and read the output from it (possibly stderr too and get an exit status). See API for java.lang.Process. Here's an example
    java.io.BufferedReader br =
    new java.io.BufferedReader(new java.io.InputStreamReader(
    Runtime.getRuntime().exec ("/sbin/ifconfig ppp0").
    getInputStream()));
    while ((s = br.readLine()) != null) {...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to execute a Scenario from Windows CMD prompt

    Please can you let me know how to execute the Scenario from a Windows CMD prompt? I am not sure if it is any different from "ODIStartScen" command that ODI uses to execute the scenario.
    Appreciate your help.
    Regards
    B

    Hi SH,
    I tried running the scenario from the command line, but the process was not completed and it came back with the below message
    Session : 131774001 finished with return code : 7000
    Do I need to set up any environmental variables or any other setups before I can run the scenario from the command line?
    Appreciate your help.
    Regards
    B

Maybe you are looking for

  • How to deal with corruption issue?

    A couple of months ago after installing Aperture 2, my Imac started slowing down, every program at some time would hang and could not be forced to quit. The machine had to be turned off (control command power) and left off for several minutes. On res

  • How to use L_IDOC_ERROR_SAVE

    Hi SAP Gurus, How to use  L_IDOC_ERROR_SAVE I am unable to find out what to populate in I_CATEGORIE, I_RESULT. Thanks, Krishna

  • Reg. Validation on Header text in Purchase Order Transaction

    Hi All,    As per the requirement we need to validate on header text in PO transaction. Can any one let me know if there is way to do using user exit or configuration. Please kindly help me. This is urgent. Regards Anil Kumar K

  • Adobe Premiere Pro Video Play Issue

    This is probably not an advanced question, but I'm having a lot of trouble finding an answer.  I'm trying to use Adobe Premiere, and I'm importing my video.  In the first screen, the top left video play area that I import my raw video into, I find th

  • SharePointBrowser::handleOpenCallBack returned 62

    I'm unable to connect to the afp share on my Airport Extreme. When I click on the Extreme in the Shared panel of Finder I get the message "Connection Failed". If I click the "Connect As" button I get the message 'The server "Extreme" is available on