Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Java Enterprise Edition (JEE)

  1. #1
    Junior Member
    Join Date
    Aug 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb Java Enterprise Edition (JEE)

    I don't know what is wrong with this codes that there is no error indication in the Netbeans Environment, yet the purpose for which they are coded is not being achieved. These codes are supposed to have display data form the database (View methods) all at once. The table name is:admin. And when the program is run, the table in which the data has to be displayed together with the submit button do not appear in the browser. The codes are divided into two: the one from the Session Bean and the other from the JSP page as shown below. I will be grateful if anybody has an idea of where the error is from.

    1. Session Bean:
    //className= viewAllAdmin
    public ArrayList viewAllAdmin() {
    ArrayList arr= null;
    AdminLocal al= null;
    //collection mthd inserted under AdminLocalHome
    Collection col= null;
    try{
    col=alh.findByAll();
    Iterator it= col.iterator();
    while (it.hasNext())
    al= (AdminLocal) it.next();
    arr.add(new NewHelper (al.getAddressBureau(), al.getBureau(), al.getCity(),
    al.getId(), al.getPassword(), al.getRank(), al.getRole() ));
    }catch(Exception e){}
    return new ArrayList ();
    }

    2. JSP page:
    <%
    NewSessionLocal nsl= null;
    NewHelper nh=null; //helper class
    %>
    <%
    //calling the servlet:
    try {
    Context c = new InitialContext();
    NewSessionLocalHome rv = (NewSessionLocalHome) c.lookup("java:comp/env/NewSessionBean");
    nsl= rv.create();
    } catch (NamingException ne) {}
    %>
    <%
    try{
    if(request.getParameter("submit") != null ) {
    ArrayList ll=nsl.viewAllAdmin();
    if(!ll.isEmpty()){
    Iterator it=ll.iterator();
    while(it.hasNext()){
    nh=(NewHelper) it.next();

    %>
    //table:admin

    <tr>
    <th width="8%" scope="col">id</th>
    <th width="24%" scope="col">password</th>
    <th width="18%" scope="col">role</th>
    <th width="17%" scope="col">rank</th>
    <th width="21%" scope="col">bureau</th>
    <th width="6%" scope="col">address</th>
    <th width="6%" scope="col">city</th>
    </tr>
    <tr>
    <td><%=nh.getId()%></td>
    <td><%=nh.getPassword()%></td>
    <td><%= nh.getRole()%></td>
    <td><%=nh.getRank()%></td>
    <td><%= nh.getBureau()%></td>
    <td><%=nh.getAddressB()%></td>
    <td><%= nh.getCity()%></td>
    </tr>
    <tr>
    <td>
    <label>
    <input type="submit" name="submit" id="submit" value="Submit">
    </label></td>
    </tr>


    <%
    }
    }
    }
    }
    catch(Exception e){}
    %>


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Java Enterprise Edition (JEE)

    Thread moved from Whats wrong with my code

    The first obvious issue are the following:
    ....
    catch(Exception e){}
    return new ArrayList ();
    }
    ...
    ....
    catch (NamingException ne) {}
    ...
    ....
    catch(Exception e){}
    ...

    Always catch and deal with exceptions appropriately. At the very least, print or log the stack trace so you can debug the issue

    And for future reference, please wrap all code in the code tags

Similar Threads

  1. Replies: 8
    Last Post: October 3rd, 2012, 11:48 AM
  2. Create Java Enterprise Application with Mobile Client
    By praveensingh18 in forum Java Servlet
    Replies: 2
    Last Post: August 18th, 2012, 06:02 PM
  3. which edition of java ee to learn?
    By rohan22 in forum Web Frameworks
    Replies: 2
    Last Post: February 23rd, 2012, 01:11 AM
  4. Replies: 7
    Last Post: November 23rd, 2010, 11:03 PM