Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet using an html form to sort data  RSS feed

 
Betty Christiansen
Greenhorn
Posts: 28
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm hoping I can ask this question here; if not please redirect me. I hava a very simple HTML form with a textField for a name, and add button to add the name to a MySQL database, and a sort button to sort the names in the database and display them. I almost have it working, however when I hit the "sort" button; I get the message that appears after a user clicks the add button along with the sorted list of names. It looks like this:
Please go back and add a name or sort.
Bill Jones
David G
Debbie Downer
Jane Doe
Joe Smith
John Doe
Mike Jones
Paul Smith
Susan Jones

Would someone be able to advise me on what I have to change on my code to make just the list show up by itself when the user clicks sort?

My servlet code:



My HTML form code
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66142
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never, ever, do this in a servlet:It will stop the entire server!

Have you traced the execution to find out where it's deviating from your expectations? (Hint: logging)
 
Betty Christiansen
Greenhorn
Posts: 28
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No I'm afraid I'm not sure how to do that in eclipse. I'm basically trying to learn how these different pieces interact by writing small programs that I run on my own computer. I realize I don't have a deep understanding of all the best practices but as I work through small exercises like this I am learning; especially from experts on these forums. Thank you for the hint, I will continue to research.
 
Betty Christiansen
Greenhorn
Posts: 28
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it figured out...not the most elegant that's for sure, but I'm learning.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66142
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You didn't take my hint: this is an excellent time to learn logging as a debug step. Why fly blind when you have instruments you can use?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No I'm afraid I'm not sure how to do that in eclipse.


Once again we see that IDEs are actually a hindrance to learning servlets. Why? - Because they do stuff behind your back and conceal what is actually going on!

Personally I use a programmer's editor for the syntax help, ANT for builds and a second screen to access JavaDocs.

Bill
 
Betty Christiansen
Greenhorn
Posts: 28
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bill and Bear, Thank you for the advice...added to my next steps in learning!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!