Solved

jsp errors

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

No single Antivirus application (despite claims by manufacturers) will catch or protect you from all Virus / Malware or Spyware threats. That doesn't stop you from further protecting yourself however - and this article is to show you how.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

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