Comparing variables :(

I am going crazy. I am a Java beginner:
if(numOfConnections < alowConections)
this line is not working properly while i run this little server of mine. It should limit connections, and even thought number should be less then 3 (in this case) it alows 3 connections. other thing is when client has disconnected by closing the telnet window the numOfConnections is decremented, but then it wount let 3rd connection to be made.. what's going on? this is crazy.
P.S. any other advise regarding the code?
import java.net.*;
import java.io.*;
public class Server {
     ServerSocket sock = null;
     static int numOfConnections = 0;
     static final int alowConections = 3;
     public Server() {
          try {
               sock = new ServerSocket(4413);
          } catch(Exception e) {
               System.out.println("E" + e.getMessage());
          try {
               while(true) {
                    if(numOfConnections < alowConections) {
                         new MultiServer(sock.accept()).start();
                         numOfConnections += 1;
                         System.out.println("Number of clients connected: " + numOfConnections);
                    } else {
                         new RegectServer(sock.accept()).start();
          } catch (Exception e) {
               System.out.println(e.getMessage());
     public static void main(String[] args) {
          Server serve = new Server();
     public static void printNumOfConnections() {
          System.out.println("Number of clients connected: " + numOfConnections);
class MultiServer extends Thread {
     Socket client;
     MultiServer(Socket cl) {
          client = cl;
     public void run() {
          try {
               InputStreamReader isr = new InputStreamReader(client.getInputStream());
               BufferedReader is = new BufferedReader(isr);
               PrintWriter os = new PrintWriter(new
                    BufferedOutputStream(client.getOutputStream()), false);
               String outLine = "Welcome to spilo Server!";
               os.println(outLine);
               os.flush();
               while(true) {
                    String inLine = is.readLine();
                    if(inLine == "exit" | inLine == null) break;
                    os.println(inLine);
                    os.flush();
               Server.numOfConnections -= 1;
               Server.printNumOfConnections();
               os.close();
               is.close();
               client.close();
          } catch(IOException e) {
               System.out.println(e.getMessage());
class RegectServer extends Thread{
     Socket client;
     RegectServer(Socket cl) {
          client = cl;
     public void run() {
          try {
               PrintWriter os = new PrintWriter(new
                         BufferedOutputStream(client.getOutputStream()), false);
               String outLine = "Server Full, Bye";
               os.println(outLine);
               os.flush();
               os.close();
               client.close();
          } catch(IOException e) {
               System.out.println("Error");
}

if(numOfConnections < alowConections)
this line is not working properly while i run this
little server of mine. It should limit connections,
and even thought number should be less then 3 (in
this case) it alows 3 connections. That's just fine, you defined it this way. E.g. when there are 2 connections, the check will result in true as 2 < 3. If you want only 2 connections, reduce "alowConections" to 2.
other thing is
when client has disconnected by closing the telnet
window the numOfConnections is decremented, but then
it wount let 3rd connection to be made.. what's going
on? this is crazy.I bet the line " Server.numOfConnections -= 1;" is not reached as an IOException is thrown when you read from/write to a closed connection; add this line into a finally clause, for instance.
P.S. any other advise regarding the code?Yes, som quick ones:
Don't do your main job in the constructor, that's no good style.
Also: you catch and only write out possible exceptions when trying to create the server socket -- the program shouldn't go on if this socket can't be created.

Similar Messages

  • Period Comparation Variable

    Hello
    i have two selection parameter
    for example
    Period 1 = 2010
    Period 2 = 2011
    period_1 = technical name of variable for 0calyear
    period_2 = technical name of variable for 0calyear
    then i created another variable for show in the report
    show_period_1 = text variable, replacement path 0calyear // wrong way, i supposed the put something connect to variable
    i wanted to create the show_period_2 = text variable, replacement path 0calyear
    but, its wont work because i want to show the period2
    for example, report:
    Product| revenue %show_period_1% | revenue %show_period_2%
    Product| revenue 2010 | revenue <blank>
    what I want is
    Product| revenue 2010 | revenue 2011
    How can I do it?
    thx regards

    hi,
    thanks.
    im using query designer 3.x
    but, there is not that option just
    When u create variable the options are:
    - Type variable: TEXT ( u cant change)
    - Variable name:
    - description
    - Precessing: option: User entry/Default Value OR Replacement Path or Customer exit
    if u select
    Replacement path
    its come Characteristic: (there is no options for variable still) then i select calander (0calyear)
    then come
    - Replace Variable with : options: Key or External Key Value or Name(text)
    - for interval user from value or to value
    -offset  start offset lenght
    there is no options to choose variable
    what u suggest i do?
    thx

  • Targeting variables in other symbols

    I am trying still to simulate a collision funcionality, so i tought that if i put a bullet, wich will say, close, far, not so far, and a matching enemy variable i could make illusion of this. so i been able to compare variables in symbol and if else acording the response, but i want to do a & statement to compare the 2 variables in the 2 symbols and i been unsuccesfull, this is what i have:
    sym.setVariable("bala", "close");
    //obtener el valor de un símbolo de variable
    var mybala = sym.getVariable("bala");
    //alert(mybala);
    if (mymalo == "close" & mybala == "close"){
              //sym.getComposition().getStage().getSymbol("colores").play("verde");
              //sym.getComposition().getStage().getSymbol("gradient").play("tres");
              alert("both true")
              // detener la línea de tiempo en la posición determinada (ms o etiqueta)
    I know i must do a complete target path for the variables but dont know how to do it on edge! here is the files: http://mazatlanonline.net/canion2.rar
    I try to do full path with this but it dint work
    if (sym.getComposition().getStage().getSymbol("malo").getVariable("mymalo") == "close" & sym.getComposition().getStage().getSymbol("canion2").getSymbol("bala2").getVariable("myba la") == "close"){
              alert("both true")
              // detener la línea de tiempo en la posición determinada (ms o etiqueta)
    but no alert!
    thanks a lot for the help buddies

    Hi there,
    If you are doing an AND comparison, then you want to use the && operator, correct?
    i.e., if (mymalo == "close" && mybala == "close")..
    hth,
    Joe

  • "If statement" problem in simple code?

    Hi,
    I am writing a simple homework program however am having some major problems with my "If" Statement and can not figure out why. I want my program to return a different variable if true yet it always says the statement is false. I Have it set up now in the test stage so that if false it prints out the two comparative variables in the Console and even though both variables are the same it still always says its false. Any ideas? Here are my two simple classes below. Thanks. And yes i know it doesn't go through the whole loop, it should not have to because in this test state the first variable it compares should be true.
    import java.util.StringTokenizer;
    public class PhoneList {
         private static final String PHONE_BOOK = "mom:860-192-9876,bill:654-987-1234,mary:123-842-1100";
         public static String getPhoneNumber(String name) {
              //     StringBuffer result = new StringBuffer();
              StringTokenizer st = new StringTokenizer(PHONE_BOOK, ",:");
              String[] tokens = new String[PHONE_BOOK.length()];
              int c = 0;
              String current = "";
              while (st.hasMoreTokens()) {
                   current = st.nextToken();
                   tokens[c] = current;
                   c = c + 1;
              for (int i = 0; i < c;) {
                   if (name == tokens) {
                        return "YES";
                   else {
                        return tokens[i] + "|" + name;
                   //     i=i+1;
              return "NO";
    public class Interface {
         public static void main(String[] args) {
              String hi = "mom";
              System.out.println(PhoneList.getPhoneNumber(hi));

    Hey,
    Thanks guys I got that working, my question now is, whats the best way to input a String into the console from the user and have the string stored as a string variable? I know how to do it for an INT and after reading online can do stings with the try / catch method but I want a more simple better way such as the way I do INTs...
    import java.util.Scanner;
    int choice;
    Scanner in = new Scanner(System.in);
    choice = in.nextInt();
    Any easy way to do this for Strings? Thanks

  • Updating a Date Column in SP2010 using Javascript in WP

    Hi,
    I know that Today() doesn't work in SP. But seeing all the various JS codes to highlight rows etc is rather cumbersome, especially if you have several operations that you may want to run based on Today().
    In my list, I have a column which is hidden from public view, 'thisDate'. This column is set to Date Only and with each new item that is added, it loads today's date. That's fine at item creation; but what I want to do is use JS to
    update all fields in thisDate column with today's date whenever the list is first loaded on any new day.
    <script type="text/javascript" language="javascript">
    var tDate = null;
    allItems = null;
    ExecuteOrDelayUntilScriptLoaded(UpdateList, 'sp.js'); //this is necessary to ensure the library is loaded before function triggered
    function DateThis(){
    tDate = new Date().toJSON();
    tDate.format("m/dd/yy");
    return tDate;
    function UpdateList(){
    var tContext = new SP.ClientContext.get_current();
    var tSite = tContext.get_site();
    var tWeb = tSite.get_rootWeb();
    var tList = tWeb.get_lists().getByTitle('TeamDUCOM LNO Travel');
    var tQuery = SP.CamlQuery.createAllItemsQuery();
    this.allItems = tList.getItems(tQuery);
    tContext.load(allItems, 'Include(thisDate)');
    tContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySuccess), Function.createDelegate(this, this.onQueryFailed));
    function onQuerySuccess(){
    var listEnum = allItems.getEnumerator();
    var todaysDate = DateThis();
    while(listEnum.moveNext()){
    var currentItem = listEnum.get_current();
    var origDate = currentItem.get_item('thisDate');
    currentItem.set_item('thisDate',todaysDate);
    currentItem.update();
    tContext.executeQueryAsync(Function.createDelegate(this, this.ListItemsUpdateSuccess), Function.createDelegate(this, this.ListItemsUpdateFailed));
    function onQueryFailed (){
    alert('Query List Failed ');
    function ListItemsUpdateSuccess(){
    alert('Success ');
    function ListItemsUpdateFailed(){
    alert('Update List Failed ');
    </script>
    Right now, I get an 'onQueryFailed' alert saying the Query list failed.  Also in the watch windo, I get null for 'tDate and 'todaysDate' is undefined.
    Once I can get this to work, it is my intention to add an extra line or two to compare variables
    origDate with todaysDate. If they match, skip and go to next.  I think this would reduce updates and minimze the List sending out email alerts (most of my users use Alerts to be notified of changes to the list. (Bonus
    would be being able to suspend any alert triggers at update, but I don't believe that's possible, or?)
    After all the debugging, I also intend to comment out the alerts within the code, since no one needs to see that.
    Ideally, this code would be reuseable on any list that needs countdowns, traffic lights, colorcoding etc, or even calcaulated columns using
    thisDate data in lieu of the nonexistent Today()
    function. And, as mentioned above, the list only needs to be updated once for the 1st person to open the list on any given day.
    TIA
    AH-C

    Victoria,
    That didn't work for me. When I stripped out the script tags fro the file and placed it around the script url, I kept getting an error message within the webpart while in page edit view: "Cannot retrieve the URL specified in the Content Link
    property. For more assistance, contact your site administrator."
    I tried both your suggested change and the older script every which way - before the list, after the list, hidden and not. I then focused more on the IE 9's F12 developer tool and watched as it stepped thru the code. Everything was fine with the variables
    (each object loaded in the Locals view) until it came time to call the executeQueryAsync.
    I even traced down the stack and confirming the arguments. But a thot kept bugging me about "get_rootweb". i had seen other examples where it was "get_web" instead. When I went back to search Bing, I came across an example where the coder
    just cut to the chase, bypassing varibles (in my case, dropping 'tSite' & 'tWeb'), so my trimmed code snippet now looks like this:
    var tContext = SP.ClientContext.get_current();
    var tList = tContext.get_web().get_lists().getByTitle('MyList Name');
    var tQuery = SP.CamlQuery.createAllItemsQuery();
    this.everyItem = tList.getItems(tQuery);
    Prior to that, I also changed the var 'allItems', because I wondered if that was causing conflicts, case-sensitivity notwithstanding, since my default list view was 'AllItems.aspx'
    Anyway, it now works regardless of CEWP positioning/hidden status (using only the reference to JS file in SiteAssets and using the script tags within the js file, not the CWEP link) -- typically, I make such CWEPs (ie EasyTabs) hidden and at the bottom of
    the page, after the list and it works just fine.
    I'm going to mark this thread as answered. But before I do that, I'll work out the one piece I need to add for the code to do nothing to a particular item if 'todaysDate' matches 'origDate' then post the entire code as the solution.
    Thanks again.
    Best regards,
    AH-C
    PS, I got a deluge of email alerts telling me that the list was updated. I anticipated that and will be looking for code to stop that if possible.  But with the test for matching dates, at least I can limit the deluge of emails to once a day by whomever
    is 1st to check the list that day (my alert is configured for instant alerting whenever a change has been made and I'd prefer to keep it that way, unless there's no workaround.

  • Problem With LinkedLists

    Hey Guys Iv been working on this program for a long time now and its basically a card game. I have a Cardist Class, a Deck Class, and a Card Class. I have made the Deck to basically be a array of 40 cards. but i need to make lists to represent hands of cards or cards drawn. my problem is that i cant seem to get it to work. i compiles but i keep getting: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 40 and some others at times. can you guys help? here are the classes
    CardList:
    public class CardList extends List implements Comparable {
         //variables
         private Card head;
         private int rankOfList;
         private CardList tail;
         public static CardList NIL = new CardList();
         //constructors
         public CardList() {
         public CardList(Card head, CardList tail){
              this.head = head;
              this.tail = tail;
         public CardList(Card head){
              //this.head = head;
              //CardList tail = new CardList();
              this(head, NIL);
         //accesors     
         public Card head() { return head; }
         public CardList tail() { return tail; }
         //methods
         public static CardList makeList (Card c) {
    return NIL.push(c);
         public CardList insert(Card c, int i){
              return i == 0 ? this.push(c) : this.tail().insert(c, i - 1);
         public CardList append (CardList l) {
    return this.isEmpty() ? l : this.tail().append(l).push(this.head());
         public CardList delete (Card c) {
         if (this.isEmpty()) return this;
    if (c == this.head()) return this.tail().delete(c);
    return this.delete(c);
    public Card nth (int n) {
    if (this.isEmpty() || n < 0) return null;
    return n == 0 ?
    this.head() :
    this.tail().nth(n - 1);
    public boolean isEmpty() {
    return this == NIL;
         public CardList push (Card c){
              return this.isEmpty() ? new CardList(c, new CardList()) :new CardList(c, this);
         public int totalListRank() {
              if (this.isEmpty()) return 0;
              rankOfList = this.head().getRank() + tail().totalListRank();
              return rankOfList;
         public int compareTo (Object o){
              CardList that = (CardList) o;
              if (this.length() == 0) return 0;
              if (that.length() == 0) return 1;
              if (this.length() == that.length()){
                   return this.totalListRank() > that.totalListRank() ? 1 : 0;}
              else return -1;
    /*     public String toString(){
              return this.isEmpty() ?
    "(" + this.head().toString() +
    (this.tail().isEmpty() ? "" : " ") +
    this.tail().toString().substring(1);
    Deck:
    public class Deck{
         //variables
         private Card deck[];
         private int deckMarker = 0;
         //accesors
         public Deck(){
              makeDeck();
         //methods
         public Card[] makeDeck(){
              int count = 0;
              deck = new Card[40];
              for(int suit = 1; suit <= 4; suit++){
                   for(int value = 1; value <= 10; value++){
                        deck[count] = new Card(value, suit);
                        count++;                         
              return deck;
         public void shuffle(){
              for (int i = 39; i > 0; i-- ) {
    int rand = (int)(Math.random()*(i+1));
    Card temp = deck;
    deck[i] = deck[rand];
    deck[rand] = temp;
         public CardList draw (int n){
              deckMarker += n;
              CardList someCards = CardList.NIL;
         for(int i=0;i<deckMarker;i++){     
              someCards = someCards.push(deck[i]);
              deckMarker++;
         return someCards;
    public String toString() {
    String s = "Deck ";
    for (int i = 40 - 1; i >= 0; i--)
    s += deck[i] + " ";
    return s;
    Card:
    public class Card implements Comparable {
         //variables
         //integers representing the four suites
         public final static int COIN = 1;
         public final static int SWORD = 2;
         public final static int CLUB = 3;
         public final static int CUP = 4;
         //integers representing non-integer cards
         public final static int ACE = 1;
         public final static int DONA = 8;
         public final static int CABALLO = 9;
         public final static int RE = 10;
         private int suit;
         private int value;
         private int rank;
         //constructors
         public Card(int value, int suit){
              this.value = value;
              this.suit = suit;
              this.rank = rank;
         //selectors
         public int getSuit(){
              return suit;
         public int getValue(){
              return value;
         //methods
         public boolean is7Coins(){
              return this.value == 7 & this.suit == 1;
         public int getRank(){
              switch(value){
                   case 2: return 2;
                   case 3: return 3;
                   case 4: return 4;
                   case 5: return 5;
                   case ACE: return 6;
                   case 6: return 8;
                   case 7: return 11;
                   case DONA: return 0;
                   case CABALLO: return 0;
                   case RE: return 0;
                   default: return 0;
         public String getValueAsString(){
              switch (value){
                   case 1: return "Ace";
                   case 2: return "2";
                   case 3: return "3";
                   case 4: return "4";
                   case 5: return "5";
                   case 6: return "6";
                   case 7: return "7";
                   case 8: return "Donna";
                   case 9: return "Caballo";
                   case 10: return "Re";
                   default: return "??";
         public String getSuitAsString(){
              switch(suit){
                   case 1: return "Coins";
                   case 2: return "Swords";
                   case 3: return "Clubs";
                   case 4: return "Cups";
                   default: return "??";
         public int compareTo (Object o){
              Card that = (Card) o;
              if (this.getRank() == that.getRank() && (this.suit==1 & that.suit==1) || this.suit != 1 & that.suit != 1) return 0;
              if (this.getRank() > that.getRank() || (this.getRank()==that.getRank() & this.suit == 1)) return 1;
              else return -1;
         //public boolean canPickUp(CardList cards){
         //     return this.getRank() ==
         public String toString(){
              return getValueAsString() + " of " + getSuitAsString();
    cardtest(simple ttest driver):
    public class CardTest{
              public static void main(String ars[]){
                   Deck aDeck = new Deck();
                   //aDeck.shuffle();
                   System.out.println(aDeck);
                   System.out.println(aDeck.draw(3));

    Without looking at your code, arrays range from 0 to length -1. So your array of length 40 has indices of 0 -39. There is no element at postion 40. Somewhere you probably have a loop that goes <= array.length, thus creating the error.

  • BEx Query Cell Definition (If ..then...else with AND)

    Hello Experts,
    I am struggling with a requirement which I need to define in the Cell definitions in Query designer. I have tried going through the numerous posts regarding this if..then...else in SCN but were of no help to me.
    My requirement is as follows:
    if expression1 then result1, else if (expression2 AND expression3) then result2, else (expression4 AND expression5) then result3
    I tried to define this in the cell as below:
    <expression1> * result1 + (<expression2> AND <expression3> ) * result2 + (<expression4> AND <expression5>) * result3
    but somehow it does not work.
    Any pointers of how to achieve this?
    Thanks.

    Hi,
    If you are getting 'X' then this may be related with the dimensions you use in comparing variables. Try the whole formula such as
    (nodim(var_1) > nodim(var_2) * nodim(kyf_1)
    "then try seperating the if else statements into different cells" : for example try adding a formula for
    each item in your formula (one for buchungsperiode, one for buchungsperiode ein gabe etc. I mean you can find the formula vaiable or key figure that causes 'X' in the results by seperating the formula into the items of the formula.
    Regards
    Yasemin...

  • What is the utility of watch point and break point in ABAP DEBUGGING !

    What is the utility of watch point and break point in ABAP DEBUGGING !
    PLEASE TELL ME IN DETAILS AND IF POSSIBLE WITH SCREEN SHOTS !

    Hi,
    Breakpoints, Watchpoints, and Checkpoints
    Summary
    The standard Breakpoints tool is always located on the Breakpoints desktop. With this tool, you can manage breakpoints, watchpoints and checkpoints. In addition, you can monitor the current status of the different breakpoint types.
    Detailed Description
    Breakpoints
    In the Breakpoints area, you will see a list of all the breakpoints set so far. If one of the breakpoints has just been reached, this is marked with a yellow arrow. The visibility (Debugger, session, user) and type (line, ABAP command, …) is displayed for each breakpoint.
    If you double click the Navigation() column, the system will display the breakpoint in the respective source code.
    The visibility of a breakpoint can be changed through the dropdown list. To change the visibility of several breakpoints, mark them and select the pushbutton Save as Session Breakpoint or Save as User Breakpoint.
    You can change the visibility of all Debugger breakpoints using the menu path Breakpoints-> Save Debugger BPs as -> ....
    In addition, you have functions for creating, changing, activating and deactivating breakpoints at your disposal.
    Watchpoints
    In the Watchpoints area, you will see a list of all the watchpoints set so far. The watchpoint last set is highlighted with a yellow arrow.
    For each watchpoint you will see not only the current value but the value before the last changed. (Technically speaking, each time you create the watchpoint and each time the watchpoint variable is changed, a clone of this variable is created.)
    In this way, you can always determine what changes have been made to the monitored variable. For complicated data structures, such as internal tables or structures, select the pushbutton „Compare Variables“( ) and choose the Diff tool to compare the old and new variable values.
    In addition, you have functions for creating, changing, activating and deactivating watchpoints at your disposal.
    Checkpoints
    In addition, you can edit conditional and unconditional checkpoints using the Breakpoints tool. This function is provided in the new Debugger only. Conditional checkpoints are set first in the source code using the ASSERTstatement; unconditional checkpoints are set using the BREAK-POINT statement. These have the effect that programs will be continued only if a preset condition is fulfilled. In the following window, these checkpoints can be searched for, activated, or deactivated.
    Pls refer to :
    http://help.sap.com/saphelp_nw70/helpdata/en/e2/5f5a42ed221253e10000000a155106/frameset.htm
    Regards,
    Renjith Michael.

  • What is utility of watch points and break point  in ABAp debugging !

    What is utility of watch points and break point  in ABAp debugging !

    Hi,
    Breakpoints, Watchpoints, and Checkpoints
    Summary
    The standard Breakpoints tool is always located on the Breakpoints desktop. With this tool, you can manage breakpoints, watchpoints and checkpoints. In addition, you can monitor the current status of the different breakpoint types.
    Detailed Description
    Breakpoints
    In the Breakpoints area, you will see a list of all the breakpoints set so far. If one of the breakpoints has just been reached, this is marked with a yellow arrow. The visibility (Debugger, session, user) and type (line, ABAP command, …) is displayed for each breakpoint.
    If you double click the Navigation() column, the system will display the breakpoint in the respective source code.
    The visibility of a breakpoint can be changed through the dropdown list. To change the visibility of several breakpoints, mark them and select the pushbutton Save as Session Breakpoint or Save as User Breakpoint.
    You can change the visibility of all Debugger breakpoints using the menu path Breakpoints-> Save Debugger BPs as -> ....
    In addition, you have functions for creating, changing, activating and deactivating breakpoints at your disposal.
    Watchpoints
    In the Watchpoints area, you will see a list of all the watchpoints set so far. The watchpoint last set is highlighted with a yellow arrow.
    For each watchpoint you will see not only the current value but the value before the last changed. (Technically speaking, each time you create the watchpoint and each time the watchpoint variable is changed, a clone of this variable is created.)
    In this way, you can always determine what changes have been made to the monitored variable. For complicated data structures, such as internal tables or structures, select the pushbutton „Compare Variables“( ) and choose the Diff tool to compare the old and new variable values.
    In addition, you have functions for creating, changing, activating and deactivating watchpoints at your disposal.
    Checkpoints
    In addition, you can edit conditional and unconditional checkpoints using the Breakpoints tool. This function is provided in the new Debugger only. Conditional checkpoints are set first in the source code using the ASSERTstatement; unconditional checkpoints are set using the BREAK-POINT statement. These have the effect that programs will be continued only if a preset condition is fulfilled. In the following window, these checkpoints can be searched for, activated, or deactivated.
    Regards,
    Renjith Michael.

  • netui-data:getData tag related query

    Hi
    I need to be able to compare the values returned by <netui-data:getData> tag against
    another variable (which is also implemented as <netui-data:getData>) .
    I have something as below :-
    <netui-data:getData resultId="variableA" value="{container.item.value}"/>          
    <netui-data:getData resultId="variableB" value="{request.variableB}"/>     
    <logic:equal value="variableB" name="variableA" >                         A equals B               
    </logic:equal>                                             
    I am trying to the use the struts <logic:equal> tag but I am not sure as to how
    to compare the two variables . I can easily compare variableA with a constant
    like "apples" as mentioned below :-
    <logic:equal value="apples" name="variableA" >                         A equals apples          
    </logic:equal>                                   
    But my requirements are I need to compare the two variables . How do I do that
    using the NetUI tags or struts tags ??
    Thanks
    Kar                    

    It worked like a charm John !! Still the good old scriplets to the rescue . Looks
    like when things get way too comlicated in the jsp pages , we can flip back to
    sciplets .
    - Kar
    "John Rohrlich" <[email protected]> wrote:
    Kar,
    If using scriptlet is okay you could do something like this
    <netui-data:getData resultId="foo1" value="{pageFlow.foo1}"/>
    <netui-data:getData resultId="foo2" value="{pageFlow.foo2}"/>
    <%
    if (pageContext.getAttribute("foo1") ==
    pageContext.getAttribute("foo2"))
    %>
    <netui:label value="foo1 == foo2"/>
    <%
    %>
    - john
    "kar piyush" <[email protected]> wrote in message
    news:4086b0f6$[email protected]..
    Hi
    I need to be able to compare the values returned by <netui-data:getData>tag against
    another variable (which is also implemented as <netui-data:getData>).
    I have something as below :-
    <netui-data:getData resultId="variableA" value="{container.item.value}"/>
    <netui-data:getData resultId="variableB" value="{request.variableB}"/>
    <logic:equal value="variableB" name="variableA" > A equals B
    </logic:equal>
    I am trying to the use the struts <logic:equal> tag but I am not sureas
    to how
    to compare the two variables . I can easily compare variableA witha
    constant
    like "apples" as mentioned below :-
    <logic:equal value="apples" name="variableA" > A equals apples
    </logic:equal>
    But my requirements are I need to compare the two variables . How doI do
    that
    using the NetUI tags or struts tags ??
    Thanks
    Kar

  • Equals and ==

    Hi all
    Please let me know similarities and differences between equals() method and '==' operator. Is their any good example or tutorials regarding this. Please help me. Thanks in advance.
    Regards
    Rakesh

    The == is a basic operator of the core Java language. It lets you compare variables and constants of the same type (both primitive and reference) for equality.
    The equals method is defined in Object, the universal superclass of all classes, so equals will be inherited by each and every class.
    class AnyClass {
    AnyClass c1 = new AnyClass();
    AnyClass c2 = c1;
    if (c1 == c2) { // case 1
    if (c1.equals(c2)) { // case 2
    }Case 1 and 2 above actually perform exactly the same test (both cases are true). BUT equals can be overridden in a subclass to mean something else, so you always will have to look in the class documentation to know what it does in that particular case. If you change AnyClass above to,
    class AnyClass {
       public boolean equals(Object o) {
           return false;
    }now case 1 will still be true because the reference variables are still the same, but case 2 will be false because equals has been overridden to always return false.

  • Java.util.Array

    Exception in thread "main" java.lang.ClassCastException: Card
    at java.util.Arrays.mergeSort(Arrays.java:1044)
    at java.util.Arrays.sort(Arrays.java:997)
    at CardPlayer.sortHand(CardPlayer.java:91)
    at Game.main(Game.java:75)
    i get this error message after I call a sort method using the java.util.Array
    does anyone know why, or do u need more code?
    thanks

    The Card object needs to implement the Comparable interface if an array of them is to be sorted. The ClassCastException occurs when the sorting code attempts to assign a Card Object to a Comparable variable. The API documentation refers to this problem like this:
    Throws:
    ClassCastException - if the array contains elements that are not mutually comparable (for example, strings and integers).

  • Compare data record to session variable

    I am completely stumped. It should be easy.
    I am trying to compare a field from a database to a sesssion variable on a JSP page and even though the fields print out the same when I call them in JSP, my "If" statement never gets activated.
    Here's the last version of the code I tried:
    String usernamev = UserSession.getValue("username").toString();
    String custname = RS.getString("ORCUST");
    if (usernamev.equals(custname))
    userrole="Customer ";
    I've also tried this:
    String usernamev = UserSession.getValue("username").toString();
    String custname = RS.getString("ORCUST").toString;
    if (usernamev.equals(custname))
    userrole="Customer ";
    And I've also tried this:
    if (RS.getString("ORCUST").equals(usernamev))
    userrole= "Customer ";
    And This:
    And I've also tried this:
    if (usernamev.equals(RS.getString("ORCUST")))
    userrole= "Customer ";
    When RILLI is the field I'm trying to compare this works:
    if (usernamev.equals("RILLI"))
    userrole= "Customer ";
    Somehow my data type must be wrong but I can't figure out why. When I print out
    <%=usernamev%>
    and <%=RS.getString("ORCUST")%>
    they show on my webpage as RILLI. I can also assign a constant value to userrole without a problem.
    What the heck am I doing wrong?

    I think limeybrit was on the right track and I hadn't trimmed because I got a no trim method error before because I hadn't converted session variable to a string.
    When I used this:
    String usernamev = UserSession.getValue("username").toString();
    usernamev = usernamev.trim();
    String custname = RS.getString("ORCUST").trim();
    I think its working now. Thanks for help all.

  • Use a single variable value to compare with 2 characteristics

    Hi guys
        I need some advice on how to use a single variable value to compare with 2 characteristics in a Infocube.
    eg : I hv 2 characteristics in Infocube
           Launch date  &  Closing Date
       Now I want to display report where the variable date (inputted by user) is equal to Launch Date and Closing Date.
        with regards

    Bobby,
    if I right understood your situation, you have an input variable ZINPUT (related to a date 'A') and 2 others dates (yours Launch and Closing dates, 'B' and 'C').
    You want to display only the rows where A(user input)=B=C.
    Now you have to create 2 new variables (called ZB and ZC, related to B and C dates) NOT marked as 'ready for input' and set to 'mandatory variable entry'.
    Call Transaction CMOD for the definition of the customer exit (if not already existing!).
    Create a new project, maintain the short text, and assign a development class.
    Goto Enhancements Assignments and assign RSR00001. Press the button components to continue.
    Double-click on EXIT_SAPLRRS0_001. For documentation place the cursor on RSR00001 and use the menu Goto -> Display documentation. 
    Then double-click on ZXRSRU01. If the include doesn’t exist you have to create it; assign a development class and a transport request.
    Enter the coding:
    DATA: L_S_RANGE TYPE RSR_S_RANGESID.
    DATA: LOC_VAR_RANGE LIKE RRRANGEEXIT.
    CASE I_VNAM.
    WHEN 'ZB'.
    (and you have to repeate the same code also for the variable 'ZC' !)
    IF I_STEP = 2.
    READ TABLE I_T_VAR_RANGE INTO LOC_VAR_RANGE
    WITH KEY vnam = 'ZINPUT'.
    if sy-subrc = 0.
    L_S_RANGE-LOW  = LOC_VAR_RANGE-LOW.
    endif.
    L_S_RANGE-sign = 'I'.
    L_S_RANGE-opt = 'EQ'.
    append L_S_RANGE to e_t_range.
    ENDIF.
    ENDCASE.
    Save and activate the coding and the project.
    Now go to your query and use these two new variables to restrict B and C....et voilà !!!
    Let me know if you need more help (and please assign points !!! be generous !!!)
    Bye,
    Roberto

  • Value of the variable FISCYEAR to compare it with a fix date

    Hi,
    I'm using a hierarchy in my query. But in some case I have to multipliy the value in one column depending wich year is shown. So I tried to use a formular variable. But it doesn't work. Has somebody an idea what to do?
    How can I extract the value of the variable FISCYEAR to compare it with a fix date?
    Problem:
    ........................|  Year 1 (2005)       |  Year 2 (2006)        |   Year 3 (2007)
    hierarchy row 1  | query result 11      | query result 12       | query result 13
    hierarchy row 2  | query result 21      | query result 22       | query result 23
    hierarchy row 3  | query result 31      | query result 32       | query result 33 => row is hidden
    formular row 4   | IF Year == 2005    | IF Year == 2005     | IF Year == 2005 
                             THEN                   | THEN                    | THEN                   
                            query result 31 *10 | query result 32 *10 | query result 33 *10
                            ELSE                     |ELSE                    | ELSE                   
                            query result 31       | query result 32       | query result 33

    The If Statement is no problem.
    I need the value of the variable FISCYEAR. So the value of the variable is the If-Statement. I tried to use a formula variable but don't get correct values. With BW 2004 I used the text and compared it with the string "2005". BW 2004s gives me the error message the if using the text, the value of the variable depends on the language which is not supported

Maybe you are looking for