Typed Arraylist in a JSP

I need to use a typed ArrayList in a JSP and it doesn't like the less than and greater than characters around the type. Similar to this:
ArrayList<MyType> a = new MyType();How do I format that syntax correctly?

I am running Apache Tomcat 5.5.12 on Win32 and the JAVA_HOME is pointing to the correct JRE (1.5).
If I do not type the ArrayList in the JSP's it will work. However I would like to know why this would work. If I run straight Java code on this system because it is 1.5 I have to type the ArrayList's. One can compile the Java to still work without the typed ArrayList's but I don't want to do that. I wonder if there are any special options Apache uses that negate having to use the typed ArrayList's. Seems strange that would be the case.
As long as this code doesn't start breaking when using future versions I wouldn't have an issue but being that 1.5 without any special options wanted the ArrayList's typed I would have rather been able to just type them.

Similar Messages

  • Pass arraylist from one JSP to another

    Hi all,
    I have a jsp in which i have a table with a list a of users. When we select some users and click on the deactivate link all these user information must be passed to another jsp which is a confirmation page to delete the users.
    In my first userlist jsp i have the code
    <h:commandLink styleClass="bold" value="Deactivate User" action="delete" actionListener="#{userlistcontroller.deleteaction}" ></h:commandLink>faces-config.xml
        <navigation-rule>
        <from-view-id>/userlist.jsp</from-view-id>
        <navigation-case>
          <from-outcome>delete</from-outcome>
          <to-view-id>/deactivateusers.jsp</to-view-id>
        </navigation-case>
      </navigation-rule>In my backing bean action method i populate the list of users that need to be deacivated in an array list
       String userAction;
       List<Integer> selectedUserIDList;
       public void deleteaction(ActionEvent event){
           userAction = "delete";
           selectedUserIDList = new ArrayList<Integer>();
           for (CompanyAdminUser user : userList) {
                 try {
                    boolean val = selectedIds.get(user.getID()).booleanValue();
               if(val){
                    selectedUserIDList.add(user.getID());
                 } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
      }can someone help me how to pass this selectedUserIDList (arraylist ) and the userAction="Delete" to deacviate users jsp.
    Thank you
    Edited by: twisai on Mar 10, 2010 9:02 AM

    You can easily pass the 2 variables you mentioned using <f:param> inside your <h:commandLink>.
    <h:commandLink styleClass="bold" value="Deactivate User" action="delete" actionListener="#{userlistcontroller.deleteaction}" >
    <f:param name="userAction" value="delete" />
    <f:param name="userIDList" value="#{userlistcontroller.selectedUserIDList}" />
    </h:commandLink>

  • How to get an ArrayList Object in servlet from JSP?

    How to get an ArrayList Object in servlet from JSP?
    hi all
    please give the solution for this without using session and application...
    In test1.jsp file
    i am setting values for my setter methods using <jsp:usebean> <jsp:setproperty> tags as shown below.
    After that i am adding the usebean object to array list, then using request.setAttribute("arraylist object")
    ---------Code----------
    <jsp:useBean id="payment" class="com.common.PaymentHandler" scope="request" />
    <jsp:setProperty name="payment" property="strCreditCardNo" param="creditCardNumber" />
    <%-- <jsp:setProperty name="payment" property="iCsc" param="securityCode" /> --%>
    <jsp:setProperty name="payment" property="strDate" param="expirationDate" />
    <jsp:setProperty name="payment" property="strCardType" param="creditCardType" />
    <%--<jsp:setProperty name="payment" property="cDeactivate" param="deactivateBox" />
    <jsp:setProperty name="payment" property="fAmount" param="depositAmt" />
    <jsp:setProperty name="payment" property="fAmount" param="totalAmtDue" /> --%>
    <jsp:useBean id="lis" class="java.util.ArrayList" scope="request">
    <%
    lis.add(payment);
    %>
    </jsp:useBean>
    <%
    request.setAttribute("lis1",lis);
    %>
    -----------Code in JSP-----------------
    In testServlet.java
    i tried to get the arraylist object in servlet using request.getAttribute
    But I unable to get that arrayObject in servlet.....
    So if any one help me out in this, it will be very helpfull to me..
    Thanks in Advance
    Edward

    Hi,
    Im also facing the similar problen
    pls anybody help..
    thax in advance....
    Litty

  • Retrieving data from an ArrayList and presenting them in a JSP

    Dear Fellow Java Developers:
    I am developing a catalogue site that would give the user the option of viewing items on a JSP page. The thing is, a user may request to view a certain item of which there are several varieties, for example "shirts". There may be 20 different varieties, and the catalogue page would present the 20 different shirts on the page. However, I want to give the user the option of either viewing all the shirts on a single page, or view a certain number at a time, and view the other shirts on a second or third JSP page.
    See the following link as an example:
    http://www.eddiebauer.com/eb/cat_default.asp?nv=2|21472|9&tid=&c=&sc=&cm_cg=&lp=n2f
    I am able to retrieve the data from the database, and present all of them on a JSP, however I am not sure how to implement the functionality so that they can be viewed a certain number at a time. So if I want to present say 12 items on a page and the database resultset brings back 30 items, I should be able to present the first 12 items on page1, the next 12 items on page2, and the remaining 6 items on page3. How would I do this? Below is my scriplet code that I use to retrieve information from the ArrayList that I retrieve from my database and present them in their entirety on a single JSP page:
    <table>
    <tr>
    <%String product=request.getParameter("item");
    ArrayList list=aBean.getCatalogueData(product);
    int j=0, n=2;
    for(Iterator i=list.iterator(); i.hasNext(); j++){
    if(j>n){
    out.print("</tr><tr>");
    j=0;
    Integer id=(Integer)i.next();
    String name=(String)i.next();
    String productURL=(String)i.next();
    out.print("a bunch of html with the above variables embedded inside")
    %>
    </tr>
    </table>
    where aBean is an instace of a JavaBean that retrieves the data from the Database.
    I have two ideas, because each iteration of the for loop represents one row from the database, I was thinking of introducing another int variable k that would be used to count all the iterations in the for loop, thus knowing the exact number. Once we had that value, we would then be able to determine if it was greater than or less than or equal to the maximum number of items we wanted to present on the JSP page( in this case 12). Once we had that value would then pass that value along to the next page and the for loop in each subsequent JSP page would continue from where the previous JSP page left off. The other option, would be to create a new ArrayList for each JSP page, where each JSP page would have an ArrayList that held all the items that it would present and that was it. Which approach is best? And more importantly, how would I implement it?
    Just wondering.
    Thanks in advance to all that reply.
    Sincerely;
    Fayyaz

    -You said to pass two parameters in the request,
    "start", and "count". The initial values for "start"
    would be zero, and the inital value for "count" would
    be the number of rows in the resultSet from the
    database, correct?Correct.
    -I am a little fuzzy about the following block of code
    you gave:
    //Set start and count for next page
    start += count; // If less than count left in array, send the number left to next next page
    count = ((start*3)+(count*3) < list.size()) ? (count) : ((list.size() - (start*3))/3)
    Could you explain the above block of code a little
    further please?Okay, first, I was using the ternary operators (boolean) ? val_if_true : val_if_false;
    This works like an if() else ; statement, where the expression before the ? represents the condition of the if statement, the result of the expression directly after the ? is returned if the condition is true, and the expression after the : is returned if the condition is false. These two statments below, one using the ternary ? : operators, and the other an if/else, do the same thing:
    count = ((start*3)+(count*3) < list.size()) ? (count) : ((list.size() - (start*3))/3);
    if ((start*3)+(count*3) < list.size()) count = count;
    else count = ((list.size() - (start*3))/3);Now, why all the multiplying by 3s? Because you store three values in your list for each product, 1) the product ID, 2) the product Name, and 3) the product URL. So to look at the third item, we need to be looking at the 9th,10th, and 11th values in the list.
    So I want to avoid an ArrayIndexOutOfBounds error from occuring if I try to access the List by an index greater than the size of the list. Since I am working with product numbers, and not the number of items stored in the list, I need to multiply by three, both the start and count, to make sure their sum does not exceed the value stored in the list. I test this with ((start*3)+(count*3) < list.size()) ?. It could have been done like: ((start + count) * 3 < list.size()) ?.
    So if this is true, the next page can begin looking through the list at the correct start position and find the number of items we want to display without overstepping the end of the list. So we can leave count the way it is.
    If this is false, then we want to change count so we will only traverse the number of products that are left in the list. To do this, we subtract where the next page is going to start looking in the list (start*3) from the total size of the list, and devide that by 3, to get the number of products left (which will be less then count. To do this, I used: ((list.size() - (start*3))/3), but I could have used: ((list.size()/3) - start).
    Does this explain it enough? I don't think I used the best math in the original post, and the line might be better written as:
    count = ((size + count)*3 < list.size()) ? (count) : ((list.size()/3) - start);All this math would be unnecessary if you made a ProductBean that stored the three values in it.
    >
    - You have the following code snippet:
    //Get the string to display this same JSP, but with new start and count
    String nextDisplayURL = encodeRedirectURL("thispage.jsp?start=" + start + "&count=" + count + "&item=" + product);
    %>
    <a href="<%=nextDisplayURL%>">Next Page</a>
    How would you do a previous page URL? Also, I need to
    place the "previous", "next" and the different page
    number values at the top of the JSP page, as in the
    following url:
    http://www.eddiebauer.com/eb/cat_default.asp?nv=2|21472
    9&tid=&c=&sc=&cm_cg=&lp=n2f
    How do I do this? I figure this might be a problem
    since I am processing the code in the middle of the
    page, and then I need to have these variables right at
    the top. Any suggestions?One way is to make new variable names, 'nextStart', 'previousStart', 'nextCount', 'previousCount'.
    Calculate these at the top, based on start and count, but leave the ints you use for start and count unchanged. You may want to store the count in the session rather than pass it along, if this is the case. Then you just worry about the start, or page number (start would be (page number - 1) * count. This would be better because the count for the last page will be less than the count on other pages, If we put the count in session we will remember that for previous pages...
    I think with the details I provided in this and previous post, you should be able to write the necessary code.
    >
    Thanks once again for all of your help, I really do
    appreciate the time and effort.
    Take care.
    Sincerely;
    Fayyaz

  • Displaying an ArrayList of values in JSP

    Hi ,
    I have a servlet called Submit Servlet that basically gets a EmpID from the request parameter , searches in a LetterRequest Table and sets matching records in an ArrayList of objects
    My probelm is sending this ArrayList to a JSP and displaying all the values in each object in a table .
    I am getting a[b] NullPointerException .Problem is I dont know if its coming from my servlet or my JSP .
    Here is part of the code for my servlet
    private void performTask(HttpServletRequest req, HttpServletResponse resp)
         throws ServletException, IOException
              String EmpID=req.getParameter("txtEmpID");
              if(EmpID.equals("")){
                   //throw a pop up message saying there is an error
              else
                   LetterRequestDAO LtrDAO=new LetterRequestDAO("001");
                   LtrDAO.storeLetter(EmpID);     
                   LetterList=LtrDAO.getLetterList();
                   if(LetterList==null)
                        System.out.println("Your Letter List is null");
                   HttpSession session = req.getSession(true);     
                   req.setAttribute("LTRList", LetterList);
                   session.setAttribute("LtrList",LetterList);
                   RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("LetterRequestJSP.jsp");
                   try
                        dispatcher.forward(req, resp);
                   catch (Exception  e)
                        // TODO Auto-generated catch block
                        System.out.println("In catch block of perform task");
              And this is part of my JSP .
    <%
            session=request.getSession();
           ArrayList LetterList = (ArrayList)session.getAttribute("LtrList");
           for (Iterator iter = LetterList.iterator(); iter.hasNext();)
                        LetterRequestDTO LtrDTO = (LetterRequestDTO) iter.next();     
                         out.println("<tr>");     
                         out.println("<td>" + LtrDTO.getLetterID() + "</td>");
                         out.println("<td>" + LtrDTO.getEmpID() + "</td>");
                     out.println("<td>" + LtrDTO.getAddress1() + "</td>");
                     out.println("<td>" + LtrDTO.getAddress2() + "</td>");
                     out.println("<td>" + LtrDTO.getAddress3() + "</td>");
                     out.println("</tr>");
              %>What am I doing wrong ? Is it something like I cant get values from a class into a JSP or something ??

    Just a simple mistake I believe....
    modify ur Line of Code
    HttpSession session = req.getSession(true);
    as
    HttpSession session = req.getSession(false);
    true variable if u pass...it creates a new session, and it will not bind ur arraylist to the existing session.
    Hope this helps !!

  • How to iterate ArrayList in jsp?

    Hi All,
    This is a strut question. In my BeAction.java I have req.setAttribute("PIMSite",site); where in I set the site object(Its a ArrayList) for my jsp page to display the
    Site attributes. Following is the part of code in jsp that does the attribute display. site being ArrayList may contain 0 or 1 or more than one locations(objects)
    [html]
    <table border="0" cellpadding="0" cellspacing="0" class="appstablecolor" width="100%"> <tr valign="top" align="left"> <td width="100%" > <table border="0" cellspacing="1" cellpadding="3" width="100%" class="modulecontent"> <tr valign="top" align="left"> <td width="40%" bgcolor="#ffffff" ><span class="modulesubhead"><bean:message key="PIMBeGeoinfo.hqaddress" /> </td></span></td> <td width="20%" bgcolor="#ffffff"> <span class="modulesubhead"><bean:message key="PIMBeGeoinfo.countrygroup"/></span> </td> <td width="17%" bgcolor="#ffffff"><span class="modulesubhead"><bean:message key= "PIMBeGeoinfo.hqcam" /></span></td> <td width="23%" bgcolor="#ffffff"><span class="modulesubhead"><bean:message key= "PIMBeGeoinfo.partneradmin" /></span></td> </tr> <tr valign="top" align="left"> <td width="40%" bgcolor="#ffffff" ><bean:write name="PIMSite" property="headQuarter"/><br> <bean:write name="PIMSite" property="siteAddress1"/> <bean:write name="PIMSite" property="siteAddress1"/> <bean:write name="PIMSite" property="siteAddress1"/> <br> <bean:write name="PIMSite" property="siteCity"/> <bean:write name="PIMSite" property="siteState"/>, <bean:write name="PIMSite" property="siteZipCode"/><br> <bean:write name="PIMSite" property="sitePhone"/></td> <td width="20%" bgcolor="#ffffff"> <bean:write name="PIMSite" property="siteCountry"/></td> <td width="17%" bgcolor="#ffffff"><bean:write name="PIMSite" property="channelAcctMgr"/></td> <td rowspan="2" bgcolor="#ffffff" width="23%">Lisa Simpson<br> Peter Parker</td> </tr> </table> </td> </tr> </table>
    [html]
    My question is PIMSite being a ArrayList may have multiple of site objects in it. Here I have displayed only one site object by passing a location object. Actually, I would be passing a ArrayList with multiple site objects in it for me to display in jsp page. But, if they are multiple site objects in ArrayList
    how can I display in above jsp/html code.
    My question is how do I iterate the ArrayList and then display multiple html hierarchy in case of multiple site locations present in ArrayList??
    thanks,
    pp

    Use h:dataTable.
    Also see http://balusc.xs4all.nl/srv/dev-jep-dat.html

  • How to send object arraylist from servlet to jsp and display using jstl

    Hi All....
    I have a simple application and problem with it.
    Once user logged in to system the user will redirect to LoginServlet.java controller.
    Then in LoginServlet I want to redirect user to another page called book_details.jsp.
    this is my login servlet.
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              // TODO Auto-generated method stub
              PrintWriter out = response.getWriter();
              ArrayList<BankAccountDTO> account_list = new ArrayList();
              ResultSet resultSet = null;
              LowFairAirDB airDB = null;
              try{
                   airDB = new LowFairAirDB();
                   String query = "SELECT account_id, type, description, balance, credit_line, begin_balance, begin_balance_time_stamp FROM bank_account";
                   airDB.sqlSelect(query);
                   resultSet = airDB.getResultSet();
                   while(resultSet.next()){
                        account_list.add(new BankAccountDTO(resultSet.getInt(1),
                                                                     resultSet.getInt(4),
                                                                     resultSet.getInt(5),
                                                                     resultSet.getInt(6),
                                                                     resultSet.getString(2),
                                                                     resultSet.getString(3),
                                                                     resultSet.getString(7)));
              }catch(Exception ex){
              }finally{
                   try{resultSet.close();}catch(Exception ex){}
                   airDB.sqlClose();
         }I set bank account values to BankAccountDTO.java objects and add them to the arrayList.
    Next I want to send this objects arrayList to books_details.jsp and wanna display each objects values using JSTL.
    I still finding a way to go through this.
    1. Can anyone say how can I do it?
    2. Is there any other method to do the same thing without using JSTL?
    thanks in advance,
    Dil.

    Naishe wrote:
    In your servlet,
    request.setAttribute("account_list", account_list);
    requestDispatcher.findForward("/your/display/jsp");
    Good. I would only follow the Java naming conventions. E.g. accountList or accounts instead of the ugly PHP/C conventions.
    In the JSP,
    lst = (List< BankAccountDTO >)request.setAttribute("account_list");
    for(BankAccountDTO b: lst){
    populate your HTML tags or whatever
    Wrong. 1) You need getAttribute() and 2) you should not use scriptlets. Use JSTL c:forEach, e.g.<table>
        <c:forEach items="${accounts}" var="account">
            <tr>
                <td>${account.id}</td>
                <td>${account.type}</td>
                <td>${account.description}</td>
            </tr>
        </c:forEach>
    </table>To the topicstarter: for future JSP/JSTL related questions please use JSP/JSTL forum.
    Here it is: [http://forums.sun.com/forum.jspa?forumID=45].

  • Pass ArrayList to jsp and display first index of resultset?

    Is it possible for me to pass an ArrayList to a jsp, and display the each resultset stored in the ArrayList by the ArrayList index?
    The code below gets passed two paramaters. An invorg, and item. It then creates resultset based upon the Object and puts the results into an ArrayList.
    The resultset returned varies, but the largest resultset that I have received back has not been bigger thatn 10 resultset rows, and the largest number of columns has been 27 columns.
    I would then like to pass the whole ArrayList to the jsp and display the contents for each row based on the index it is on.
    Is this possible?
    public class RunReportAction extends MTDAction
        ArrayList results;   
        public RunReportAction()
        public boolean execute(HttpServletRequest _req, HttpServletResponse _res) throws ServletException, IOException
            String item = _req.getParameter("itemsToAdd");
            String invorg = _req.getParameter("invorg");
            try
                if (rep_type.equals("Vendor"))
                    runVendorReport(item, invorg);
                else if (rep_type.equals("Purchase Order"))
                    runPOReport(item, invorg);
                else if (rep_type.equals("Inventory"))
                    runInventoryReport(item, invorg);
                else if (rep_type.equals("Item Usage"))
                    runWhereUsedReport(item, invorg);
                else if (rep_type.equals("Cost/Purchasing"))
                    runCostReport(item, invorg);
                else if (rep_type.equals("Planning"))
                    runPlanningReport(item, invorg);
            catch (Exception e)
                setView("SSMErrorPage.jsp");
                model = e;
            model = results;
            view = "SSM_Reports";
            return true;
        boolean runInventoryReport(String item, String invorg) throws MTDException
            try
                CallableStatement cs = conn.prepareCall("{call CTI_SSM_PKG.get_inventory_report(?,?,?)}");
                cs.registerOutParameter(3, OracleTypes.CURSOR);
                cs.setObject(2, item, Types.VARCHAR);
                cs.setObject(1, invorg, Types.VARCHAR);
                cs.execute();
                ResultSet rs = (ResultSet)cs.getObject(3);
                while (rs.next())
                    InventoryObj inventory = new InventoryObj();
                    inventory.setInvOrg(rs.getString(1));
                    inventory.setItem(rs.getString(2));
                    inventory.setItemDescription(rs.getString(3));
                    inventory.setInvFlag(rs.getString(4));
                    inventory.setStockEnabled(rs.getString(5));
                    inventory.setTransactable(rs.getString(6));
                    inventory.setRevQtyControl(rs.getString(7));
                    inventory.setReservable(rs.getString(8));
                    inventory.setCheckShortage(rs.getString(9));
                    inventory.setLotControl(rs.getString(10));
                    inventory.setShelfLife(rs.getString(11));
                    inventory.setLotStartPrefix(rs.getString(12));
                    inventory.setLotStartNumber(rs.getString(13));
                    inventory.setLotCycleCount(rs.getString(14));
                    inventory.setPosMeasureError(rs.getString(15));
                    inventory.setNegMeasureError(rs.getString(16));
                    inventory.setSerialGeneration(rs.getString(17));
                    inventory.setSerialNumbStart(rs.getString(18));
                    inventory.setSerialPrefixStart(rs.getString(19));
                    inventory.setLotStatus(rs.getString(20));
                    inventory.setSerialStatus(rs.getString(21));
                    inventory.setLotSplit(rs.getString(22));
                    inventory.setLotMerge(rs.getString(23));
                    inventory.setLocatorControl(rs.getString(24));
                    inventory.setToday(rs.getString(25));               
                    results.add(inventory); 
                    System.out.println(results);
            catch (SQLException e)
                throw (new MTDException("Failed to run report in database.", e));
            //model = results;
            //setView("SSM_Reports.jsp");
            return true;
    }jsp code:<%@ page import="java.util.*"%>
    <%@ page import="ssmmtd2.InventoryObj"%>
    <html>
    <head>
    <title> SSM 2 Inventory Report </title>
    <style>
              A {text-decoration:none;color:black;}
              A:Hover {color:Blue}
    </style>
    </head>
    <%
      ArrayList inventory;
      if (request.getAttribute("model") != null)
        if ((request.getAttribute("model").getClass().getName()).equals("java.util.ArrayList"))
          inventory = (ArrayList)request.getAttribute("model");     
          if (inventory != null && inventory.size() > 0)
          %>
        <body  bgcolor="#FFFFFF">
          <table border = "1" width="755" cellpadding="0" cellspacing = "0">
          <tr>
            <td colspan="3" width="755" align="center">
              <p align="center"><big><b><font color="#000080">Inventory Report</font></b></big>
            </td>
          </tr>
          </table>
          <table border="1" width="755">
            <tr>
              <td width="100%">
                <form>
                  <table>
                <%
                  Iterator i = inventory.iterator();
                  while (i.hasNext())
                    InventoryObj invObj = (InventoryObj)i.next();
                %>
                  <TR>
                    <TD><B>ITEM:</B>
                      <align="left" valign="center"><%=invObj.getItem()%>
                    <td><B>DESCRIPTION:</B>
                      <align="left" valign="center"><%=invObj.getItemDescription()%>
                  <TR>
                  </TR>
                  <TR>
                  </TR>
                  <TR>
                  </TR>
                    <td><B>ORGANIZATION:</B>
                      <align="left" valign="center"><%=invObj.getInvOrg()%>
                    </TD>
                    <TD>
                      <B>CURRENT DATE:</B>
                        <align="left" valign="center"><%=invObj.getToday()%></TD>
                    </TR>
                    <TR>
                    <TR>
                    <TR>
                    <TR>
                    <TR>
                    <TR>
                    <TR>
                    <TR>
                    <TR>
                    <TR>
                    <TR>
                    <TR>
                    <TR>
                      <TD><B>INVENTORY ITEM</B>
                      <TD align="left" valign="center"><b>:</B>  <%=invObj.getInvFlag()%>
                      </TD>
                    </TR>
                    <TR>
                      <TD><B>STOCK ENABLED</B>
                      <TD align="left" valign="center"><b>:</B>  <%=invObj.getStockEnabled()%>
                      </TD>
                    </TR>
                    <TR>
                      <TD><B>TRANSACTABLE</B>
                      <TD align="left" valign="center"><b>:</B>  <%=invObj.getTransactable()%>
                      </TD>
                    </TR>
                    <TR>
                      <TD><B>REVISION QTY CONTROL</B>
                      <TD align="left" valign="center"><b>:</B>  <%=invObj.getRevQtyControl()%>
                      </TD>
                    </TR>
                    <TR>
                      <TD><B>RESERVABLE TYPE</B>
                      <TD align="left" valign="center"><b>:</B>  <%=invObj.getReservable()%>
                      </TD>
                    </TR>
                    <TR>
                      <TD><B>CHECK SHORTAGES</B>
                      <TD align="left" valign="center"><b>:</B>  <%=invObj.getCheckShortage()%>
                      </TD>
                    </TR>
                    <TR>
                      <TD><B>LOT CONTROL</B>
                      <TD align="left" valign="center"><b>:</B>  <%=invObj.getLotControl()%>
                      </TD>
                    </TR>
                    <TR>
                      <TD><B>SHELF LIFE DAYS</B>
                      <TD align="left" valign="center"><b>:</B>  <%=invObj.getShelfLife()%>
                      </TD>
                    </TR>
                    <TR>
                      <TD><B>STARTING LOT PREFIX</B>
                      <TD align="left" valign="center"><b>:</B>  <%=invObj.getLotStartPrefix()%>
                      </TD>
                    </TR>
                    <TR>
                      <TD><B>STARTING LOT NUMBER</B>
                      <TD align="left" valign="center"><b>:</B>  <%=invObj.getLotStartNumber()%>
                      </TD>
                    </TR>
                    <TR>
                      <TD><B>CYCLE COUNT</B>
                      <TD align="left" valign="center"><b>:</B>  <%=invObj.getLotCycleCount()%>
                      </TD>
                    </TR>
                    <TR>
                      <TD><B>POSITIVE MEASUREMENT ERROR</B>
                      <TD align="left" valign="center"><b>:</B>  <%=invObj.getPosMeasureError()%>
                      </TD>
                    </TR>
                    <TR>
                      <TD><B>NEGATIVE MEASUREMENT ERROR</B>
                      <TD align="left" valign="center"><b>:</B>  <%=invObj.getNegMeasureError()%>
                      </TD>
                    </TR>
                    <TR>
                      <TD><B>SERIAL GENERATION</B>
                      <TD align="left" valign="center"><b>:</B>  <%=invObj.getSerialGeneration()%>
                      </TD>
                    </TR>
                    <TR>
                      <TD><B>STARTING SERIAL NUMBER</B>
                      <TD align="left" valign="center"><b>:</B>  <%=invObj.getSerialNumbStart()%>
                      </TD>
                    </TR>
                    <TR>
                      <TD><B>STARTING SERIAL PREFIX</B>
                      <TD align="left" valign="center"><b>:</B>  <%=invObj.getSerialPrefixStart()%>
                      </TD>
                    </TR>
                    <TR>
                      <TD><B>LOT STATUS</B>
                      <TD align="left" valign="center"><b>:</B>  <%=invObj.getLotStatus()%>
                      </TD>
                    </TR>
                    <TR>
                      <TD><B>SERIAL STATUS</B>
                      <TD align="left" valign="center"><b>:</B>  <%=invObj.getSerialStatus()%>
                      </TD>
                    </TR>
                    <TR>
                      <TD><B>LOT SPLIT</B>
                      <TD align="left" valign="center"><b>:</B>  <%=invObj.getLotSplit()%>
                      </TD></TR>
                    <TR>
                      <TD><B>LOT MERGE</B>
                      <TD align="left" valign="center"><b>:</B>  <%=invObj.getLotMerge()%>
                      </TD>
                    </TR>
                    <TR>
                      <TD><B>LOCATOR CONTROL</B>
                      <TD align="left" valign="center"><b>:</B>  <%=invObj.getLocatorControl()%>
                      </TD>
                    </TR>
                <%} %>
                  </table>
                <input type="hidden" name="SearchValue">
                <BR>
                <img src="images/close11.bmp" style="cuinvObjor:hand" onmouseover='this.src="images/close12.bmp"' onmouseout='this.src="images/close11.bmp"' onClick="window.close()">     
                <img src="images/print1.bmp" style="cuinvObjor:hand" onmouseover='this.src="images/print2.bmp"' onmouseout='this.src="images/print1.bmp"' onClick='this.src="images/print3.bmp"; window.print()' >
                </form>
              </td>
            </tr>
          </table>
        </body>
    <%
    %>
    </html>

    Your arraylist object should be a list of inventory bean objects and then, If you are using struts, you could use logic:iterate tags.. or something equivalent.. you could use forEach in jstl..

  • A jsp page for searching employees

    this jsp page is used for searching employees and displaying the search results.
    when the submit button is clicked, the http request will be sent to a servlet java class.
    <%@ page contentType="text/html" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <html>
    <head>
    <title>SEARCH STAFF</title>
    </head>
    <body>
    <p align="center"><font color="#008000">SEARCH STAFF</font></p>
    <FORM METHOD=POST ACTION="/servlet/ReqHandler?action=searchstaffget">
    <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
        <tr>
        <td width="50%">Staff ID:</td>
        <td width="50%"><INPUT NAME=staffid SIZE=15></td>
      </tr>
      <tr>
        <td width="50%">First Name:</td>
        <td width="50%"><INPUT NAME=firstname SIZE=30></td>
      </tr>
        <tr>
        <td width="50%">Last Name:</td>
        <td width="50%"><INPUT NAME=lastname SIZE=30></td>
      </tr>
      <tr>
        <td width="50%">Gender:</td>
        <td width="50%"><select size="1" name="sex">
        <option value="m" selected>Male</option>
        <option value="f">Female</option>
        </select></td>
      </tr>
       <tr>
        <td width="50%">E-mail:</td>
        <td width="50%"><INPUT NAME=email SIZE=30></td>
      </tr>
      <tr>
        <td width="50%">Birth date:</td>
        <td width="50%"><INPUT NAME=birthdate SIZE=10></td>
      </tr>
      <tr>
        <td width="50%">Address:</td>
        <td width="50%"><input type="text" name="addr" size="30"></td>
      </tr>
      <tr>
        <td width="50%">Phone number (Home):</td>
        <td width="50%">
    <input type="text" name="phoneno" size="8"></td>
      </tr>
      <tr>
        <td width="50%">Phone number (Mobile):</td>
        <td width="50%">
       <input type="text" name="mobileno" size="8"></td>
      </tr>
      <tr>
        <td width="50%">ID card number:</td>
        <td width="50%"><input type="text" name="idno" size="8"></td>
      </tr>
        <tr>
          <td width="50%">Position:</td>
          <td width="50%"><select size="1" name="position">
        <option value="deliveryman" selected>Deliveryman</option>
        <option value="normalstf">Normal Staff</option>
        </select></td>
      </tr>
    </table>
    <P align="center">
    <INPUT TYPE=SUBMIT></FORM>
    <!--
    I WANT THE SEARCH RESULTS TO BE DISPLAYED HERE IN THIS JSP PAGE.
    THIS MEANS THAT, AFTER THE SUBMIT BUTTON IS CLICKED, THE FORM ABOVE WILL NOT DISAPPEAR AND THE SEARCH RESULTS WILL DISPLAY BELOW THE FORM.
    --> the java servlet class will then forward the search parameters(last name, first name....etc.) to a database accessor class and this class will then return an arraylist of all the columns for each row in the database that match the search criteria. Each column of a row is stored as a String object in the arraylist.
    what i would like to ask is, what codes should i use in the servlet class, and what codes should i use in the jsp page, in order that, the search results will finally display in <TABLE> format.
    please help, thanks a lot~~~~~~~~

    put the search results in session in your servlet
    using
    request.getSession().setAttribute("SEARCH_RESULT_SESSI
    ON", searchResult);
    where searchResult is your arrayList.
    in your JSP page:
    <c:set var="SEARCH_RESULT"
    value="<%=SEARCH_RESULT_SESSION%>"/>
    <c:set var="searchResult"
    value="${sessionScope.SEARCH_RESULT}"
    scope="request"/>
    and use this searchResult to display your results in
    whatever format you want.
    <c:forEach var="result" items="searchResult">
         <c:out value="${result}"/>
         result is the string that you stored in arrayList.
    </c:forEach>
    Questions, let me know.thanks but.....
    this doesn't work for me, i placed this statement in my java servlet class:
    request.getSession().setAttribute("SEARCH_RESULT_SESSION", searchResult);and i placed the other statements in the JSP page like this:
    <%@ page contentType="text/html" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <%@ page isELIgnored="false" %>
    <%@ page import="java.util.ArrayList" %>
    <html>
    <head>
    <title>SEARCH STAFF</title>
    </head>
    <body>
    <p align="center"><font color="#008000">SEARCH STAFF</font></p>
    <FORM METHOD=POST ACTION="/servlet/ReqHandler?action=searchstaffget">
    <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
    <tr>
    <td width="50%">Staff ID:</td>
    <td width="50%"><INPUT NAME=staffid SIZE=15></td>
    </tr>
    <tr>
    <td width="50%">First Name:</td>
    <td width="50%"><INPUT NAME=firstname SIZE=30></td>
    </tr>
    <tr>
    <td width="50%">Last Name:</td>
    <td width="50%"><INPUT NAME=lastname SIZE=30></td>
    </tr>
    <tr>
    <td width="50%">Gender:</td>
    <td width="50%"><select size="1" name="sex">
    <option value="m" selected>Male</option>
    <option value="f">Female</option>
    </select></td>
    </tr>
    <tr>
    <td width="50%">E-mail:</td>
    <td width="50%"><INPUT NAME=email SIZE=30></td>
    </tr>
    <tr>
    <td width="50%">Birth date:</td>
    <td width="50%"><INPUT NAME=birthdate SIZE=10></td>
    </tr>
    <tr>
    <td width="50%">Address:</td>
    <td width="50%"><input type="text" name="addr" size="30"></td>
    </tr>
    <tr>
    <td width="50%">Phone number (Home):</td>
    <td width="50%">
    <input type="text" name="phoneno" size="8"></td>
    </tr>
    <tr>
    <td width="50%">Phone number (Mobile):</td>
    <td width="50%">
    <input type="text" name="mobileno" size="8"></td>
    </tr>
    <tr>
    <td width="50%">ID card number:</td>
    <td width="50%"><input type="text" name="idno" size="8"></td>
    </tr>
    <tr>
    <td width="50%">Position:</td>
    <td width="50%"><select size="1" name="position">
    <option value="deliveryman" selected>Deliveryman</option>
    <option value="normalstf">Normal Staff</option>
    </select></td>
    </tr>
    </table>
    <P align="center">
    <INPUT TYPE=SUBMIT></FORM>
    <c:set var="SEARCH_RESULT" value="<%=SEARCH_RESULT_SESSION%>"/>
    <c:set var="searchResults" value="${sessionScope.SEARCH_RESULT}" scope="request"/>
    <c:forEach begin="1" end="3" var="result" items="searchResults">
    <c:out value="${result}"/>
    </c:forEach>
    </body>
    </html>
    i typed some data in the text fields and clicked "submit" button
    but it turned into a blank page
    i was sure the arraylist contained the search results because i tried to write them into the stdout.log file.
    could you please tell me why it's like this?

  • Check for null and empty - Arraylist

    Hello all,
    Can anyone tell me the best procedure to check for null and empty for an arraylist in a jsp using JSTL. I'm trying something like this;
    <c:if test="${!empty sampleList}">
    </c:if>
    Help is greatly appreciated.
    Thanks,
    Greeshma...

    A null check might not be you best option.  If your requirement is you must have both the date and time component supplied in order to populate EventDate, then I would use a Script Functoid that takes data and time as parameters.
    In the C# method, first check if either is an empty string, if so return an empty string.
    If not, TryParse the data, if successful, return a valid data string for EventDate.  If not, error or return empty string, whichever satsifies the requirement.

  • A bunch of ArrayLists

    Overview
    My program needs to store 11 different types of data (numbered 1 through 12, skipping 5, although I may find a way to fill this gap soon). Each type of data needs to have a bunch of entries of undeterminate size (ArrayList), but I know there will always be 11 different types of data. I figured instead of having 11 different ArrayList variables and 11 getters, 11 setters, and 11 removers, I could just store them all in an array of some sort, and then only have 1 getter/setter/remover/etc which takes an argument of what data type it is.
    Problem
    Problem is, I'm not exactly sure what to use to group these ArrayLists together. I tried an array, but it complains about the generic typing:
    ArrayList<Resource> resList[] = new ArrayList<Resource>[13]();
    or any combination/order of [13] and () and it always complains "Cannot create a generic array of ArrayList<Resource> or "Cannot convert from ArrayList<Resource> to ArrayList<Resource>[]"
    Solution
    Using basic google skills, I discovered I could use:
    ArrayList resList[] = new ArrayList[12];
    essentially just dropping the type...
    and then loop through the 13 new ArrayList<Resource>();
    Resulting Problem
    Then when I go to add one of the datatypes to its respective data type ArrayList
    resList[Resource.PATH].add(new Path());
    it warns me: "...Type Safety... raw type ArrayList... should be Parameterized"
    it also says the same thing, somewhat surprisingly, when I generalize the path data type back down to Resource:
    resList[Resource.PATH].add((Resource)new Path());
    since I did declare each arraylist of type <Resource>. Yet it makes the same complaint.
    Conclusion
    There's basically 4 possible outcomes to this that I can think up.
    1) (Mostly desirable) There is a solution to my Type Safety warning.
    2) (Undesirable) use @SuppressWarnings
    3) An alternative to bunching them in arrays (I had a glance at Arrays.asList, but wasn't so sure about it)
    4) (Undesirable) just leave them as 11 different ArrayList variables and make them public.
    Thanks in advance,
    -IsmAvatar

    @musicalscale, thanks, I think. Is this just creating
    an ArrayList of ArrayLists? Because I don't think
    that's appropriate here because the 11 data types are
    unchanging (until I fill in the gap at 5, in which
    case it's simply a matter of slight recoding which
    I'm more than happy to do).Yes, it's an ArrayList of ArrayLists. It will get rid of the generics warnings. If you don't plan on changing the size of the outer ArrayList, then you don't have to change it. Only your one class that keeps the private ArrayList of ArrayLists will have direct access to the outer list (unless you code it otherwise). So, you don't have to worry that someone else will mess up the list.
    Or, after you create the initial list of lists, store the private reference as an unmodifiable List:
    private final List< List < Resource > > resList;// In your constructor (or another method):
    // create tempResList with generics as described,
    // then set the instance variable as
    resList = Collections.unmodifiableList(tempResList);Then even your local class can't add or remove things from the outer list (they can still modify the inner lists).
    As for HashMap, I guess it doesn't matter that the
    order may change, since we have the key paired with
    it. But is HashMap also dynamically resizable? Maybe
    I'm just blind to the internal workings.Yes, a HashMap is dynamically resizable. Since you have a key, yes, the order doesn't matter (there is also a TreeMap that keeps the keys sorted, but you don't really need that for your stated purposes). You can make an unmodifiable Map similar to how you make an unmodifiable List.

  • ListIterator not working in JSP page

    Hello,
    I am using an ArrayList in a JSP as follows:
    <%
    ArrayList missingFieldsArr = (ArrayList) HeaderBean.getMissingFieldsArr();
    ListIterator i = (ListIterator)missingFieldsArr.listIterator();
    %>
    <hbj:scrollContainer
      id="scrContError"
      width="320"
      height="50"
    >
      <table width="60%">
      <% while(i.hasNext()) {
        String str = (String) i.next();
      %>
        <tr>
          <td width="100%"> 
            <hbj:textView
           id="txtErrorLst"
           wrapping="true"
           text="<%=str%>"
         />     
         </td>
       </tr>     
      <% } %>
      </table>
    </hbj:scrollContainer>
    Iterating through the ArrayList works when I test via portalapp.xml in NDS, but it does not when I test via the iview in the Portal.  The error I'm receiving is:
    Portal Runtime Error
    An exception occurred while processing a request for :
    iView : pcd:portal_content/com.nbcuni.sc_portal_Content/com.nbcuni.Roles/com.nbcuni.SAP_SC_Testing_Pre-Bom/com.nbcuni.product_information_prebom_ws/com.nbcuni.pre_bom_pg/com.nbcuni.pre_bom
    Component Name : PBS.Inbox
    The exception was logged. Inform your system administrator..
    Exception id: 06:37_30/12/05_0106_4554750
    See the details for the exception ID in the log file
    Any thoughts? 
    Thanks for your help,
    -Jamie

    Hi Jamie,
    for what reason do you think it's the list iterator? All you know from the info you have passed through to us, that it is your component...
    > Exception id: 06:37_30/12/05_0106_4554750
    > See the details for the exception ID in the log file
    ==> Please submit the detailed exception / message / stacktrace from the default.X.trc file.
    Best regards
    Detlev

  • Looping through javabean array in jsp?

    Hello,
    In my servlet, I created an ArrayList of objects and pass these to a jsp page using:
    req.setAttribute("bean", uploadList);
    The ArrayList contains objects of the FileBean class, with a getIndex, and getDate methods.
    Could any possibly demonstrate how to loop through the ArrayList in the jsp and display the FileBean object values in a html table?
    To display the values of a javabean in jsp pages I normally have to use for example, requestScope.bean.getMethod();
    Thanks

    No, that would be requestScope.bean.attributename, if your getter method has the same name as the attribute you are getting.
    To loop through an array you have to use the c:forEach tag. Check google for "jstl foreach example", there are loads of examples.

  • Help with JSP and Servlets

    Hi,
    How would I create an editable JSP form from JDBC?
    I know how to retrieve the data from JDBC, but I'm still trying to figure out how to take that table data and format it into a tabluar format that user can make changes to it.
    Thanks,
    Tom
    Message was edited by:
    bztom_33
    Message was edited by:
    bztom_33

    CreateConnection();
    logger.info("Database connection opened in Testimonials");
    String queryText = "LOCK TABLE testimonials WRITE,posting_table WRITE";
    int numOfRows = st.executeUpdate(queryText);
    rs = st.executeQuery(SELECT_QUERY_FROM_TESTIMONIALS);
    logger.info("Query executed postingVeiw");
    String queryText1 = "UNLOCK TABLES";
    int numOfRow = st.executeUpdate(queryText1);
    while(rs.next())
    ClientData client = new ClientData();
    client.setName(rs.getString("name"));
    client.setTestimonial(rs.getString("testimonial"));
    client.setCompany(rs.getString("company"));
    clientList.add(client);
    RequestDispatcher disp = null;
    req.setAttribute("clientlist", clientList);
    String error1 = req.getParameter("");
    disp = req.getRequestDispatcher("testimonial.jsp");
    disp.forward(req,res);
    And call this arraylist from the jsp page
    Cheers
    Varun Rathore

  • Dynamically refresing my jsp page

    Hello friends,
    I have a problem."Suppose there is a jsp page client.jsp who has two fields :a textarea and another is a. text . I have another servlet. When i press my submit button from jsp the value in the text will go to servlet and it will be shown in the textarea. "My requirement is suppose two persons access the same jsp page .If one person clicks the submit button he as well as the other person should see the same value of the text in their textarea." How can i forward from servelt so that it will dynamically show the fress containt in the textarea.
    Chandan Kumar Mohanty

    When you are using text box and text area then each page aact independently as for every request the server creates threads.So i think this text area problem is hard to implement because how can the second jsp page know that some other jsp has been modified ?
    But what type of application is this which has this kind of requirement ?
    One option is that you put server side push after certain interval but because of that the person typing something in the jsp willl get refreshed so ......

Maybe you are looking for

  • SLOW MACPRO

    Problem description: MACPRO slowing down Hi My MACPRO (half 2010) 2 x 2,4 GHz Quad-Core Intel Xeon 14 GB 1066 MHz DDR3 ECC is running very slow on Yosemite, but on Mavericks was the same. Can You help me please? EtreCheck version: 2.0.11 (98) Report

  • How to use autologin for subscribers with Unity

    How to set up autologin with Unity. When pressing a button you should be logged in to your mailbox with password.

  • PHP/MySQL Record Insert question

    I am working with which PHP 4.4.2, MySQL Server 5.0 running on Apache 2.0.55, and I am developing my web-site with Dreamweaver 8. All of which is running locally on my machine. I am working on a real-estate website that allows landlords around my loc

  • Extremely Poor Volume Level

    Hi Guys, My iphone's barely 3 months old and what I'm facing is poor audio levels out of my apple headphones which louder on my iPod and significantly louder on my Mac... I don't hear a thing if the volume level on my iPhone is somewhere in the middl

  • Re: Forte Environment on OpenVMS Cluster - doubling up forno reason?

    Hi, I tested Forte on OpenVMS more than one year ago. So, it's only what I remember and it was on Forte R2. Normally, it should work exactly as you described if you have one TCP alias for the two nodes. The test I made (one year ago) prouved that For