?
Solved

jsp errors

Posted on 2012-03-30
4
Medium Priority
?
277 Views
Last Modified: 2012-04-02
These if statements are causing error: ';' expected IF (answer1 != "even") {
                                                               

                                                
IF (answer1 != "even") {
    bPassed = false;
}
IF (answer2 != "yes") {
    bPassed = false;
}
IF (answer3 != "1") {
    bPassed = false;
}

Question: Why this code shows this error?

Please see the attached files.

Thank you.
quizhandler-jsp-.txt
quiz-jsp-.txt
0
Comment
Question by:Mike Eghtebas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 23

Accepted Solution

by:
wdosanjos earned 2000 total points
ID: 37787972
if should be all lowercase and you should use equals to compare Strings as below:

                              if (!"even".equals(answer1)) {
                                    bPassed = false;
                              }
                              if (!"yes".equals(answer2)) {
                                    bPassed = false;
                              }
                              if (!"1".equals(answer3)) {
                                    bPassed = false;
                              }

I hope this helps.
0
 
LVL 9

Expert Comment

by:ioanton
ID: 37787992
The wdosanjos' comment is correct. I would add the following: because of the uppercase you used for the "if" statement, the compiler treats it as a method call having a boolean as argument. Therefore, it expects a semicolon to end this method call.
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 37789600
wdosanjos and ioanton,

Thank you for the comments.

Because I switch back and for from ,net to java, I sometimes make mistakes like this.

Mike
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 37795262
one more suggestion.. there is no need for looping while loop in your pgm ...  but this answer is not relvant to your question ...
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
If you're a modern-day technology professional, you may be wondering if certifications are really necessary. They are. Here's why.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question