Solved

jsp errors

Posted on 2012-03-30
4
266 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 500 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

696 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