Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Java to submit forms on a web page

Posted on 2000-04-06
2
Medium Priority
?
558 Views
Last Modified: 2008-02-20
I have never used Java before, but may do so for a project I am working on at the moment. Can anybody tell me if you can use Java to submit a form to another target page (i.e. Java applet [a menu system] is in another frame).

Also, would there be any compatibility issues with various browsers that I should be aware of?

Hope you can help.

Cheers.
0
Comment
Question by:rhinosaur
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Accepted Solution

by:
jpick earned 800 total points
ID: 2690543
I'm not sure if I understand your questions, but this should help you out.

You can use the JSObject to communicate from Java to Javascript.  You can then write a javascript function to do the submit.  for example:

JAVA
-------

// Netscape imports
import netscape.javascript.*;
import netscape.plugin.*;

class MyClass extends Applet {
 
 ...

    public void submitForm()
   {
        try
          {
            m_window = JSObject.getWindow(this);
          }
      catch(Exception e)
          {
            e.printStackTrace();
                    }

      try
          {
            // submit form
            m_window.call("submitMyForm",null);
          }
        catch(Exception e)
          {
            e.printStackTrace();
          }

   }
}



Javascript
-------------

funtion submitMyForm()
{
      document.formname.submit();
}

You can find documentation on JSObject at http://developer.netscape.com.  This solution works for all 4.0 browsers and above.  Good Luck.

Jeff
0
 
LVL 1

Author Comment

by:rhinosaur
ID: 2881123
Using "javac form.java" at the command prompt I get the following errors:

form.java:2: Package netscape.javascript not found in import"

form.java:3: Package netscape.javascript not found in import"

form.java:5: "Superclass Applet of class MyClass not found. class MyClass extends Applet {"

form.java:7: Type expected.

Also - will this work in IE browsers?

Do I need to include the following:

import java.applet.Applet;
import java.applet.AppletContext;
import java.awt.*;
import java.awt.event.*;

aswell?

Cheers,

Ben.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question