Accessing multidimensional Array using JSTL

Hi there,
first of all: I'm a newbie to JSP/JSTL :-)
I'm calling a Java-bean from my JSP. In this bean, a 2-dimensional array is created which holds four values per entry. I can access this array from my JSP w/ following code:
<jsp:useBean id="feedback" scope="session" class="de.qv.feedback.Feedback"/>
<% feedback.getDaten()     %>
<c:forEach var="ids" items="${feedback.bogenListe}">
     <c:forEach var="ids2" items="${ids}">
          <c:out value="${ids2}" />
          </c:forEach>
</c:forEach>
Now I want the data to be displayed within a HTML-table. How do I do this? I think I have to access each value one by one, but I don't know how.
Any hint will be greatly appreciated!
TIA,
Buzzy

Aye, this works :-)
One more thing: This line accesses each element one by
one:
<c:forEach var="value" items="${docs}">
Is it possible to access a specific value, e.g. only
the 2nd or 4th element?
Or do I have to use a counter and <c:if...> to to
this?No, you can do use the square brackets to get specific values if you want:
<table>
<c:forEach var="docs" items="${feedback.bogenListe}">
<tr>
//Remember arrays are zero indexed so [0][1][2][3][4] second doc = [1]
<td><c:out value="${docs[1]}"/></td><c:out value="${docs[3]}"/></td>
</tr>
</c:forEach>
</table>
//or, if you want all even values, but don't want to manually read them
<c:forEach var="docs" items="${feedback.bogenListe}">
<tr>
<c:forEach var="curr" items="${docs}" begin="1" step="2">
<td><c:out value="${curr}"/></td>
</c:forEach>
</tr>
</c:forEach>
</table>
<td><c:out value="${docs[2]}"/></td><c:out value="${docs[4]}"/></td>
</td>
</c:forEach>

Similar Messages

  • How to access variables indirectly using JSTL

    Hi,
    I have a variable called titleInsert pointing to a session variable someSessionVariable. The jsp has access to titleInsert but would like to output the value of someSessionVariable which is pointed to by tilesInsert.
    If I have something like
    <c:out value="${titleInsert}"/>
    the name of the session variable is being displayed but not the value.
    I tried something like
    <c:out value="$${titleInsert}"/> and
    <c:out value="${${titleInsert}}"/> and both resulted in JSP exceptions.
    Is there a way to display the value of someSessionVariable?
    Help appreicated,
    Kumar

    You use the implicit variable sessionScope, and the square brackets notation.
    <c:out value="${sessionScope[titleInsert]}"/>Cheers,
    evnafets

  • Return a multidimensional array using Adaptive WS model

    Hi all,
          I have created a web service that needs no request parameters and returns a 2-dimensional String array as output. I deployed the Web service and tested it using WSNavigator. It works fine.
    Now,I imported the Web service using Web service model. I got an error when importing the model itself.
    Then, I tried using Adaptive Web Service model and tried  to bind the values of the output String array in my webdynpro table. I was able to get only the first element of the 2D String array. Don't know where I am going wrong.
    This is my code:
    MO_Test instance = new MO_Test();          
    Request_GET_USERCUST inst = new Request_GET_USERCUST(instance);
    wdContext.nodeRequest_GET_USERCUST().bind(inst);
    wdContext.currentRequest_GET_USERCUSTElement().modelObject().execute();
    wdComponentAPI.getMessageManager().reportSuccess("Size:"+wdContext.node_GET_USERCUSTResponse().size());
    The size is displayed as 1!!
    Any insights?
    Thanks & regards,
    M.Subathra

    Did u use "webservice model" or "adaptive webservice model".
    Earlier i used with "wenservice model" and it was working fine. Now that with SP17, "WebService model"is depricated and we are forced to use "adaptive webservice model" and it is giving the problem. the detailed error is :
      Exception  : java.lang.NullPointerException: null
    <i>!STACK 0
    java.lang.NullPointerException
         at com.sap.engine.services.webservices.espbase.client.dynamic.impl.DOperationImpl.initParameters_DocumentStyle(DOperationImpl.java:59)
         at com.sap.engine.services.webservices.espbase.client.dynamic.impl.DOperationImpl.initParameters(DOperationImpl.java:46)
         at com.sap.engine.services.webservices.espbase.client.dynamic.impl.DOperationImpl.<init>(DOperationImpl.java:40)
         at com.sap.engine.services.webservices.espbase.client.dynamic.impl.DInterfaceImpl.initOperationNameToOperationMapping(DInterfaceImpl.java:150)
         at com.sap.engine.services.webservices.espbase.client.dynamic.impl.DInterfaceImpl.<init>(DInterfaceImpl.java:55)
         at com.sap.engine.services.webservices.espbase.client.dynamic.impl.DGenericServiceImpl.initPortNameToInterfaceMapping(DGenericServiceImpl.java:78)
         at com.sap.engine.services.webservices.espbase.client.dynamic.impl.DGenericServiceImpl.<init>(DGenericServiceImpl.java:50)
         at com.sap.engine.services.webservices.espbase.client.dynamic.GenericServiceFactory.createService(GenericServiceFactory.java:71)</i>

  • Question on System.arraycopy method and multidimensional array

    I'm trying to copy from single dimensional to multidimensional array using System.arraycopy method. The following is my problem.
    1) I need to specify the index of the multidimensional array while copying. Can I do that ? If yes , how???
    eg ; int a[] = new int[3];
    int b[] = new int[3][2]; I need to copy from a to b
    I tired the following and I'm getting an error.
    System.arraycopy(a,0,b[][1],0,3);
    How Can I achieve the above?? PLease Help --------------

    Java doesn't have multidimensional arrays. When you see an int[][] it's an array of arrays of ints. The arrays of ints might have different lengths like this one:int[][] arr =
    {{1,2,3,4},
    {1,2,3},
    {1,2},
    {1}
    };Do I need to say that arraycopy as you see it would fail in this case?
    If you know what kind of arrays you'll have you can simply implement your own arraycopy method (but it will not be as effecient as System.arraycopy) with a simple for-loop.

  • Accessing a array stored in database through JSTL, need urgent help

    Hi,
    I have a database table which contains a column storing the following structure:
    Column Name:- Score_Data
    Stores a structure in each row,
    Structure Name:- Score_Datatype
    Structure Values:- ScoreNumArray integer[], ScoreNAType character(2)
    My aim is to access ScoreNumArray values and show it in a drop down box using JSTL.
    Can someone please help me
    Thanks
    Saurabh.

    Thanx for the prompt reply,
    Actually the requirment is that my dropdown has following values 0,1,2,NA or 0,1,2,3,NA or 0,1,NA and so on....
    thats why I made a user defined type in database(postgresql) and than storing int and char in it.
    Can this be done through JSTL.
    When I use the following code:
    *<%@ include file="/html/common/init.jsp" %>
    <% pageContext.setAttribute("colors",
    new String[] {"red","green","blue","orange","black"} ); %>
    <sql:query dataSource="jdbc:postgresql://10.10.33.39:5432/globus_db,org.postgresql.Driver,postgres,marines@123" sql="select
    (\"Score_Data\").\"ScoreNumArray\" from \"Opex_Subparameters_Values_B\" where \"Short_Name\"='cs'" var="artists"/>
    <table>
    <c:forEach items="${ artists.ScoreNumArray }" var="row">
    <c:forEach var="n" items="${row}"
    varStatus="a">
    <tr>
    <td> <c:out value="${a.index}" /> </td>
    <td> <c:out value="${a.current}" /> </td>
    <td> <c:out value="${a.count}" /> </td>
    <td> <c:out value="${a.first}" /> </td>
    <td> <c:out value="${a.last}" /> </td>
    <tr>
    </c:forEach>
    </c:forEach>
    </table> *
    I get no values for a.current, means it shows nothing.
    Please suggest.
    Thanks,
    Saurabh.

  • Problems making windchill chart using multidimensional arrays

    Alright i am doing a program for my java class. The book doesnt tell me much and the teacher didnt either cause we had a midterm to take. Alright in this program i have to write a java program that produces a wind chill chart with temperatures from 50 to -50 degrees f in steps of 10 degrees, with wind speeds from 5 to 50mph, in steps of 5mph. The following formula may be useful.
    windchill= ((10.45+6.686112 * sqrt(windspeed)- .447041 * windspeed)/22.034)*(temperature- 91.4) + 91.4
    use for statements in your program and a function to calculate the wind chill factor at a given temperature and wind speed.
    I know im gonna have to use multidimensional arrays to do this problem, unless someone has an easier way to do it. I am really stuck. I have this so far.
    import javax.swing.*;
    public class lab7
    public static void main( String args[] )
    int a[][] = {{5,10,15,20,25,30,35,40,45,50},
    {-50,-40,-30,-20,-10,0,10,20,30,40,50}};
    System.exit(0);
    I am not even sure if that is correct but the major problem is how can i get the program to show a table with the temperature on the x coordinate at the top the wind speed on the y axis and then having the program use those arrays to calculate the windchill and put that in the table. I am really stuck and i was wondering if u guys could give me a little push in the right direction. The book doesnt say much so thats why im asking.
    Thank you everyone.

    I have no clue what i am doing right now. I am so confused it isnt even funny. I am trying something new to see what happens. The decimalformat didnt do anything for me. I have the numbers i just want to be able to put them into a chart. I wish my teacher would actually teach, and the book actually say how to do stuff.
    This is my program:
    import java.text.DecimalFormat;
    public class lab7
    DecimalFormat twoDigits = new DecimalFormat ("0.00");
    static private double windchill(double s, double t) { 
    return (((10.45 + 6.686112 * Math.sqrt(s) - .447041 * s)/(22.034))*(t-91.4) + 91.4);};
    static void print(double s, double t)
    {   System.out.print(" "+windchill(s, t));};
    static private void printRow(double s)
    { // the speed is assumed constant  
    for (double t= -50; t <= 50; t+= 10) // loop over the temperature values
    print(s, t); // print a row value
    System.out.println();};
    static private void printChart()
    {   for (double s= 5; s <= 50; s+= 5)      
    printRow(s);};
    public static void main(String args[])
    for (double t= -50; t <= 50; t+= 10) // loop over the temperature values
    {System.out.print( "   " + t);};
    System.out.println();
    System.out.println();
    for (double s= 5; s<=50; s+= 5)
    {System.out.println(s);};
    printChart();
    I am probably way off and this program is due tomorrow and i am going nuts. I tried to do it during the week and it didnt work out to well.
    Here is what it is outputting.
    C:\cis260>java lab7
    -50.0 -40.0 -30.0 -20.0 -10.0 0.0 10.0 20.0 30.0 40.0 50.
    0
    5.0
    10.0
    15.0
    20.0
    25.0
    30.0
    35.0
    40.0
    45.0
    50.0
    -57.26056937082865 -46.747092046159025 -36.233614721489374 -25.720137396819737
    -15.2066600721501 -4.6931827474804635 5.820294577189159 16.333771901858796 26.84
    7249226528433 37.36072655119807 47.87420387586771
    -82.65748711959239 -70.3479052865236 -58.03832345345484 -45.728741620386074 -33
    .41915978731731 -21.109577954248536 -8.799996121179774 3.5095857118890024 15.819
    167544957764 28.128749378026534 40.4383312110953
    -98.80774164293763 -85.35599188035366 -71.90424211776966 -58.452492355185655 -4
    5.00074259260168 -31.54899283001768 -18.097243067433695 -4.645493304849694 8.806
    256457734293 22.25800622031828 35.70975598290227
    -110.17157107350803 -95.91615586321751 -81.66074065292699 -67.40532544263644 -5
    3.14991023234592 -38.894495022055395 -24.639079811764873 -10.38366460147435 3.87
    17506088161713 18.127165819106693 32.38258102939722
    -118.4766111010257 -103.63385218298993 -88.79109326495416 -73.94833434691841 -5
    9.105575428882645 -44.262816510846875 -29.42005759281112 -14.57729867477535 0.26
    54602432604065 15.108219161296176 29.95097807933194
    -124.60889848734033 -109.33245587861754 -94.05601326989475 -78.77957066117196 -
    63.50312805244914 -48.22668544372635 -32.950242835003564 -17.67380022628076 -2.3
    973576175579723 12.87908499116483 28.15552759988762
    -129.09477971074705 -113.50108949075079 -97.90739927075452 -82.31370905075829 -
    66.72001883076203 -51.12632861076577 -35.53263839076952 -19.93894817077326 -4.34
    5257950777011 11.24843226921925 26.842122489215498
    -132.2771986196876 -116.45844341320333 -100.63968820671906 -84.82093300023479 -
    69.00217779375052 -53.18342258726625 -37.36466738078198 -21.545912174297698 -5.7
    27156967813428 10.09159823867084 25.91035344515511
    -134.39436482483956 -118.42588074953267 -102.45739667422575 -86.48891259891886
    -70.52042852361197 -54.55194444830505 -38.58346037299816 -22.614976297691257 -6.
    646492222384367 9.321991852922537 25.29047592822944
    -135.61971729379445 -119.56457462803812 -103.50943196228181 -87.45428929652547
    -71.39914663076914 -55.34400396501283 -39.288861299256496 -23.233718633500175 -7
    .178575967743839 8.876566698012482 24.931709363768803
    C:\cis260>
    All i want it to do is look like this: im just gonna make numbers in between just say that there is numbers in that whole thing. What am i missing. Thanks everyone so far for everything, i just need a little more and it should be done.
    -50 -40 -30 -20 -10 0 10 20 30 40 50
    5 65 44 55 78 4 45 etc etc etc
    10
    15
    20
    25
    30
    35
    40
    45
    50

  • Accessing the value in option Tag in html using JSTL

    Hi,
    Following is my code
    <select>
    <option value="1">one </option>
    <option value="2">Two</option>
    </select>
    Now, if I select two from the option, i need to get the value 2, using JSTL( JSP standard Tag Library).
    Can someone help me out.
    Thanks
    Achillies.

    You need to give the "select" component a name to submit under.
    <select name="yourChoice">
      <option value="1">one </option>
      <option value="2">Two</option>
    </select>When you submit this page, it will submit a parameter like yourChoice=2.
    In a servlet you retrieve this with request.getParameter("yourChoice");
    In JSTL/EL, you can use the param map: ${param.yourChoice}

  • Multidimensional array and chars

    Hi again,
    My apologies in advance if i can't word my question that well, i will try and be as clear and succinct as possible and hopefully for this newbie you can apprehend what i'm trying to figure out if i come up short.
    I'm trying to write a rather large control statement with a while loop and several nested ifs inside it that ultimately returns a single character after all is said and done, and then continually concatenates that character to a string which will eventually be output to a file. The part i'm stuck at is after i've changed the two letter characters into their ASCII values. I need to make the program take those two ASCII values and use them as a reference to a character in a multidimensional array of alphabetic characters, and then that character will be what is returned at the end.
    Here's the method, thanks in advance for your time.
    public String encode( String cipherKey )
            String textToEncode = input.next();
            String encodedText = " ";
            cipherKey = cipherKey.toUpperCase();
            textToEncode = textToEncode.toUpperCase();
            openFiles();
            int numberOfChars = textToEncode.length();
            int cipherPos = 0;
            int cipherLength = cipherKey.length();
            while (input.hasNext())
                for ( int count = 0; count < numberOfChars; count++ )
                    if (Character.isLetter(textToEncode.charAt(count)))
                        cipherPos %= cipherLength;
                        int xChar = (int) textToEncode.charAt(cipherPos);
                        int yChar = (int) textToEncode.charAt(count);
                        xChar -= 65;
                        yChar -= 65;
                        if ((xChar >= 0) && (xChar <= 25))
                            if ((yChar >= 0) && (yChar <= 25))
                        return ' ';
                     encodedText = encodedText +
        return encodedText; 
        }As you can see towards the end there are some incomplete statements where i became lost.

    its there, i couldnt c&p the whole program because it went over my character limit. Yeah it did compile but couldn't invoke my encode method without a NullPointerException.
    Here are the other methods in the class....
        public String setSource( String in )
            source = in;
            return source;
         Sets the value of the output file
         * @param out A <code>String</code> value representng name of output file.
         * @see #setSource
        public String setDestination( String out )
            destination = out;
            return destination;
         * Method to open both input and output files, and to test for exceptions
         * @see #encode
         * @see #decode
        private void openFiles()
        File inputFile = new File(source);  //Creates new file object from source file
        File outputFile = new File(destination);  //Creates new file object from destination file
            /* Tests whether input file exists and if so enables the Scanner
             * to read the data in from the source file. Catches SecurityException and
             * FileNotFoundException amd prints appropriate messages to user.
            if (inputFile.exists())
                try
                    input = new Scanner( new File( source ) );
                    FileReader reader = new FileReader(inputFile);
                    BufferedReader BufferIn = new BufferedReader(reader);
                catch ( SecurityException securityException )
                    System.err.println("You do not have read access to this file.");
                    System.exit( 1 );
                catch ( FileNotFoundException filesNotFoundException )
                    System.err.println("Error: File does not exist.");
                    System.exit( 1 );         
            /* Tests whether output file exists and if it does enables Formatter
             * to write encoded output to file. Catches SecurityException and
             * FileNotFoundException and prints appropriate message to user.
            if (outputFile.exists())
                try
                    output = new Formatter( new File( destination ) );
                catch ( SecurityException securityException )
                    System.err.println("You do not have write access to this file.");
                    System.exit( 1 );
                catch ( FileNotFoundException filesNotFoundException )
                    System.err.println("Error: File does not exist.");
                    System.exit( 1 );
         * Closes both input and output files after output file has been written
         * to.
         * @see #openFiles
        private void closeFiles()
            if ( output != null )
                input.close();
                output.close();
        }Edited by: fearofsoftware on Apr 17, 2009 8:35 PM

  • Use JSTL tags for ATG droplets and beans

    Hi,
    I am trying to display profile values in a JSON object in jsp.
    <dsp:getvalueof var="json" bean="ProfileFormHandler.ProfileJSON"></dsp:getvalueof>
    <c:out value="${json}" />
    but instead of using dsp tag is there a way for accessing ProfileFormHandler using JSTL tag
    Also how can we use droplets in ATG like ForEach using JSTL tags only
    <dsp:droplet name="ForEach">
    <dsp:param name="array" param="catalogItems.rootCategories"/>
    <dsp:param name="elementName" value="categoryItem"/>

    I am trying to display profile values in a JSON object in jsp.
    <dsp:getvalueof var="json" bean="ProfileFormHandler.ProfileJSON"></dsp:getvalueof>
    <c:out value="${json}" />
    but instead of using dsp tag is there a way for accessing ProfileFormHandler using JSTL tagIn the <dsp:importbean> use var to give an EL variable name to the component you are importing.You can also set its scope attribute to page, request, session, or application with page scope being the default. You can then access it as a page scoped attribute. So this should do:
    <dsp:importbean var="profileFormHandler" bean="/atg/userprofiling/ProfileFormHandler" />
    <c:out value="${pageScope.profileFormHandler.ProfileJSON}" />In case you change the scope in importbean you can accordingly use pageScope, requestScope, sessionScope or applicationScope.
    Also how can we use droplets in ATG like ForEach using JSTL tags only
    <dsp:droplet name="ForEach">
    <dsp:param name="array" param="catalogItems.rootCategories"/>
    <dsp:param name="elementName" value="categoryItem"/>Any ATG droplet is nothing but a servlet which is also a Nucleus component. So essentially you want to call a servlet from JSTL which as such shouldn't be done in a well written script-less JSP. You can probably try to use the droplet as a bean and use JSTL on top of it but since ATG droplets also have different types of parameters like input, output and open so you will have to specially handle those.

  • How to get the values of an Array using JSP Tags

    Hey guys,
    I need some help. I've splited a String using
    fn:split(String, delim) where String = "1,2,3,4" and delim is ,
    This method returns an Array of splited Strings. how do i get the values from this array using jsp tags. I don't wanna put java code to achive that.
    Any help would be highly appreciated
    Thanks

    The JSTL forEach tag.
    In fact if all you want to do is iterate over the comma separated list, the forEach tag supports that without having to use the split function.
    <c:set var="list" value="1,2,3,4"/>
    <c:forEach var="num" items="${list}">
      <c:out value="${num}"/>
    </c:forEach>The c:forTokens method will let you do this with delimiters other than a comma, but the forEach tag works well just with the comma-delimited string.

  • How to use jstl variable in a jsp page

    Hi all,
    I am new to JSTL and i want to access the value of jstl in jsp.
    when i use the tag like below it is displaying the value ""
    <c:out value="${ack}"/>
    But as ack is string, i want to convert it into int. and i have written like
    <c:set var="ackvalue" value="${ack}"/>
    and int ack = Integer.parseInt(ackvalue);
    But it is showing error like varialbe can not be resolved: ackvalue
    can anybody please help me regarding this?
    Waiting for your warm response.
    Thanks in advance

    Hi,
    Thanks for your immediate reply.
    I am able to display the ackvalue when i am using
    <c:set var="ackvalue" value="${ack}"/>
    and <c:out value="${ackvalue}"/>
    But my actual requirement is to use the ack value in
    switch statement. if i can assign the value to a
    String variable, then it si easy for me to proceed.
    Please help me in this regard.
    Thanks,You can use the c:choose, c:when and c:otherwise tags
    <c:choose>
        <c:when test = "${ackvalue == 1}">
               //do stuff
        </c:when>
        <c:when test = "${ackvalue == 2}">
               //do some other stuff
        </c:when>   
       <c:otherwise>
              //stuff
        </c:otherwise>
    </c:choose>ram.

  • I can't seem to get individual elements when comparing 2 arrays using Compare-Object

    My backup software keeps track of servers with issues using a 30 day rolling log, which it emails to me once a week in CSV format. What I want to do is create a master list of servers, then compare that master list against the new weekly lists to identify
    servers that are not in the master list, and vice versa. That way I know what servers are new problem and which ones are pre-existing and which ones dropped off the master list. At the bottom is the entire code for the project. I know it's a bit much
    but I want to provide all the information, hopefully making it easier for you to help me :)
    Right now the part I am working on is in the Compare-NewAgainstMaster function, beginning on line 93. After putting one more (fake) server in the master file, the output I get looks like this
    Total entries (arrMasterServers): 245
    Total entries (arrNewServers): 244
    Comparing new against master
    There are 1 differences.
    InputObject SideIndicator
    @{Agent= Virtual Server in vCenterServer; Backupse... <=
    What I am trying to get is just the name of the server, which should be $arrDifferent[0] or possibly $arrDifferent.Client. Once I have the name(s) of the servers that are different, then I can do stuff with that. So either I am not accessing the array
    right, building the array right, or using Compare-Object correctly.
    Thank you!
    Sample opening lines from the report
    " CommCells > myComCellServer (Reports) >"
    " myComCellServer -"
    " 30 day SLA"
    CommCell Details
    " Client"," Agent"," Instance"," Backupset"," Subclient"," Reason"," Last Job Id"," Last Job End"," Last Job Status"
    " myServerA"," vCenterServer"," VMware"," defaultBackupSet"," default"," No Job within SLA Period"," 496223"," Nov 17, 2014"," Killed"
    " myServerB"," Oracle Database"," myDataBase"," default"," default"," No Job within SLA Period"," 0"," N/A"," N/A"
    Entire script
    # things to add
    # what date was server entered in list
    # how many days has server been on list
    # add temp.status = pre-existing, new, removed from list
    # copy sla_master before making changes. Copy to archive folder, automate rolling 90 days?
    ## 20150114 Created script ##
    #declare global variables
    $global:arrNewServers = @()
    $global:arrMasterServers = @()
    $global:countNewServers = 1
    function Get-NewServers
    Param($path)
    Write-Host "Since we're skipping the 1st 6 lines, create test to check for opening lines of report from CommVault."
    write-host "If not original report, break out of script"
    Write-Host ""
    #skip 5 to include headers, 6 for no headers
    (Get-Content -path $path | Select-Object -Skip 6) | Set-Content $path
    $sourceNewServers = get-content -path $path
    $global:countNewServers = 1
    foreach ($line in $sourceNewServers)
    #declare array to hold object temporarily
    $temp = @{}
    $tempLine = $line.Split(",")
    #get and assign values
    $temp.Client = $tempLine[0].Substring(2, $tempLine[0].Length-3)
    $temp.Agent = $tempLine[1].Substring(2, $tempLine[1].Length-3)
    $temp.Backupset = $tempLine[3].Substring(2, $tempLine[3].Length-3)
    $temp.Reason = $tempLine[5].Substring(2, $tempLine[5].Length-3)
    #write temp object to array
    $global:arrNewServers += New-Object -TypeName psobject -Property $temp
    #increment counter
    $global:countNewServers ++
    Write-Host ""
    $exportYN = Read-Host "Do you want to export new servers to new master list?"
    $exportYN = $exportYN.ToUpper()
    if ($exportYN -eq "Y")
    $exportPath = Read-Host "Enter full path to export to"
    Write-Host "Exporting to $($exportPath)"
    foreach ($server in $arrNewServers)
    $newtext = $Server.Client + ", " + $Server.Agent + ", " + $Server.Backupset + ", " + $Server.Reason
    Add-Content -Path $exportPath -Value $newtext
    function Get-MasterServers
    Param($path)
    $sourceMaster = get-content -path $path
    $global:countMasterServers = 1
    foreach ($line in $sourceMaster)
    #declare array to hold object temporarily
    $temp = @{}
    $tempLine = $line.Split(",")
    #get and assign values
    $temp.Client = $tempLine[0]
    $temp.Agent = $tempLine[1]
    $temp.Backupset = $tempLine[2]
    $temp.Reason = $tempLine[3]
    #write temp object to array
    $global:arrMasterServers += New-Object -TypeName psobject -Property $temp
    #increment counter
    $global:countMasterServers ++
    function Compare-NewAgainstMaster
    Write-Host "Total entries (arrMasterServers): $($countMasterServers)"
    Write-Host "Total entries (arrNewServers): $($countNewServers)"
    Write-Host "Comparing new against master"
    #Compare-Object $arrMasterServers $arrNewServers
    $arrDifferent = @(Compare-Object $arrMasterServers $arrNewServers)
    Write-Host "There are $($arrDifferent.Count) differences."
    foreach ($item in $arrDifferent)
    $item
    ## BEGIN CODE ##
    cls
    $getMasterServersYN = Read-Host "Do you want to get master servers?"
    $getMasterServersYN = $getMasterServersYN.ToUpper()
    if ($getMasterServersYN -eq "Y")
    $filePathMaster = Read-Host "Enter full path and file name to master server list"
    $temp = Test-Path $filePathMaster
    if ($temp -eq $false)
    Read-Host "File not found ($($filePathMaster)), press any key to exit script"
    exit
    Get-MasterServers -path $filePathMaster
    $getNewServersYN = Read-Host "Do you want to get new servers?"
    $getNewServersYN = $getNewServersYN.ToUpper()
    if ($getNewServersYN -eq "Y")
    $filePathNewServers = Read-Host "Enter full path and file name to new server list"
    $temp = Test-Path $filePathNewServers
    if ($temp -eq $false)
    Read-Host "File not found ($($filePath)), press any key to exit script"
    exit
    Get-NewServers -path $filePathNewServers
    #$global:arrNewServers | format-table client, agent, backupset, reason -AutoSize
    #Write-Host ""
    #Write-Host "Total entries (arrNewServers): $($countNewServers)"
    #Write-Host ""
    #$global:arrMasterServers | format-table client, agent, backupset, reason -AutoSize
    #Write-Host ""
    #Write-Host "Total entries (arrMasterServers): $($countMasterServers)"
    #Write-Host ""
    Compare-NewAgainstMaster

    do not do this:
    $arrDifferent = @(Compare-Object $arrMasterServers $arrNewServers)
    Try this:
    $arrDifferent = Compare-Object $arrMasterServers $arrNewServers -PassThru
    ¯\_(ツ)_/¯
    This is what made the difference. I guess you don't have to declare arrDifferent as an array, it is automatically created as an array when Compare-Object runs and fills it with the results of the compare operation. I'll look at that "pass thru" option
    in a little more detail. Thank you very much!
    Yes - this is the way PowerShell works.  You do not need to write so much code once you understand what PS can and is doing.
    ¯\_(ツ)_/¯

  • How to create a table in MS Access from Labview using ActiveX?

    I want to transfer datas from Labview to Access using activeX method. My only problem is to find out how to create a new table (array) in Access from the Labview program.
    Remarks: I use Labview 6i and MS Access 2000.
    For the moment I can write and read datas of Access from Labview.
    If someone could help me... that would be grate!

    This is off the Microsoft MSDN site "creating an external table". I think you can drop the last step.:
    Open the database you want to create the table in. If it is the current database, use the CurrentDb function to return an object variable that represents the current database. If it isn�t the current database, use the OpenDatabase method to open the database you want.
    Use the CurrentDb function to create a Database object that points to the current database.
    Use the CreateTableDef method of the Database object to create a table definition for the Microsoft Access table.
    Use the CreateField method of the TableDef object to create one or more fields in the Microsoft Access table.
    Use the Append method of the Fields collection to add the new field or fields t
    o the Microsoft Access table.
    Use the Append method of the TableDefs collection to create the Microsoft Access table.
    Use the TransferDatabase method to create the external table in the specified folder.
    Use the Delete method of the TableDefs collection to delete the Microsoft Access table definition.

  • How to access XML attributes with JSTL

    Hello,
    I'm using the XML functions of JSTL. I'm trying to parse the following RSS feed.
    http://weather.yahooapis.com/forecastrss?p=USNY0996
    I can get it parsed and access the elements via JSTL, but is it possible to access the attributes of some of the elements?
    For example, how can I get the city attribute out of
    <yweather:location city="New York" region="NY" country="US" />

    Hello,
    I'm using the XML functions of JSTL. I'm trying to parse the following RSS feed.
    http://weather.yahooapis.com/forecastrss?p=USNY0996
    I can get it parsed and access the elements via JSTL, but is it possible to access the attributes of some of the elements?
    For example, how can I get the city attribute out of
    <yweather:location city="New York" region="NY" country="US" />

  • Send Vector class to JSP and print this Vector using JSTL

    Hello All!
    I need your help to solve my question.
    I developed a Servlet + jsp application.
    I tested it in local with Apache Tomcat/6.0.20 and it works correctly.
    I write and use these classes:
    class for execute query, and including data page:
    package MySQL;
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    import java.util.*;
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    * @author initmax
    public class MySQLQuery {
        private Connection CurrentConnect; //obj for connect to databae
        private Vector VectorPageObj = new Vector(); //save array object page, after execute query
    public MySQLQuery() {}
    //constructor accept current conection database
    public MySQLQuery(Connection CurrentConnectBase)
        CurrentConnect = CurrentConnectBase;
    //method accept name table and return all info on this table
    public void SelectAllField(String NameTable)
           try
             Statement st = CurrentConnect.createStatement();
             String query = ("select * from "+NameTable);
             ResultSet resultQuery = null;
             resultQuery = st.executeQuery(query);
    //step in cycle after execution query, and create Vector object
               while (resultQuery.next())
                  GenPageMySQL PageObj = new GenPageMySQL();
                  PageObj.setId(resultQuery.getInt("id"));
                  PageObj.setTheme(resultQuery.getString("theme"));
                  PageObj.setPage(resultQuery.getString("page"));
                  VectorPageObj.add(PageObj); //add obj in tail vector
           catch (SQLException e) {
             e.printStackTrace();
        *@set the CurrentConnect
        public void setConnection(Connection CurrentConnectBase) {
             CurrentConnect = CurrentConnectBase;
        *@get Vector object "Vector created after execute query"
         public Vector getVectorPageObj(Connection CurrentConnectBase) {
             return VectorPageObj;
    }start Servlet class:
    import java.util.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import MySQL.*;
    public class indexServlet extends HttpServlet {
        private  String getpage;
        //Connected MySQL
        private MySQLConnect MySQLConnectObj = new MySQLConnect();
        private MySQLQuery MySQLQueryObj = new MySQLQuery();
        public void init(){
              MySQLConnectObj.DownloadDriver();
              MySQLConnectObj.Connected();
              //Use current connection, for execution query
              MySQLQueryObj.setConnection(MySQLConnectObj.GetConnection());
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException, NullPointerException  {
      //      init();
            PrintWriter out = response.getWriter();
    //GET case useer
          getpage = request.getParameter("page");
          out.print("MySQLConnectObj.GetConnection() = "+MySQLConnectObj.GetConnection()); 
    //Check curent connect to database
          if(MySQLConnectObj.GetConnection() != null)
               MySQLQueryObj.SelectAllField("up_menu");//execution query
               MySQLConnectObj.DisConnected();
                request.setAttribute("up_menu_theme",MySQLQueryObj.getVectorPageObj(null));
                RequestDispatcher Dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/jsp/index.jsp");
                Dispatcher.forward(request, response);
          else if(MySQLConnectObj.GetConnection() == null){
                init() ;
            out.print("MySQLConnectObj.GetConnection() = "+MySQLConnectObj.GetConnection());
    //        MySQLConnectObj.DisConnected();
    }I forward Vector "MySQLQueryObj.getVectorPageObj(null)" to JSP, how I can print data vector using JSTL?

    your right, I learn Java however this very Interesting!
    I change code, change Vector on List
    class MySQLQyery:
    package MySQL;
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    import java.util.*;
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    * @author initmax
    public class MySQLQuery {
        private Connection CurrentConnect; //obj for connect to databae
    public MySQLQuery() {}
    //constructor accept current conection database
    public MySQLQuery(Connection CurrentConnectBase) {
        CurrentConnect = CurrentConnectBase;
    //method accept name table and link on List, after work return all info on this table inside List
    public List<GenPageMySQL> selectAllField(String NameTable, List<GenPageMySQL> ListPageObj) {
           try {
             Statement st = CurrentConnect.createStatement();
             String query = ("select * from "+NameTable);
             ResultSet resultQuery = null;
             resultQuery = st.executeQuery(query);
    //step in cycle after execution query, and create Vector object
               while (resultQuery.next()) {
                  GenPageMySQL PageObj = new GenPageMySQL();
                  PageObj.setId(resultQuery.getInt("id"));
                  PageObj.setTheme(resultQuery.getString("theme"));
                  PageObj.setPage(resultQuery.getString("page"));
                  ListPageObj.add(PageObj); //add obj in tail vector
           catch (SQLException e) {
             e.printStackTrace();
           return ListPageObj;
        *@set the CurrentConnect
        public void setConnection(Connection CurrentConnectBase) {
             CurrentConnect = CurrentConnectBase;
      List<GenPageMySQL> ListPageObj;
                //get List<RowObject>
                ListPageObj = MySQLQueryObj.getListPageObj();
      out.print("Size Page objects = "+ListPageObj.size());
                request.setAttribute("upMenu",ListPageObj);
                RequestDispatcher Dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/jsp/index.jsp");
                Dispatcher.forward(request, response);string out.print("Size Page objects = "+ListPageObj.size()); == worked, I get count objects correct
    How I can output fields Object GenPageMySQL in JSTL?
    writing so:
             <c:out value="hello, Max" />
             <c:out value="${10+20/2}" />
             <c:forEach items="${upMenu}" var="Object" >     
                   <c:out value="${Object.getId}"> </c:out>
             </c:forEach>
        </body>
    </html>but get error:
    org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/jsp/index.jsp at line 36
    33:          <c:forEach items="${upMenu}" var="Object" >
    34:         
    35:                 
    36:                <c:out value="${Object.getId}"> </c:out>
    37:
    38:    
    39:          </c:forEach>
    Stacktrace:
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
         indexServlet.doGet(indexServlet.java:49)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:717)How I can in output print fields my Object?
    Thank you for your help.

Maybe you are looking for