aspose file tools
The moose likes Servlets and the fly likes Logic Help Please!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Logic Help Please!!!" Watch "Logic Help Please!!!" New topic

Logic Help Please!!!

Xay Sayco

Joined: May 31, 2002
Posts: 2
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!
Jessica Sant

Joined: Oct 17, 2001
Posts: 4313

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 ]

- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
Riaz Mohamed

Joined: May 31, 2002
Posts: 23
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
Xay Sayco

Joined: May 31, 2002
Posts: 2
Sorry about the name. As you can see I've changed it already.
Thanks for your help. You advice was very helpful!
It is sorta covered in the JavaRanch Style Guide.
subject: Logic Help Please!!!