• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need an IDE or debugger!

 
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone please tell me the best way to debug an simple html which is calling a servlet which then calls a bean?
I tried downloading SUN ONE and ECLIPSE, but found the installation instructions too vague!
Is there another way to debug these kinds of components please?
Thanks very much!
BC
 
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
System.out.println() works when you need to debug and don't have an IDE/debugger to help
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my experience, by far the best way to debug a servlet application is to remove the bugs before they get to the server.
Step 1: unit test your bean to death on its own, make sure there are no problems with this "simple" bit.
Step 2: move any code not to do with processing HTTP (that's the business of GET's and parameters and stuff) to a regular Java class which you call from the servlet code. Unit test your new class to death, make sure there are no problems in this code either. If this code is generating HTML, test that it is generating the correct HTML when it has the correct parameters passed in, etc.
Step 3: Put some diagnostic prints in your servlet so that it prints out the parameters about to be passed in to the regular Java code, and whetever information comes out. Deploy and run your servlet, grab the printed diagnostic data and compare it with your unit test data. If the "live" parameters are different from your tests, add new tests which test your code when supplied with the actual parameters you logged. Rinse and Repeat with different user input until you are happy that the extracted Java "business code" works.
Step 4; When you are happy, remove the diagnostic prints from teh servlet code, and redeploy the final application with the corrected business code.
If you use this approach, you should only need to deploy your servlet application to a server twice - once with diagnostics, once without. All other testing and debugging is done with regular java tools on regular Java classes.
I hope this makes sense. I have used this technique successfully in many projects.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great answer Frank. It shows using Tests, decoupling classes to makes it easier to debug and later maintain and enhance.
I'd much rather take that time up front like you post, than trying to fix it on the other side, like Bob is finding out.
Good Luck Bob, and take Frank's advice.
Mark
 
reply
    Bookmark Topic Watch Topic
  • New Topic