Question about loops

hey guys,
with this piece of code here... right now I have it reading a dataSet and printing out the first Value out of 9 datapoints. How can I tweak this so that it would read through ALL 9 datapoints. I know i can do a loop but im not sure how to go about it!...
int numDataSets = dc.size(); // determine number of data sets in collection
      for (int i=0; i<numDataSets; i++) {
        dataSet ds = dc.get(i); // get the ith dataset
        String  filename = ds.sourceFileName;
        System.out.println("the number of DataSets: " + numDataSets);
        dataEl  el = ds.get(0); // get the 0th element of the ith dataset
        double value = el.getMainValue(); // get the associated main value
        int dateInt = el.getDateInt();
        //for (int dateInt=0; dateInt<0; dateInt++) {
        System.out.println("data set " + filename + ": value " + value + dateInt);
      }

You'd use a nested loop. It's no trouble to nest one loop inside another. Traditionally, if i is the index variable of the outer loop, then j is the index variable of the inner one.
By the way, if dc is a java.util.Collection (saying that it's a java.util.Collection means that it's a class that implements that interface, or implements a sub-interface of that interface), and if you're using JDK 1.5 or above, then you don't need to use an explicitly indexed for loop. You could just do this:
for(dataSet ds : dc) {
    // your code here
}And you could easily nest a similar loop inside of that.

Similar Messages

  • Basic Questions about Looping and Headers

    Hello,
    Relative SSRS newcomer here and I have a couple of foundational questions...  These are based on the simple premise of the underlying dataset returning multiple rows of data, elements of each to be displayed on subsequent pages of the report.
    Is it fair to day that the Table (or Matrix) are the basic elements used for an iterative report?
    Assuming the above is true, I'm using a Table for my first experiment here.
    I can iterate and display my records but I'm struggling with header and footer information.
    I want to display header and footer information on each page the is part of the current record.  I've tried to add these elements in the 'header row' of the table, but that doesn't seem to do it.  I don't see any facility for a footer.  Is
    this to be accomplished with row groups or something?
    Any guidance would be appreciated.

    Hi Steven,
    According to your description, you want to display interview questions and answers between interview name and date, and different interview name displays in different page. After testing the issue in my environment, we can use list to achieve your goal.
    Please refer to the following steps:
    Add a table to the design surface, drag question_name, question_answer fields from the Report Data pane to the table cells, and delete the last column of the table.
    Click anywhere in a tablix data region, in the Grouping pane, Click Add Group, select Parent Group, in the Tablix Group dialog box, select interview_name, then click OK. 
    Right click [interview_name] next to details symbol, click insert row, select Inside Group – Below, then Inside Group – Above.
    Delete the first row and the first column.
    Merge all the cells in the first and last row, then drag interview_name to the first row and drag interview_date to the last row from the Report Data pane. 
    Add a List to the design surface, drag the tablix into the List.
    Select and right click the List, in the Grouping pane, Click Group Properties, click Add button and select interview_name from the drop down list. Then click Page Breaks, and check Between each instance of a group check box, click OK.
    The following screenshot is for your reference:
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu

  • Quick question about looping movie clips

    I'm a REAL Flash novice, and I'm trying to get a movie clip to loop 3 times, and then continue on.
    Here's the code I've written (I'm sure it's painful to see)
    stop();
    if (!loopCount) {
      var loopCount:Number = 0;
    loopCount++;
    if (loopcount < 3) {
    gotoAndPlay (1)
    if (loopCount = 3) {
      gotoAndPlay(363);
    Could someone help me out?
    Thanks,
    Brandon

    use double equal (==) to test for equality:
    stop();
    if (!loopCount) {
      var loopCount:Number = 0;
    loopCount++;
    if (loopcount < 3) {
    gotoAndPlay (1)
    if (loopCount == 3) {
      gotoAndPlay(363);

  • Question about Looping through tables in Adobe Form

    Hello,
    We have an adobe form which is to be filled offline. It consists of a table. Table can have repeating rows and user can add\remove rows as they wish.  The cardinality of the context node where we need to bind this table data is set to 1…n
    We want to know the process to get all the values in the table back into our context node once the form is uploaded. I assume we need to loop through the table, and add elements to the context node.  Can someone please let us know if we’re on the right track, and provide some sample code if possible?
    <b>We can’t figure out a way to loop through a table inside an Adobe form.</b>
    We are using Web Dynpro Java with Adobe Livecycle Designer 7.1
    Your help is much appreciated.
    Thanks,
    Rob.

    Try using...
    for (z = 0; z < 16; z++) {
         this["cb"+z].setStyle("styleName", "cssCBstyle");
    That is the way to target them.  I haven't dealt with setting styles, so I can't answer for that aspect working or not.

  • Newbie question about looped querys

    Hi there!
    I'm starting in this thing of CF dev .
    My question is the next;
    I have a table with 2 foreign keys and want to order my
    result this way :
    a
    1
    name surname etc,etc
    name surname etc,etc
    2
    name surname etc,etc
    3
    name surname etc,etc
    name surname etc,etc
    name surname etc,etc
    b
    1
    name surname etc,etc
    name surname etc,etc
    2
    name surname etc,etc
    name surname etc,etc
    and so on ...
    a and b belong to foreign_key_1
    1 and 2 belong to foreign_key_2
    oneof my try codes for the query is the next one :
    select foreign_key_1,foreign_key_2,name, surname,etc...
    order by foreign_key_1 group by foreign_key_2
    thank you in advance!

    Use the group attribute of cfoutput. The cfml reference
    manual has a excellent example. If you don't have one, the internet
    does.

  • HT2506 Hello guys, I have a question about Preview - How do you loop a slideshow?

    Hello guys, I have a question about Preview - How do you loop a slideshow?

    Had the "loop" feature using Preview in 10.4.11; upgaded to 10.5.8 and it's gone. Don't you have to work at "Taking" it away? Makes no sense. Now you have to look for a third market for something that was included in Preview since the first version was launched.  ....I don't get this one.

  • Some questions about configuration in MAX.

    Hello,everyone!
    I have some questions about configuration in MAX(I am a jackaroo for motion control development),I hope I can get your help.
    I use PCI-7344+UMI-7764+Servo amplifier+Servo motor,my MAX version is 4.2 and I use NI-Motion7.5
    My question as following:
    1,In Axis Configuration,for motor type,why I must select stepper but not servo?my motor is servo motor!If I select Servo,my motor can't run,I don't know why.
     If I select stepper,though motor can work but I can't test encoder in MAX.
    2,In Stepper settings,for stepper loop mode,why I must select open-loop but not close-loop?If I select close-loop,the servo motor doesn't work too.
    3,If I want my two servo motors run at different velocity,How shoud I do?It seems I just can set the same velocity in MAX for my two servo motors.
     My English is poor,Pls pardon me!I come from China.
    Thank you for your help!
    EnquanLi
    Striving is without limit!

    Hi,Jochen,
    Thank you for your kindly help!
    The manufacturer of the drive and motor that I am using now is Japan SANYO DENKI,drive type is RS1A01AA,motor type is R2AA06020FXP00.
    And I use position control mode,thehe encoder's counts per revolution is 131072.I set the electronic gear ratio to 1:1 for drive.
    Now,I can use Close-Loop to control the motor but still has some problems.When I configure it to run in closed loop mode, the motors behave strangely and never move to the target position.When I configure it to run in closed loop mode, the motors behave strangely and never move to the target position.The detail situation is as following
    1,Motor can't run.
    2, Or motor moves to a position, then moves in the same direction agian and eventually stops.
    Except for the  two points mentioned above,"Following Error" is  occured frequently,I don't know why.
    I am still not clear why I must set the motor type be stepper in MAX .
    And I have another question:what the relationship between the steps and the counts?They have the proportion relations?I notice that there are a section said like this in help document: For proper closed-loop and p-command operation, steps per revolution/counts per revolution must be in the range of 1/32,767 < steps/counts < 32,767. An incorrect counts to steps ratio can result in failure to reach the target position and erroneous closed-loop stepper operation.
    I am verry sorry I have too many questions!
    I am very appreciate for your kingly help!Thanks again!
    EnquanLi
    China
    Striving is without limit!

  • Few questions about apex + epg and cookie blocked by IE6

    Hi,
    I would like to ask a few questions about apex and epg.
    I have already installed and configured apex 3.2 on oracle 10g (on my localhost - computer name 'chen_rong', ip address -192.168.88.175 ), and enable anonymous access xdb http server.
    now,
    1. I can access 'http://chen_rong' , 'http://localhost' , 'http://192.168.88.175' without input username / password for realm 'XDB' in IE6;
    2. I can access 'http://localhost/apex/apex_admin' , 'http://192.168.88.175/apex/apex_admin' , and I can be redirected into apex administation page after input admin/<my apex admin password> for realm 'APEX' in IE6;
    3. I can access 'http://chen_rong/apex/apex_admin' in IE6, but after input admin/password , I can not be redirected into administation page, because the cookie was blocked by IE6.
    then, the first question is :
    Q1: What is the difference among 'http://chen_rong' , 'http://localhost' , 'http://192.168.88.175' ? I have already include site 'chen_rong' into my trusted stes! why the cookie was blocked by IE6. I have already tried firefox and google browser, both of them were ok for 'chen_rong', no cookie blocked from site 'chen_rong'!
    and,
    1. I have tried to use the script in attachment to test http authentication and also want to catch the cookie by utl_http .
    2. please review the script for me.
    3. I did:
    SQL> exec show_url('http://localhost/apex/apex_admin/','ADMIN','Passw0rd');
    HTTP response status code: 401
    HTTP response reason phrase: Unauthorized
    Please supplied the required Basic authentication username/password for realm XDB for the Web page.
    Web page http://localhost/apex/apex_admin/ is protected.
    MS-Author-Via: DAV
    DAV: 1,2,<http://www.oracle.com/xdb/webdav/props>
    Server: Oracle XML DB/Oracle Database
    WWW-Authenticate: Basic realm="XDB"
    Date: Tue, 04 Aug 2009 02:25:15 GMT
    Content-Type: text/html; charset=GBK
    Content-Length: 147
    ======================================
    PL/SQL procedure successfully completed
    4. I also did :
    SQL> exec show_url('http://localhost/apex/apex_admin/','ANONYMOUS','ANONYMOUS');
    HTTP response status code: 500
    HTTP response reason phrase: Internal Server Error
    Check if the Web site is up.
    PL/SQL procedure successfully completed
    SQL> exec show_url('http://localhost/apex/apex_admin/','SYSTEM','apexsite');
    HTTP response status code: 401
    HTTP response reason phrase: Unauthorized
    Please supplied the required Basic authentication username/password for realm APEX for the Web page.
    Web page http://localhost/apex/apex_admin/ is protected.
    Content-Type: text/html
    Content-Length: 147
    WWW-Authenticate: Basic realm="APEX"
    ======================================
    PL/SQL procedure successfully completed
    my second questions is :
    Q2: After I entered into realm 'XDB', I still need went into realm'APEX'. how could I change the script show_url to accomplish these two tasks and successfully get the cookie from site.
    the show_url script is as following:
    CREATE OR REPLACE PROCEDURE show_url
    (url IN VARCHAR2,
    username IN VARCHAR2 DEFAULT NULL,
    password IN VARCHAR2 DEFAULT NULL)
    AS
    req UTL_HTTP.REQ;
    resp UTL_HTTP.RESP;
    name VARCHAR2(256);
    value VARCHAR2(1024);
    data VARCHAR2(255);
    my_scheme VARCHAR2(256);
    my_realm VARCHAR2(256);
    my_proxy BOOLEAN;
    cookies UTL_HTTP.COOKIE_TABLE;
    secure VARCHAR2(1);
    BEGIN
    -- When going through a firewall, pass requests through this host.
    -- Specify sites inside the firewall that don't need the proxy host.
    -- UTL_HTTP.SET_PROXY('proxy.example.com', 'corp.example.com');
    -- Ask UTL_HTTP not to raise an exception for 4xx and 5xx status codes,
    -- rather than just returning the text of the error page.
    UTL_HTTP.SET_RESPONSE_ERROR_CHECK(FALSE);
    -- Begin retrieving this Web page.
    req := UTL_HTTP.BEGIN_REQUEST(url);
    -- Identify yourself.
    -- Some sites serve special pages for particular browsers.
    UTL_HTTP.SET_HEADER(req, 'User-Agent', 'Mozilla/4.0');
    -- Specify user ID and password for pages that require them.
    IF (username IS NOT NULL) THEN
    UTL_HTTP.SET_AUTHENTICATION(req, username, password, 'Basic', false);
    END IF;
    -- Start receiving the HTML text.
    resp := UTL_HTTP.GET_RESPONSE(req);
    -- Show status codes and reason phrase of response.
    DBMS_OUTPUT.PUT_LINE('HTTP response status code: ' || resp.status_code);
    DBMS_OUTPUT.PUT_LINE
    ('HTTP response reason phrase: ' || resp.reason_phrase);
    -- Look for client-side error and report it.
    IF (resp.status_code >= 400) AND (resp.status_code <= 499) THEN
    -- Detect whether page is password protected
    -- and you didn't supply the right authorization.
    IF (resp.status_code = UTL_HTTP.HTTP_UNAUTHORIZED) THEN
    UTL_HTTP.GET_AUTHENTICATION(resp, my_scheme, my_realm, my_proxy);
    IF (my_proxy) THEN
    DBMS_OUTPUT.PUT_LINE('Web proxy server is protected.');
    DBMS_OUTPUT.PUT('Please supply the required ' || my_scheme ||
    ' authentication username/password for realm ' || my_realm ||
    ' for the proxy server.');
    ELSE
    DBMS_OUTPUT.PUT_LINE('Please supplied the required ' || my_scheme ||
    ' authentication username/password for realm ' || my_realm ||
    ' for the Web page.');
    DBMS_OUTPUT.PUT_LINE('Web page ' || url || ' is protected.');
    END IF;
    ELSE
    DBMS_OUTPUT.PUT_LINE('Check the URL.');
    END IF;
    -- UTL_HTTP.END_RESPONSE(resp);
    -- RETURN;
    -- Look for server-side error and report it.
    ELSIF (resp.status_code >= 500) AND (resp.status_code <= 599) THEN
    DBMS_OUTPUT.PUT_LINE('Check if the Web site is up.');
    UTL_HTTP.END_RESPONSE(resp);
    RETURN;
    END IF;
    -- HTTP header lines contain information about cookies, character sets,
    -- and other data that client and server can use to customize each
    -- session.
    FOR i IN 1..UTL_HTTP.GET_HEADER_COUNT(resp) LOOP
    UTL_HTTP.GET_HEADER(resp, i, name, value);
    DBMS_OUTPUT.PUT_LINE(name || ': ' || value);
    END LOOP;
    -- Read lines until none are left and an exception is raised.
    --LOOP
    -- UTL_HTTP.READ_LINE(resp, value);
    -- DBMS_OUTPUT.PUT_LINE(value);
    --END LOOP;
    UTL_HTTP.GET_COOKIES(cookies);
    dbms_output.put_line('======================================');
    FOR i in 1..cookies.count LOOP
    IF (cookies(i).secure) THEN
    secure := 'Y';
    ELSE
    secure := 'N';
    END IF;
    -- INSERT INTO my_cookies
    -- VALUES (my_session_id, cookies(i).name, cookies(i).value,
    -- cookies(i).domain,
    -- cookies(i).expire, cookies(i).path, secure, cookies(i).version);
    dbms_output.put_line('site:'||url);
    dbms_output.put_line('cookies:');
    dbms_output.put_line('name:'||cookies(i).name);
    dbms_output.put_line('value:'||cookies(i).value);
    dbms_output.put_line('domain:'||cookies(i).domain);
    dbms_output.put_line('expire:'||cookies(i).expire);
    dbms_output.put_line('path:'||cookies(i).path);
    dbms_output.put_line('secure:'||secure);
    dbms_output.put_line('version:'||cookies(i).version);
    END LOOP;
    UTL_HTTP.END_RESPONSE(resp);
    EXCEPTION
    WHEN UTL_HTTP.END_OF_BODY THEN
    UTL_HTTP.END_RESPONSE(resp);
    END;
    /

    I use oracle database enterprise edtion 10.2.0.3. I have already figured out the epg on 10.2.0.3 to support apex 3.2.
    And as I described above, the apex site works fine for ip address , and localhost. but the cookie will be blocked by IE6, if I want to access the site by 'http://computername:port/apex/apex_admin'. This problem does not occured in firefox and google browser. Could someone give me answer?

  • Question about LRU in a replicated cache

    Hi Tangosol,
    I have a question about how the LRU eviction policy works in a replicated cache that uses a local cache for its backing map. My cache config looks like this:
    <replicated-scheme>
    <scheme-name>local-repl-scheme</scheme-name>
    <backing-map-scheme>
    <local-scheme>
    <scheme-ref>base-local-scheme</scheme-ref>
    </local-scheme>
    </backing-map-scheme>
    </replicated-scheme>
    <local-scheme>
    <scheme-name>base-local-scheme</scheme-name>
    <eviction-policy>LRU</eviction-policy>
    <high-units>50</high-units>
    <low-units>20</low-units>
    <expiry-delay/>
    <flush-delay/>
    </local-scheme>
    My test code does the following:
    1. Inserts 50 entries into the cache
    2. Checks to see that the cache size is 50
    3. Inserts 1 additional entry (as I understand it, this should cause the eviction logic to kick-in)
    4. Checks the cache size again, expecting it to now be 20
    With HYBRID and LFU eviction policies, the above logic works exactly as expected. When I switch to LRU however, the code at step 2 always returns a value significantly less than 50. All 50 inserts appear to complete successfully, so I can only assume that some of the entries have already been evicted by the time I get to step 2.
    Any thoughts?
    Thanks.
    Pete L.
    Addendum:
    As usual, in attempting to boil this issue down to its essential elements, I left out some details that turned out to be important. The logic that causes the condition to occur looks more like:
    1. Loop 2 times:
    2. Create named cache instance "TestReplCache"
    3. Insert 50 cache entries
    4. Verify that cache size == 50
    5. Insert 1 additional entry
    6. Verify that cache size == 20
    7. call cache.release()
    8. End Loop
    With this logic, the problem occurs on the second pass of the loop. Step 4 reports a cache size of < 50. This happens with LRU, LFU, and HYBRID-- so my initial characterization of this problem is incorrect. The salient details appear to be that I am using the same cache name each pass of the loop and that I am calling release() at the end of the loop. (If I call destroy() instead, all works as expected.)
    So... my revised question(s) would be: is this behavior expected? Is calling destroy() my only recourse?
    Message was edited by: planeski

    Robert,
    Attached are my sample code and cache config files. The code is a bit contrived-- it's extracted from a JUnit test case. Typically, we wouldn't re-use the same cache name in this way. What caught my eye however, was the fact that this same test case does not exhibit this behavior when running against a local cache directly (as opposed to a repl cache backed by a local cache.)
    Why call release? Well, again, when running this same test case against a local cache, you have to call release or it won't work. I figured the same applied to a repl cache backed by a local cache.
    Now that I understand this is more a byproduct of how my unit tests are written and not an issue with LRU eviction (as I originally thought), it's not a big deal-- more of a curiosity than a problem.
    Pete L.<br><br> <b> Attachment: </b><br>coherence-cache-config.xml <br> (*To use this attachment you will need to rename 545.bin to coherence-cache-config.xml after the download is complete.)<br><br> <b> Attachment: </b><br>LruTest.java <br> (*To use this attachment you will need to rename 546.bin to LruTest.java after the download is complete.)

  • A very simple question about WF

    hi experts
    I would like to ask a question about workflow
    as u may know there is 'Loop' step in workflow, but I am confused when should I use Loop?
    Is this step used for processing internal table?  if yes, why shouldn't I create a custom BOR method and pass the entire internal table to the method?
    many thanks

    hi
    loop step for not process the internal table,
    this is used to process the some steps repetely until condition True or False.
    we have two loop steps is there
    WHILE AND UNTIL.
    Thanks
    sitaram

  • Question about PL/SQL Function in report

    Hi all. I have a (basic) question about using a PL/SQL function in a report. In my report page I have an item (PL/SQL function) that has the following syntax:
    return username from t1
    where username like 'Le%'
    I reference this item in an email process. Ideally this function would return all usernames that begin with 'Le' in the drafted email; however, its not looping so I'm only getting a return on the first name.
    I have a few books on PL/SQL but I'm not exactly sure where to start - I imagine there is a loop process I need to integrate into the function but, like I said, I'm not sure.
    I would have posted this to the PL/SQL forum but also wanted some feedback on whether or not using this method is the best way forward. Essentially I have a table with usernames and just want to send email messages based on some simple logic.
    Thanks!
    Len

    Hi Sergio,
    First, it's an honor to have you reply to my post. Thanks!
    To be more specific,
    T1 is a table containing the results from a user security scan. Username is a column in this table containing user names. What I have done is create a page in HTML DB with the following elements:
    1. An 'Item' containing the PL/SQL function that is hidden. The purpose of this Item is to generate information from T1 that meets the simple logic parameters - in this case, the user names that begin with "Le". I have called this Item P145_TT
    2. A 'Process' containing references to HTMLDB_MAIL. The 'Process' looks similar to this:
    HTMLDB_MAIL.SEND(
    P_TO => '[email protected]',
    P_FROM => 'Anon Email Account',
    P_BODY => 'Note: This message was automatically generated. Do not attempt to reply to this email.
    These are the users that begin with Le: '||:P145_TT||' ',
    P_SUBJ => 'Summary');
    3. A 'Button' to submit the process and (hopefully) send the message containing all users that adhere to the logic in the function.
    4. If I use 'return username from t1...' I will get a username generated, but like I said previously, it only gives me the first and does not loop.

  • Question about opening sockets

    Hello I have some questions about using sockets.
    I made a program which works with sockets.
    I have a class which contains this
    static byte[] send(byte outbuf[], int len, byte recbyt[], long recip[])
            InetAddress dst = InetAddress.getByName(sendip);
            DatagramPacket request = new DatagramPacket(outbuf, len, dst, sendportint);
            DatagramSocket socket = new DatagramSocket();       
    socket.send(request);
      DatagramPacket packet = new DatagramPacket(inbuf, inbuf.length);
    socket.receive(packet);
      }In another class I call this method like this
    for(int i=0;i<rows;i++)
    send(byte outbuf[], int len, byte recbyt[], long recip[])
    }As you can see it opens a socket when sending something but never close. Does this mean that evrytime I call send it opens a new socket??
    So that if rows is 500 after this loop 500 socket are opened??
    When I place close.socket after socket.receive() it works the same. Is this better or not??

    What do you mean with this line
    Method ends, Socket gets GCed and closes on GCDo you mean when the method ends the socket closes??
    And what is GC?

  • Question about IsCancelled

    Hi,
    Has anyone used the TaskHandle.EnableSytemCancel attribute
    with any success? When should this actually used? I want
    to prevent the FORTE runtime from canceling me during
    critical sections of my code.
    Basically, I'm trying to make sure that my database and
    updates I'm doing performing on regular UNIX files are kept
    in sync.
    Does anyone have any sample code that uses this attribute?
    A second question is about the debugger? Is there any
    indication, such as an exception or an event, to the
    running TOOL code when the user presses the Cancel Task
    menu item? I want to do some cleanup before exiting.
    -rick

    I have used the EnableSystemCancel attribute in the case where I am
    interfacing to an external C DLL and I need to leave the DLL in a known
    state before I clean some stuff up when the task terminates. In my case,
    the particular task is a queue service thread, so it's pretty easy to code
    this with a while loop.
    while not task.isCancelled do
    // task body is here
    end while;
    // task cleanup is here
    As for your second question, I believe choosing the Cancel Task option from
    the debugger is the same as calling MyTaskDesc.SetCancel() in TOOL code.
    The on-line help for CancelException has a good example of how to trap and
    handle this.
    Kevin Klein
    Millennium Partners, Inc.
    An association of men who will not quarrel with one another is a thing
    which has never yet existed, from the greatest confederacy of nations
    down to a town meeting or a vestry.
    -- Thomas Jefferson
    -----Original Message-----
    From: Kimball, Richard <[email protected]>
    To: 'Forte Mailing List' <[email protected]>
    Date: Monday, December 15, 1997 5:41 PM
    Subject: Question about IsCancelled
    Hi,
    Has anyone used the TaskHandle.EnableSytemCancel attribute
    with any success? When should this actually used? I want
    to prevent the FORTE runtime from canceling me during
    critical sections of my code.
    Basically, I'm trying to make sure that my database and
    updates I'm doing performing on regular UNIX files are kept
    in sync.
    Does anyone have any sample code that uses this attribute?
    A second question is about the debugger? Is there any
    indication, such as an exception or an event, to the
    running TOOL code when the user presses the Cancel Task
    menu item? I want to do some cleanup before exiting.
    -rick

  • Question about displaying data

    Based on the search criteria I need to show some info. with check box on each item, but it might retrun upto fifty items (between 1 to 50 items). Should I create checkbox/output text dynamically or how do I handle this scenario? In the jspx how do I loop it and display? Thank you.

    hi user13094256
    See my reply in your other forum thread with the same question
    at Question about displaying data
    regards
    Jan Vervecken

  • Question about servlet architecture

    Hello,
    I have a question about Web Application / servlet architecture and development, and haven't had any luck finding an answer so far. My plan must be either unusual, or wrong, or both, so I'm hoping the community here could point me in the right direction.
    I have quite a bit of background in OSGi, but very little in servlets. I know my architecture would work with something such as sever-side Equinox, but for the open source project I'm contemplating, I think that the more mainstream Tomcat/servler route would be better -- assuming it can be done. Here is a rather simplified scenario:
    There is a class, Manager. It could be a Java class that implements Runnable, or a non-HTTP servlet (GenericServlet?), but somehow it should be configured such that it runs as soon as Tomcat starts.
    When Manager runs, it instantiates its primary member variable: Hashtable msgHash; mshHash will map Strings (usernames) to ArrayList<String> (list of messages awaiting that user). Manager also has two primary public methods: addMsg() and getMsgs().
    The pseudocode for addMsg is:
    void addMsg(String username, String msg) {
    if username=="*" { for each msgList in msgHash { msgList.add(msg) } return;
    if username not in msgHash { msgHash.add(username, new ArrayList<String>) }
    msgHash[username].add(msg)
    And for getMsgs():
    String getMsgs(username) {
    String s = "";
    for each msg in msgHash[username] { s = s + msg; }
    return s;
    Once Manager has started, it starts two HTTP Servlets: Sender and Receiver, passing a reference back to itself as it creates the servlets.
    The HTML associated with Sender contains two text inputs (username and message) and a button (send). When the send button is pressed and data is POSTed to Sender, Sender takes it and calls Manager.addMsg(username.value, message.value);
    Receiver servlet is display only. It looks in the request for HTTP GET parameter "username". When the request comes in, Receiver calls Manager.getMsgs(username) and dumps the resulting string to the browser.
    In addition to starting servlets Sender and Receiver, the Manager object is also spawning other threads. For example, it might spawn a SystemResourceMonitor thread. This thread periodically wakes up, reads the available disk space and average CPU load, calls Manager.addMsg("*", diskAndLoadMsg), and goes back to sleep for a while.
    I've ignored the synchronization issues in this example, but during its lifecycle Manager should be idle until it has a task to do, using for example wait() and notify(). If ever addMsg() is called where the message string is "shutdown", Manager's main loop wakes up, and Manager shuts down the two servlets and any threads that it started. Manager itself may then quit, or remain resident, awaiting a command to turn things back on.
    Is any of this appropriate for servlets/Tomcat? Is there a way to do it as I outlined, or with minor tweaks? Or is this kind of application just not suited to servlets, and I should go with server-side Equinox OSGi?
    Thanks very much for any guidance!
    -Mike

    FrolfFla wrote:
    Hello,
    I have a question about Web Application / servlet architecture and development, and haven't had any luck finding an answer so far. My plan must be either unusual, or wrong, or both, so I'm hoping the community here could point me in the right direction.
    I have quite a bit of background in OSGi, but very little in servlets. I know my architecture would work with something such as sever-side Equinox, but for the open source project I'm contemplating, I think that the more mainstream Tomcat/servler route would be better -- assuming it can be done. Here is a rather simplified scenario:
    There is a class, Manager. It could be a Java class that implements Runnable, or a non-HTTP servlet (GenericServlet?), but somehow it should be configured such that it runs as soon as Tomcat starts.You can configure a servlet to be invoked as soon as Tomcat starts. Check the tomcat documentation for more information on that (the web.xml contains such servlets already though). From this servlet you can start your Manager.
    >
    When Manager runs, it instantiates its primary member variable: Hashtable msgHash; mshHash will map Strings (usernames) to ArrayList<String> (list of messages awaiting that user). Manager also has two primary public methods: addMsg() and getMsgs().
    The pseudocode for addMsg is:
    void addMsg(String username, String msg) {
    if username=="*" { for each msgList in msgHash { msgList.add(msg) } return;
    if username not in msgHash { msgHash.add(username, new ArrayList<String>) }
    msgHash[username].add(msg)
    And for getMsgs():
    String getMsgs(username) {
    String s = "";
    for each msg in msgHash[username] { s = s + msg; }
    return s;
    Once Manager has started, it starts two HTTP Servlets: Sender and Receiver, passing a reference back to itself as it creates the servlets. Not needed. You can simply create your two servlets and have them invoked through web calls, Tomcat is the only one that can manage servlets in any case. Servlets have a very short lifecycle - they stay in memory from the first time they are invoked, but the only time that they actually do something is when they are called through the webserver, generally as the result of somebody running the servlet through a webbrowser, either by navigating to it or by posting data to it from another webpage. The servlet call ends as soon as the request is completed.
    >
    The HTML associated with Sender contains two text inputs (username and message) and a button (send). When the send button is pressed and data is POSTed to Sender, Sender takes it and calls Manager.addMsg(username.value, message.value);
    Receiver servlet is display only. It looks in the request for HTTP GET parameter "username". When the request comes in, Receiver calls Manager.getMsgs(username) and dumps the resulting string to the browser.This states already that you are going to run the servlets through a browser. You run "Sender" by navigating to it in the browser. You run "Receiver" when you post your data to it. Manager has nothing to do with that.
    >
    In addition to starting servlets Sender and Receiver, the Manager object is also spawning other threads. For example, it might spawn a SystemResourceMonitor thread. This thread periodically wakes up, reads the available disk space and average CPU load, calls Manager.addMsg("*", diskAndLoadMsg), and goes back to sleep for a while.Since you want to periodically run the SystemResourceMonitor, it is better to use a Timer for that in stead of your own thread.
    >
    I've ignored the synchronization issues in this example, but during its lifecycle Manager should be idle until it has a task to do, using for example wait() and notify(). If ever addMsg() is called where the message string is "shutdown", Manager's main loop wakes up, and Manager shuts down the two servlets and any threads that it started. Manager itself may then quit, or remain resident, awaiting a command to turn things back on.
    Is any of this appropriate for servlets/Tomcat? Is there a way to do it as I outlined, or with minor tweaks? Or is this kind of application just not suited to servlets, and I should go with server-side Equinox OSGi?
    Thanks very much for any guidance!
    -MikeI don't see anything that cannot be done in a normal java web environment, as long as you are aware of how servlets operate.

Maybe you are looking for

  • How can I make text fill a custom shape?

    I am trying to make text in the shape of a fish, kinda like this: Can someone help me out with this one?!?!  Thanks!

  • 120GB dead. Big red X. How can I save my  10000 songs?

    Hi guys, I need your help badly. My iPod classic 120gb died on me. Red x. Computer won't recognize it. I have +10000 songs on that iPOd and that iPod alone. I am a music freak. Some of those songs were really hard to find. And I can't remember 10.000

  • Any issues giving my ipod mini to a friend?

    I've had a mini for 6-7 months and am about to upgrade to a 5th gen ipod. I'd like to give my mini to a friend. Are there any issues I should be aware of (registrations etc.) so that's she's able to use it without hitches, or it being assumed that it

  • Support: Searching for PC audio connection (TV:32W2333)

    HI, I just bought a 32W2333 LED TV and I was trying to connect my computer. I need to do it with a monitor PC cable and I bougth the TV because I saw it has a PC connection slot (RGB/PC connector in the back of the TV). But I was unable to find the s

  • Messageid in subject of mail in mail-adapter

    hi, we want to send ORDER-documents to our supplier via eMail. As subject in these mails we have to set the messageid of the document. Is it possible to set the subject of a mail in a j2ee-module? I didn't find any information about that in the XI- o