aspose file tools*
The moose likes Applets and the fly likes Applet in web application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet in web application" Watch "Applet in web application" New topic
Author

Applet in web application

s penumudi
Ranch Hand

Joined: Nov 17, 2004
Posts: 113
Hello Experts there,

I guess I am posting in the right forum. If you think this should be in some other forum, it is fine with me.

Here is my problem,
I am working on a web application using Jsp, struts and EJB. When a form is submitted, I have to validate the form and show the error messages to the user. To do this I am using <html:errors/> tag of struts.

Now, when I show these error messages, I have to generate a beep sound, which creates a feel that there is something wrong.

I have done some search on web and found that Javascript does not have method to generate these sounds where as Java has one.


I cannot call this method directly from javascript because, IE does not support this call whereas Netscape navigator does. Workaround for this would be to write an applet and call this applet. Hence I have written a applet called JavaBeep that has method called beep().


This is how I have included applet in my JSP



when I try to run my Jsp I get Applet notinited error.
When I look at error, I see ClassNotFoundException. It seems that the classloader is looking for JavaBeep class somewhere. How can I give the codebase relative to my web component?. Is there anything wrong with the above declaration?

Is there is any alternate solution for my problem?

thank you
Murali Kurukunda
Ranch Hand

Joined: Oct 20, 2003
Posts: 36
Try using the Applet tag and package your .class in a jar/cab file and specify it in the archive param.
s penumudi
Ranch Hand

Joined: Nov 17, 2004
Posts: 113
Hello murali,

Thank you very much for ur response.


Try using the Applet tag and package your .class in a jar/cab file and specify it in the archive param.


Ok I will try using Applet tag in place of object.
I have packages my class file along with web component files in .war file. Do I have make a separate jar for this applet?

I am sorry, my ignorance... where can I find this archive param.
Can u please show me a sample.

Thank you
s penumudi
Ranch Hand

Joined: Nov 17, 2004
Posts: 113
I have tested with applet tag, still same errors.

I have few doubts though.
I understand that I have to jar my applet class and refer that jar file in the archive attribute of the applet tag.

In the web component directory structure where I am supposed to place this jar file. Does this has to be placed in web-inf/lib folder?

All the classes that are refered from the web component are relative to the web-inf/classes directory. does same thing not apply in case of applets?

I would appreciate if you could clear my these doubts

Thank you
Murali Kurukunda
Ranch Hand

Joined: Oct 20, 2003
Posts: 36
<APPLET code="com.company.MyClass.class" id="MyClass" name="MyClass" archive="MyApplet.jar" height=0 width=0 VIEWASTEXT>
<param name="useslibrary" value="MyApplet">
</APPLET>
s penumudi
Ranch Hand

Joined: Nov 17, 2004
Posts: 113
If you could see my above post I have tried using applet tag.
But I still have same problem.
I would apreciate if you could tell me where should I have to place .jar file. Currently it is web-inf/lib directory.
Murali Kurukunda
Ranch Hand

Joined: Oct 20, 2003
Posts: 36
try putting it directly under WebContent. (i.e in the same folder as WEB-INF is in)
s penumudi
Ranch Hand

Joined: Nov 17, 2004
Posts: 113
Thanks murali,
I did try that and it worked.
Sorry for not updating you soon. I was in the meeting.

But the problem is cannot hear beep sound.

I am calling this method onload.
document.SystemConfigForm.javaBeep.oneBeep();

This is oneBeep() method in Applet
public void oneBeep() {
Toolkit.getDefaultToolkit().beep();
}

Thank you very much for all the help
s penumudi
Ranch Hand

Joined: Nov 17, 2004
Posts: 113
Hey Murali,

I got it. My call in Javascript was wrong.

Correct syntax is this
document.javaBeep.oneBeep();


Thank you very much for helping me in solving my problem..
Thank you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applet in web application