Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8473533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:22:38+00:00 2026-06-10T17:22:38+00:00

In the below Java code which is placed in a JSP file, if (false

  • 0

In the below Java code which is placed in a JSP file,

if (false == session.getAttribute("loggedin")) {  
    response.sendRedirect("login.jsp");
}
else if (null == session.getAttribute("loggedin")) {
    response.sendRedirect("login.jsp");
}

I am getting the following compilation error:

incompatible operand types and object

How is this caused and how can I solve it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T17:22:40+00:00Added an answer on June 10, 2026 at 5:22 pm

    session.getAttribute() returns an Object. An Object can’t be compared to a boolean. So the expression false == session.getAttribute("loggedin") is invalid. If you want to check if Boolean.FALSE is stored in the session attribute, the code should be

     if (Boolean.FALSE.equals(session.getAttribute("loggedin")))
    

    Note that you’d better put all the Java code in regular Java classes and limit yourself to the JSP EL in the JSPs. Scriptlets should not be used anymore.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got the following java code, which is giving the error below: import java.io.File;
I have a java file Test.java (below) which uses Guava's HashMultiMap (downloaded from http://code.google.com/p/guava-libraries/
I have wrote the code below which was taken from Java How to program
IN JAVA CODE IN JSP as below i m getting null value for fieldnoOfRecords.
I'm really sorry, but I need to post below Java code. Which won't work
I have written the java code below, which executes another java program named Newsworthy_RB.
I am trying to create a generic container (e.g. java code below), which has
I have the below java code: List<SomePojo> list = new ArrayList<SomePojo>(); //add 100 SomePojo
Consider the Java code below, what would happen if there were no paintComponent method
Given the Java code below, what's the closest you could represent these two static

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.