Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Logic Help Please!!!

 
Xay Sayco
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!
 
Jessica Sant
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 ]
 
Riaz Mohamed
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic