String Comparision in JSTL

have to do something like this
if(product.equals("ABC")) {
} else {
Trying to use
<c:choose>
<c:when test="${product == 'ABC'}'"> ------ is this correct?????
</c:when>
<c:otherwise>
</c:otherwise>
</c:choose>
thanks.

HI,
<c:set var="a" value="A" />
   <c:choose>
          <c:when test="${a == 'A'}">
               Do something
          </c:when>
          <c:otherwise>
               Do some other
          </c:otherwise>
    </c:choose>or
<c:set var="a" value="A" />
   <c:choose>
          <c:when test="${a eq  'A'}">
               Do something
          </c:when>
          <c:otherwise>
               Do some other
          </c:otherwise>
    </c:choose>will work
AE

Similar Messages

  • String Comparision in XSLT Mapping

    HI All,
    Can any one suggest me to compare the two strings in XSLT mapping.Please let me know is there any string comparision function in xslt?
    Thanks
    Pullarao

    Hi Pullaro!
    It depends what you want to do with the comparison
    E.g. you can use a simple xsl-if Tag to compare a value
    and then take action.
    If your XML looks like this:
    <root>
      <child><b>value1</b></child>
      <child>value2</child>
    </root>
    you can make an expression like this and take action on it:
    <xsl:if test="<b>//child = 'value1'</b>">
        <i>.. Do what you want to do here..</i>
    </xsl:if>
    With kind regards
                 Sebastian

  • String comparision using tokens (challenging question)

    Hello, everyone.
    i am having a problem with string comparision.
    for example, the input file is:
    each line is an input line (string)
    1)a x
    2)b c x
    3)a b x
    4)a b y
    5)a b c x
    in above example a,b,c,x,y are strings(tokens)
    in above example
    line 1 ,3,5 has token "a" common and class "x" is also common
    if this condition is satisfied,
    line 1 should be send to general file (output file 1) and
    line 3 and 5 should be send to specific file (output file 2)
    rest of the lines should be send to third file.
    remember in line 4, token "a" is same when compared with line1
    but it has a different class (y) .this line will go the third file. this is where line 3 and 4 differs.
    i have read this file into an string array.
    how to proceed further.
    i am new to java programming.
    cheers in advance.

    Well, first off, I'm assuming that you keep the first string as the first token and the class name as your last token, then you tokenize everything using StringTokenizer. the code would look something like this. You could also use countTokens() to know how many tokens are in a tokenizer.
    My approach would be the following:
    1. Create an array of Strings to hold each line (you already did that)
    2. Go through the array, one line at a time, tokenize the String, figure out the first and last tokens
    3. Write it to the corresponding file.
    The code would be something as follows
    String ClassToLookFor, StringToLookFor; // holds which class and first string to look for
    String firstToken, lastToken; //used in checking each element with first one
    boolean firstFound = false;  // First instance of Class name and first thread combo found
    public static void main(String args[])
    StringTokenizer tokenizer;
    int tokenizerLength;
    // read in array of Strings, store it into lines or something
    int endOfRun = lines.length;
    for (int i = 0; i<endOfRun; i++)
    tokenizer = new StringTokenizer(lines);
    tokenizerLength = tokenizer.countTokens();
    if(!firstFound)
    // store the information (StringToLookFor and ClassToLookFor) and write the line to the corresponding file
    else
    firstToken = tokenizer.next();
    int runThru;
    while(runThru < (tokenizerLength - 2)) {tokenizer.next();} // going to the last token
    lastToken = tokenizer.next();
    if (firstToken.equals(StringToLookFor) && lastToken.equals(ClassToLookFor))
    {write lines[i] to second file}
    else
    {write lines[i] to third file}
    hope that helps ...

  • How do I add strings together with JSTL?

    How do I add strings together with JSTL?
    Thanks,
    JN

    Just include them together in an expression string.
    For printing
    <c:out value="${user.lastName}, ${user.firstName}"/>
    or with a set statement
    <c:set var="fullName" value="${user.lastName}, ${user.firstName}"/>

  • Get name of query string parameter in JSTL

    Is there a way to get only the query string name in a URL in JSTL?
    i.e.
    http://www.mysite.com/mypage.jsp?name=value
    and return "name" as a string. I can't seem to find any documentation saying this is possible.

    If I am using c:out or any of the jstl-core tags I don't think the request.getXYZ functions will work in tandem. (Correct me if I'm wrong). It seems like they are called before the request is called (my terminology is awful, sorry). So by the time request.getParameterNames() is called, <c:out value = ""/> has already finished - hence I can't use the value from request.getParameterNames(). I guess I wasn't clear when I asked the question that that is what I wanted to do.
    This isn't exactly what I wanted but it will work:
    <c:forEach var='parameter' items='${paramValues}'>
    <c:out value='${parameter.key}'/>
    </c:forEach>
    at http://www.informit.com/articles/article.asp?p=30946&seqNum=7
    I answered my own question but thanks anyway.

  • String manipulation in JSTL

    Hello All
    I'm a just a beginner and I'm need to write a web page that is totally based on JSTL. I found out that the standard java tab lib in JSTL doesnt really support string manipulation or regular expression like in perl.
    As such, I would like to know what are the different options (like adding servlets/javabeans/etc) can i add to my JSTL page so that i can perform complex string manipulation to a data entered by the user in the text box?
    Some of the operations that I wish to carry out on the data are:
    1. check if data contains certain characters, strings
    2. joining and spliting strings
    3. find length of the string
    4. find the position of certain character in a string
    5. check if string match certain pattern.
    and many more.
    Would greatly appreciate if you guys can help to provide some light.
    Regards
    Beginner....

    You might find MicroNova YUZU JSP tag library (http://sourceforge.net/projects/micronova-yuzu) useful, especially if you need to support both JSP 1.2 and 2.0. Hope this helps.

  • Using StartsWith for String Comparision in Business rules

    hi,
    I need to compare whether a particular string starts with some pre-defined prefixes. These are bound to change from time to time and hence we wanted to use the business rule engine for this. We declared prefixes using "list of values" vocab and
    defined the set. Now, I hoped to use the String.StartsWith() method but couldn't understand if it can be used.
    As of now, we are creating a method and that will be called with 2 parameters. One the string and other is one of the list of values which we want the string to start with. Is there any better way to do this?
    Praveen Behara
    MCST : BizTalk Server 2006 R2, 2010

    Hi Murugesan,
    I need to match a particular series of numbers... say 12xxx,345xxx,567xxx. I am creating a
    Series as a list and the valid values would be 12, 345, 567. I intend to keep them as prefixes i.e. they are not regular expressions. So, they won't be 12.*, 345.*, 567.*. The idea is to keep the vocab close to requirement
    and away from implementation (typically, for a business user). Now, if I want this setup, how will the implementation with
    Match look like?
    Technically, your above solution would work.. but my way of implementation / thought process is for a different purpose.
    Praveen Behara
    MCST : BizTalk Server 2006 R2, 2010

  • Program for string comparision in ABAP

    Hi,
    I require a program in abap for string comparision

    Comparing Strings
    Similarly to the special statements for processing strings, there are special comparisons that you can apply to strings with types C, D, N, and T. You can use the following operators:
    <operator>
    Meaning
    CO
    Contains Only
    CN
    Contains Not only
    CA
    Contains Any
    NA
    contains Not Any
    CS
    Contains String
    NS
    contains No String
    CP
    Contains Pattern
    NP
    contains No Pattern
    There are no conversions with these comparisons. Instead, the system compares the characters of the string. The operators have the following functions:
    CO (Contains Only)
    The logical expression
    <f1> CO <f2>
    is true if <f1> contains only characters from <f2>. The comparison is case-sensitive. Trailing blanks are included. If the comparison is true, the system field SY-FDPOS contains the length of <f1>. If it is false, SY-FDPOS contains the offset of the first character of <f1> that does not occur in <f2> .
    CN (Contains Not only)
    The logical expression
    <f1> CN <f2>
    is true if <f1> does also contains characters other than those in <f2>. The comparison is case-sensitive. Trailing blanks are included. If the comparison is true, the system field SY-FDPOS contains the offset of the first character of <f1> that does not also occur in <f2>. If it is false, SY-FDPOS contains the length of <f1>.
    CA (Contains Any)
    The logical expression
    <f1> CA <f2>
    is true if <f1> contains at least one character from <f2>. The comparison is case-sensitive. If the comparison is true, the system field SY-FDPOS contains the offset of the first character of <f1> that also occurs in <f2> . If it is false, SY-FDPOS contains the length of <f1>.
    NA (contains Not Any)
    The logical expression
    <f1> NA <f2>
    is true if <f1> does not contain any character from <f2>. The comparison is case-sensitive. If the comparison is true, the system field SY-FDPOS contains the length of <f1>. If it is false, SY-FDPOS contains the offset of the first character of <f1> that occurs in <f2> .
    CS (Contains String)
    The logical expression
    <f1> CS <f2>
    is true if <f1> contains the string <f2>. Trailing spaces are ignored and the comparison is not case-sensitive. If the comparison is true, the system field SY-FDPOS contains the offset of <f2> in <f1> . If it is false, SY-FDPOS contains the length of <f1>.
    NS (contains No String)
    The logical expression
    <f1> NS <f2>
    is true if <f1> does not contain the string <f2>. Trailing spaces are ignored and the comparison is not case-sensitive. If the comparison is true, the system field SY-FDPOS contains the length of <f1>. If it is false, SY-FDPOS contains the offset of <f2> in <f1> .
    CP (Contains Pattern)
    The logical expression
    <f1> CP <f2>
    is true if <f1> contains the pattern <f2>. If <f2> is of type C, you can use the following wildcards in <f2>:
    for any character string *
    for any single character +
    Trailing spaces are ignored and the comparison is not case-sensitive. If the comparison is true, the system field SY-FDPOS contains the offset of <f2> in <f1> . If it is false, SY-FDPOS contains the length of <f1>.
    If you want to perform a comparison on a particular character in <f2>, place the escape character # in front of it. You can use the escape character # to specify
    characters in upper and lower case
    the wildcard character "" (enter # )
    the wildcard character "" (enter # )
    the escape symbol itself (enter ## )
    blanks at the end of a string (enter #___ )
    NP (contains No Pattern)
    The logical expression
    <f1> NP <f2>
    is true if <f1> does not contain the pattern <f2>. In <f2>, you can use the same wildcards and escape character as for the operator CP.
    Trailing spaces are ignored and the comparison is not case-sensitive. If the comparison is true, the system field SY-FDPOS contains the length of <f1>. If it is false, SY-FDPOS contains the offset of <f2> in <f1> .
    DATA: F1(5) TYPE C VALUE <f1>,
          F2(5) TYPE C VALUE <f2>.
    IF F1 <operator> F2.
       WRITE: / 'Comparison true, SY-FDPOS=', SY-FDPOS.
    ELSE.
       WRITE: / 'Comparison false, SY-FDPOS=', SY-FDPOS.
    ENDIF.
    The following table shows the results of executing this program, depending on which operators and values of F1 and F2.
    <f1>
    <operator>
    <f2>
    Result
    SY-FDPOS
    'BD '
    CO
    'ABCD '
    true
    5
    'BD '
    CO
    'ABCDE'
    false
    2
    'ABC12'
    CN
    'ABCD '
    true
    3
    'ABABC'
    CN
    'ABCD '
    false
    5
    'ABcde'
    CA
    'Bd '
    true
    1
    'ABcde'
    CA
    'bD '
    false
    5
    'ABAB '
    NA
    'AB '
    false
    0
    'ababa'
    NA
    'AB '
    true
    5
    'ABcde'
    CS
    'bC '
    true
    1
    'ABcde'
    CS
    'ce '
    false
    5
    'ABcde'
    NS
    'bC '
    false
    1
    'ABcde'
    NS
    'ce '
    true
    5
    'ABcde'
    CP
    'b'
    true
    1
    'ABcde'
    CP
    '#b'
    false
    5
    'ABcde'
    NP
    'b'
    false
    1
    'ABcde'
    NP
    '#b'
    true
    5
    goto sap library if intsalled in ur system and check the above one....

  • String comparision in fields

    HI All,
         I have a requirement to compare strings.
         Like this:
         parameters:  belnr like bkpf-belnr.
         Select * from swwwihead into table t_swwwihead
            where ( WI_TYPE EQ 'F'   or
                    WI_TYPE EQ 'W' ) AND
                    WI_CD GE l_budat.
         X2 = belnr.
         Loop at t_swwwihead.
           X1 = t_swwwihead-TEXT.
           IF X1 byte-cs X2.
             write :/ t_swwwihead-TEXT.
           Endif.
         Endloop.
         I tried to use 'CP' but i could not compare using fields. I mean i have to compare the values in the fields.
    I tried byte-cs but that i can only compare in terms of bytes and my text doesnot have zeros at the begining. and xstring pads zeros to the string to make it a full byte it seems.
    how can i compare this ?

    Hi,
    Try to concatenate * in the beginning and in the end of the to be compared string before using CP..
    Example
    data: X1 type string.
    X1 = 'Approve Parked document 100638133 initiated by USER123'.
    data: X2 type string.
    X2 = '100638133'.
    CONCATENATE '' X2 '' INTO X2.
    IF X1 CP X2.
      write: / 'True'.
    ELSE.
      write: / 'False'.
    ENDIF.
    Thanks,
    Naren
    Message was edited by: Narendran Muthukumaran

  • String Comparision in pl/sql

    Hi,
    i executed the below code and found that output should be 5 but it shows 7(always else part). it is not comparing string in case. can anybody state the reason.
    declare
    check_in_date date;
    var_day varchar2(11);
    rate_id number;
    begin
    check_in_date := '23-mar-2013';
    select to_char(check_in_date, 'DAY') into var_day from dual;
    dbms_output.put_line(var_day);
    select case
    when VAR_DAY = 'SATURDAY' THEN
    5
    WHEN VAR_DAY = 'SUNDAY' THEN
    6
    ELSE
    7
    END
    into rate_id
    from dual;
    DBMS_OUTPUT.PUT_LINE(rate_id);
    end;
    Thanks.
    Vipin

    Change this
    select to_char(check_in_date, 'DAY') into var_day from dual;as
    select to_char(check_in_date, 'fmDAY') into var_day from dual;You need to use the "fm" (format model) specificaton otherwise the value will be right padded with space for the max size.
    SQL> select '"' || to_char(sysdate+level, 'DAY') || '"' without_fm,
      2         '"' || to_char(sysdate+level, 'fmDAY') || '"' with_fm
      3    from dual
      4  connect by level <= 7;
    WITHOUT_FM  WITH_FM
    "FRIDAY   " "FRIDAY"
    "SATURDAY " "SATURDAY"
    "SUNDAY   " "SUNDAY"
    "MONDAY   " "MONDAY"
    "TUESDAY  " "TUESDAY"
    "WEDNESDAY" "WEDNESDAY"
    "THURSDAY " "THURSDAY"
    7 rows selected.

  • String comparision in reverse order

    Hi all
    i want a logic in plsql which compares string and substring
    and soon from last digit in the number to first digit.
    If condition mets gives out put
    for example my input is
    INPUT = 1234567890
    TO COMPARE WITH a column has list of values like
    1234560000
    1234567000
    1234567800....soon
    so now the condition is
    the input 1234567890 should match with the column value
    1234567890
    if value is not there it should match with
    123456789
    if not 12345678 soon till 1 in reverse comparision

    In SQL:
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select '123456' col1 FROM dual)
      2  SELECT col1,inp,lvl FROM
      3  (SELECT SUBSTR(:my_num,1,level-1) inp,level - 1 lvl FROM
      4  dual CONNECT BY level <= LENGTH(:my_num)) x,t
      5* WHERE t.col1 = x.inp
    SQL> /
    COL1   INP               LVL
    123456 123456              6
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select '1234567890' col1 FROM dual)
      2  SELECT col1,inp,lvl FROM
      3  (SELECT SUBSTR(:my_num,1,level-1) inp,level - 1 lvl FROM
      4  dual CONNECT BY level <= LENGTH(:my_num) + 1) x,t
      5* WHERE t.col1 = x.inp
    SQL> /
    COL1       INP               LVL
    1234567890 1234567890         10
    -- in plsql
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2  my_val VARCHAR2(100) := NULL;
      3  BEGIN
      4  FOR I IN REVERSE 1..LENGTH(:my_num) LOOP
      5  DBMS_OUTPUt.PUT_LINE('substring value:'||SUBSTR(:my_num,1,I));
      6  BEGIN
      7  SELECT '123456' INTO my_Val FROM dual WHERE '123456' = SUBSTR(:my_num,1,I);
      8  EXCEPTION
      9  WHEN NO_DATA_FOUND THEN
    10  NULL;
    11  END;
    12  EXIT WHEN my_Val IS NOT NULL;
    13  END LOOP;
    14  DBMS_OUTPUT.PUT_LINE('matched value:'||my_val);
    15* END;
    SQL> /
    substring value:1234567890
    substring value:123456789
    substring value:12345678
    substring value:1234567
    substring value:123456
    matched value:123456
    PL/SQL procedure successfully completed.
    SQL> print :my_num
    MY_NUM
    1234567890

  • String comparision

    String a = "alpha";
    String b = "xxxxalphayyyyyyy";
    is there any method that returns true, if I had to check if String b contains a, otherwise false.....

    What version of Java are you using?
    edit: never mind, you got spoonfed in the meantime, I see
    Edited by: georgemc on Jul 22, 2008 7:12 PM

  • String comparision issue

    Good morning folks,
    I want to take basically month and year of sysdate and compare with month and year of field in database and compare them.
    But it is not working.
    select case when
    (concat(TO_CHAR(sysdate, 'MM'), to_char(sysdate,'YYYY')) >
    concat(to_char(max(as_of_date),'MM'), to_char(max(as_of_date),'YYYY'))) then 'Not Archived'
    else 'Archived' end from historical_advs_curr_eom
    can someone suggest me any other better way of doing?
    May be I shouldn't convert sysdate to string?
    Thanks much folks.
    regards
    nathan

    user12131044 wrote:
    May be I shouldn't convert sysdate to string?Exactly. A string is not a date. Nor a number. So comparisons using strings do not behave like comparisons using dates and numbers.
    Always try and use data in its native format - do not convert it into another data type as that data type will often behave differently and not provide the expected answer.
    It is also not a good idea from a performance perspective. If you have an index or a number columns, the index value is numeric. If you now do a conversion of the column to a string and compare using that, it renders that index that contains numbers and not strings, useless.
    Conversion also is an overhead - especially when it needs to be applied to every single row that the SELECT statement hints.
    So rather stick to the native data type of that column. It is a lot more sensible.

  • String Comparision ---please do help me

    Hai all,
    I have a problem ,
    1. i have an ArrayList which contains a list of all properties in the app, and an HashMap which contains the name of the file as the key and the string representation of the file as the value. i need to search the key of the ArrayList in the value of the HashMap(String representation of the file)
    I have written the code as follows and its not working to get the values
    Code:
    HashMap hashReport=new HashMap();
                   //Get the resource File Keys in the form of an ArrayList
                   ArrayList rList=getResourceFiles(); // name of a function
                   //Get the source Files and the String Representation of the
                   //Source File in the form of a HashMap.
                   HashMap sourcemap=createSourceMap(); // name of a function
                   Set sourceSet=sourcemap.keySet();
                   Iterator arrIter=rList.iterator();
                        while(arrIter.hasNext())
                             String arrString=(String)arrIter.next();
                             Iterator sourceIter=sourceSet.iterator();
                             while(sourceIter.hasNext())
                                  String sourceStr=(String)sourceIter.next();
                                  String valueStr=(String)sourcemap.get(sourceStr);
                                  if ((arrString.indexOf(valueStr))!= -1)
                                       if(hashReport.put(arrString,sourceStr)== null)
                                            hashReport.put(arrString,sourceStr);
                                       else
                                            hashReport.put(arrString , ", "+ sourceStr);
    please do help me in the regard.

    hashReport.put(arrString , ", "+ sourceStr);This does not append sourceStr to the existing value. It just puts sourceStr, with a comma in front of it, in hashReport, overwriting any value that was already associated with arrString. If you want to append, you'll need to save the value from when you checked it earlier:
    if(hashReport.put(arrString,sourceStr)== null)By the way, that kinds of make the following statement kind of extraneous. You only need to do extra work if the result of the first put is not null.
    The approach you're taking may not be ideal anyway. Rather than creating long comma-delimited Strings, another approach you could take is to use Lists as the values of the result map, like this:
    if ((valueStr.indexOf(arrString))!= -1) {
      List val = hashReport.get(arrString);
      if (val == null) {
        val = new ArrayList();
        hashReport.put(arrString, val);
      val.add(sourceStr);
    }

  • Basic Doubt regarding string comparision

    I have the following code:
    RegisterForm rf = (RegisterForm)form;
    String user = rf.getUsername();
    DTO ourdto = DBconnection.getDTO();               
    String pass = ourdto.getPword();When I print user,*pass* both the strings print "*pojo*"
    Now the condition I have to satisfy is
    pseudo code ---- if(*user* isequal to pass) { proceed forward }.
    I have used .equals but it is returning false,used equalsIgnoreCase and isContentEquals both are returning false.
    Could someone tell me if there is any method that can compare "pojo" to "pojo" and return a true.
    .

    sidster wrote:
    I have used .equals but it is returning false,used equalsIgnoreCase and isContentEquals both are returning false.Then they're not equal.
    Could someone tell me if there is any method that can compare "pojo" to "pojo" and return a true.
    String str = getUserInputOrWhatever();
    if ("pojo".equals(str)) {
      // the string was "pojo"
    }

Maybe you are looking for

  • I cannot recover my Master Password under 10.6.8. I want to change it. I do have my admin password for my account. How can I create a new master pw?

    I cannot recover my Master Password under 10.6.8. I want to change it. I do have my admin password for my account. How can I create a new master pw?

  • Running Short on HD space

    I'm running short on hard drive space. I know my itunes folder takes up almost half of it and when I add applications and photos, don't quite make it to 3/4 of the space. I was wondering if there was any software I could use that would tell me where

  • Syntax error Creating Transparent Partition in MaxL

    Hello, I'm trying to create a simple transparent partition (no mapping needed, just using all the 3 dimensions and descendants in the source database to the target database. I'm getting a syntax error, I went through the MaxL naming conventions and a

  • Move to another computer?

    I want to purchase the Student Edition of the Creative Suite Standard on bahalf of our children (whom we homeschool).  We are starting with an older iMac (~2008) and I need to be sure that if I purchase a newer, more powerful, Mac in the future that

  • Feels like a virus please help

    My computer is acting weird. Almost all programs are no longer working. Everything quits, from system profiler, photobooth, installer, to Quicktime, & QuarkXpress. Programs that open are missing letters in the menu bars and websites like aol also hav