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 6049707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:36:25+00:00 2026-05-23T07:36:25+00:00

I’ve got an if statement in a bean that seems to be processing fine

  • 0

I’ve got an if statement in a bean that seems to be processing fine when I create a test java class, but doesn’t work fine when the bean is invoked by a jsp.

My code, let me shows you it:

First, the test class:

package com.serco.inquire;
import java.util.*;
import java.text.*;

public class TestCollection {
    public static void main(String[] args) {
        IrCollection myCollection = new IrCollection();
        myCollection.setSort("none");
        myCollection.setMgrid("none");
        int endpoint = myCollection.getSize();
        for (int i=0;i<endpoint;i++) {
            InquireRecord curRec = myCollection.getCurRecords(i);
            Long milis = new Long(curRec.getSubmitDate());
            Date theDate = new Date(milis);
            Format formatter = new SimpleDateFormat("dd MMM yyyy");
            String s = formatter.format(theDate);
            System.out.println("ID: " + curRec.getID() + " | Subject: " + curRec.getSubject());
        }
    }
}

a snippit from the IrCollection class it calls:

private void processSort(String datum) {
    int LastChar = datum.length()-1;
    String colName = datum.substring(0, LastChar);
    if (datum=="none") {
        this.fullSort  = " ORDER BY lastUpdated DESC";
    } else {
        if (datum.endsWith("2")) {
            this.fullSort = " ORDER BY " + colName + " ASC";
        } else {
            this.fullSort = " ORDER BY " + colName + " DESC";
        }
    }
}

There’s more code in another method that calls this particular method using:

this.processSort(this.sort);

But the problem is the if (datum=="none") portion in the second code sample. Given that line 10 of the first class sets the member variable sort to "none", that processSort() method should set the member variable fullSort to " ORDER BY lastUpdated DESC".

And if I use the class in the first sample, it does that.

HOWEVER

I have this custom tag:

<%@ tag body-content="scriptless" import="com.serco.inquire.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ attribute name="mgr" required="true" %>
<%@ attribute name="mkind" required="false" %>
<%@ attribute name="sort" required="false" %>
<c:if test="${empty mkind}">
    <c:set var="mkind" value="manager" />
</c:if>
<c:if test="${empty sort}">
    <c:set var="sort" value="none" />
</c:if>
<jsp:useBean id="irc" scope="page" class="com.serco.inquire.IrCollection">
    <jsp:setProperty name="irc" property="mgrtype" value="${mkind}" />
    <jsp:setProperty name="irc" property="sort" value="${sort}" />
    <jsp:setProperty name="irc" property="mgrid" value="${mgr}" />
</jsp:useBean>
${irc.fullsort}

Which the .jsp file invokes with this:

<c:set var="user" value="none" />    
<c:set var="sort" value="none" />
<inq:displayCollection>
    <jsp:attribute name="mgr">${user}</jsp:attribute>
    <jsp:attribute name="mkind">cotr</jsp:attribute>
    <jsp:attribute name="sort">${sort}</jsp:attribute>
</inq:displayCollection>

In other words, the exact same data is fed to the IrCollection bean. so I should get the same data, right?

Except I get this:

WHERE cotr = ‘none’ ORDER BY non DES

so when Java calls it, it thinks "none" == "none", but when jsp calls it, it thinks "none" != "none".

  • 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-05-23T07:36:26+00:00Added an answer on May 23, 2026 at 7:36 am

    You have to use equals instead of ==:

    datum.equals("none")

    Refer to whats the difference between “.equals and ==”

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

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
i got an object with contents of html markup in it, for example: string
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
I need to clean up various Word 'smart' characters in user input, including but
I have just tried to save a simple *.rtf file with some websites and
I have a JSP page retrieving data and when single or double quotes are
Does anyone know how can I replace this 2 symbol below from the string

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.