473,385 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Accessing ArrayList to place in table on jsp page

JoeMac3313
I have been flailing widely about trying to get the information from the arrayList to the jsp page to print to a table on the jsp page.

The information on the txt file is

Name:Department:Job Title:Year Hired:Gender


Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. <%@page import="java.io.*"%>
  4.  
  5. <%@ page session="false"%>
  6.  
  7.  
  8.  
  9.  
  10. <html>
  11.  
  12. <head><title>Employees Hired</title></head>
  13. <head><description>Employee Listing</description></head>
  14. <form method="post" action="hiredEmployee.jsp"/> 
  15.  
  16.  
  17. <table border='2' cellspacing='0' cellpadding='4'>
  18.    <tr><th> Name </th><th> Department <th> Job Title </th><th> Year Hired </th><th> Gender </th></tr>
  19.  
  20.  
  21. </html>
  22.  
  23.  
  24.  
  25.  
  26. ////////////////////////////////////////////////////////////////////////////////////////
  27.  
  28. package domain;
  29.  
  30.  import java.util.Scanner;
  31.  import java.io.*;
  32.  import java.util.ArrayList;
  33.  import java.lang.*;
  34.  
  35. public class HiredEmployee {
  36.  
  37.     public ArrayList line = new ArrayList();
  38.     private String temp="";    
  39.     private String[] words; 
  40.     private Scanner sInput = null;
  41.  
  42.  
  43.     public ArrayList<String> getLine(){
  44.  
  45.         words=new String[line.size()];
  46.           try{
  47.                 sInput = new Scanner(new FileReader("hired.txt"));
  48.  
  49.  
  50.                 while (sInput.hasNextLine()){
  51.                     temp=sInput.nextLine();
  52.                     line.add(temp);
  53.                     //words = temp.split(":");
  54.  
  55.                 }
  56.         }
  57.         catch (FileNotFoundException exception) {}
  58.             sInput.close();
  59.              return line;
  60.         }
  61.  
  62. }
  63.  
  64.  
  65.  
  66.  
Any insights woudl be greatly appreciated!

Thanks,
JoeMac
Oct 31 '08 #1
1 8035
itsraghz
127 100+
As per your query on the title, "Accessing ArrayList to place in table on jsp page" the logic goes as follows.
  1. Create an arraylist somewhere - preferably in a Java class
  2. Store the arraylist in one of the available scopes - request, session for eg.,
  3. Access the arraylist object from the scope in JSP page
  4. Iterate the array list inside the <tr> tags of your JSP page using the scriptlets <%..%>

Hope this helps.
Nov 4 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Stephen | last post by:
I have been getting on well with help from this forum trying to create an array list and work with it. Everything is working fine apart from displaying my array list items into the labels in my...
11
by: Stephen | last post by:
I was wondering if someone can help me with an web application design problem. I have a aspx page which builds up an arraylist called addresses and outputs the values in the arraylist items to a...
3
by: Stephen | last post by:
I was wondering if someone can help me with an web application design problem. I have a aspx page which builds up an arraylist called addresses and outputs the values in the arraylist items to a...
3
by: Mark Jones | last post by:
I am quite new to ASP and .Net development and I am building a web-based multiple choice exam application. The web page displays the questions using a Repeater control and the answers are nested...
0
by: Jeremy Chapman | last post by:
I have included below virtually all the code to a control I'm trying to build. My issue is that an array list property in my control does not get persisted properly to the aspx page code in design...
5
by: Siva | last post by:
Hello I have a dropdownlist inside the gridview as a template column defined as follows: <asp:TemplateField HeaderText="Choose Location"> <ItemTemplate> <asp:DropDownList ID="ddlChooseLoc"...
3
by: kosmodisk | last post by:
Hi, I'm having problem accessing javascript-created elements from opened window. This occurs only when I'm including another files in opened window, javascript or css. When I comment out...
3
by: =?Utf-8?B?R3JlZw==?= | last post by:
I''ve been working with a CSharp web-site (and am new to it). I have a javascript function that accepts variables from my CSharp code. It all works fine, with the exception of one variable type. I...
13
by: looper | last post by:
Hi, i am having a problem as im new to c#. I did an arraylist and store my "uid" and want to put it into a row of pictures pic 1 , pic 2 , pic 3, pic 4 this is my code for putting the "uid"...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.