• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Logic Help Please!!!

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm just beginning to learn about servlets and I'm stuck on my program. The logic is not working and I don't see why. Can anyone help?
Thanks in Advance!
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"xam"
1st thing:
Welcome to the JavaRanch! Please adjust your displayed name to meet the JavaRanch Naming Policy.
You can change it here.
2nd thing:
Why are you wrapping the request.getParameter() calls in a try/catch block? I don't think that call can throw any exception

3rd thing:
Why aren't you wrapping the number parsing in a try/catch block?? if you receive a value other than a Double (a letter, or null) you'll get a NumberFormatException.

4th thing:
You need to compare Strings with the .equals(String) method, not ==. I think this is the main 'logic' problem.
5th thing:
Try chaining your if statements -- you don't expect there to be more than one userAction, right? so make them if-else blocks

Last thing:
What happens if the userAction isn't any of those? what if its null?
Hope that Helps!!
[ June 01, 2002: Message edited by: Jessica Sant ]
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i agree with jesica and i don get y u se such a lot of try blocks .. and it would be great if u could send the client program as well from which u r calling the servlet or atleast the usrl on how u r accesing the servlet ..this would help to pinpint u'r error
riaz
 
Xay Sayco
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about the name. As you can see I've changed it already.
Jessica,
Thanks for your help. You advice was very helpful!
 
Who knew that furniture could be so violent? Put this tiny ad out there to see what happens:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!