Solved

jsp errors

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
netstat -a in AIX unix 8 43
Set up Wildfly 10 8 396
Spring Data jpa resouce mapping error "status":500,"error":"Internal Server Error", 3 312
main method of string class 3 110
This tutorial shows how to create a greeting card by combining two image layers and a text layer on a PC using a free image editing app.
The question appears often enough, how do I transfer my data from my old server to the new server while preserving file shares, share permissions, and NTFS permisions.  Here are my tips for handling such a transfer.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

778 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