This week's book giveaway is in the Design and Architecture forum.
We're giving away four copies of Communication Patterns: A Guide for Developers and Architects and have Jacqui Read on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Applet in web application

 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<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
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try putting it directly under WebContent. (i.e in the same folder as WEB-INF is in)
 
s penumudi
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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'm thinking about a new battle cry. Maybe "Not in the face! Not in the face!" Any thoughts tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic