Solved

jsp errors

Posted on 2012-03-30
4
256 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
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 33

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now