• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Posting from HTML form to java applet

 
Sean McGurk
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there!
I am designing a spell checker program at the minute and the first step is to create a HTML form that loads a java applet once the 'check spelling' button is pressed on the HTML page.
The second step then will be to post whatever the user has entered in the HTML text box to a java applet for checking.
Anyone know how I might go about this?
Regards,
Sean
 
arul senthil
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sean
Will a Servlet serve your purpose? Then, have the applet inside the Servlet (it is just like an Html element only...) & submit your Html form values to this Servlet. Pass values to the Applet by using PARAM tags & do the spell check.
[Instead of a Servlet, you can have a Jsp also, if u prefer].
Hope that helps.
-Senthil.
 
sharad goswami
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi!
well do it by using servlet.or passing parameters to applet.it will work.
 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree. This would be best done with a servlet on the backend.
 
Sean McGurk
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
Thanks for all your input so far. I have followed your advice and created a simple HTML form with a little javascript function that passes the text typed in a text area to the java applet a follows:
passtext()
{
document.spell.check(document.formname.Textarea.value);
}
The java applet's init() method is null, so the applet doesn't do anything when it starts up, but it has a 'check' method that passes a parameter to the GUI program as follows:
public void check (String TextToCheck)

{
DictGUI dictGUI= new DictGUI();

dictGUI.createNewInterface(TextToCheck);

}
The DictGUI program builds an interface by creating a text box, putting the text box in a panel, putting the panel inside a frame and displaying the frame. This works well as I have tested the createNewInterface function it by running it through a main method.
However, when I try and call this program from my applet, I get the following error message:
java.lang.NoClassDefFoundError: javax/swing/JTextField
at the line:
dictGUI.createNewInterface(TextToCheck);
Anyone know why this might be? Are there any special considerations one needs to bear in mind when loading desiging applets that have a GUI?
 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your browser probably doesn't support Swing. Try building the applet with just awt.
 
Sean McGurk
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow!
Cheers for that, yeah, you're right.
How do I know which browsers do and which don't support Swing? As I'm building a browser-independent component, I take it it would be safer to implement the whole thing in AWT. Is this tricky? I have built my interface using swimg components with an AWT layout. Will it be difficult to convert all these to AWT? Sorry, this might not be a question for the applets forum, possibly for GUI or AWT or something.
Many thanks again,
Sean
 
Mike Bwn
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sean
Java 2 (Java 1.2) currently will not run within IE or any Netscape browser under version 6 (which ships the 1.3 Java Runtime Env). This means that you cant use swing components unless;
a) your audience all have the JRE 1.2 or above plugin;
b) all have netscape 6
ie - its an intranet.............otherwise your buggered really.
may as well convert to awt. very similar (normally you can keep your existing code and take out the J. ie JButton is Button,
JMenuItem is MenuItem..get the idea).
hope this helps
mike b
 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah,
Mike is right. I started using Netscape 6.1 yesterday and it's amazing the things that work with it. Swing, RMI........
 
Moody Hopkins
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there another way to pass the form element values to the applet?
Seems like it should be easy...
Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic