• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

JAVA: What is the error in this applet?

 
Ranch Hand
Posts: 507
Netbeans IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have created an applet but it has some errors. The error is, the code inside the try, catch block is not working. Apart from that all other works fine. Please help me to correct this code. here is a very little part of the code.

Code:

 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The first thing to do is to put an e.printStackTrace() in the catch block. You should not ignore exceptions - at the least print some information to a console or log file.
 
Yohan Weerasinghe
Ranch Hand
Posts: 507
Netbeans IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:The first thing to do is to put an e.printStackTrace() in the catch block. You should not ignore exceptions - at the least print some information to a console or log file.



Thanks for the reply. I did that...But no progress. I executed it in net beans, but didn't get any info regarding any error. Please help me. Here I am posting my new code

 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I executed it in net beans,


That could be the problem. NetBeans is not a browser, so it wouldn't have a proper AppletContext. Create an HTML page with an APPLET tag, and then load that into a browser.
 
Yohan Weerasinghe
Ranch Hand
Posts: 507
Netbeans IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Checked that in a browser. No good.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which means what? Which lines of code of the actionPerformed method are being executed?
 
Yohan Weerasinghe
Ranch Hand
Posts: 507
Netbeans IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
code inside the the try catch block s not working. All other parts are OK.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ask yourself this: Under which circumstances would the try/catch block ever be executed?
 
Yohan Weerasinghe
Ranch Hand
Posts: 507
Netbeans IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:Ask yourself this: Under which circumstances would the try/catch block ever be executed?



There should be no code before the opening of the try block. I removed all the form validations code and if else parts and it worked!! But the case is, that code is a must! I must check whether those given fields are empty or not before submitting the form. Actually this code is a part of my java project in my degree. I really appreciate your help. please help me. That form validation is a MUST!
 
Yohan Weerasinghe
Ranch Hand
Posts: 507
Netbeans IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had to google a lot in order to find out "How to link using java". Now that is also not working as I need. please help...
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's the clue to the solution: The if condition that currently decides whether the try/catch block is executed does NOT check the form input - it checks something else entirely.

I had to google a lot in order to find out "How to link using java". Now that is also not working as I need.


Forget about whatever you found or did there; that's not the problem.
 
Yohan Weerasinghe
Ranch Hand
Posts: 507
Netbeans IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the help...I replaced the else statement and it worked! Thanks again!
reply
    Bookmark Topic Watch Topic
  • New Topic