473,513 Members | 2,752 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing ArrayList to place in table on jsp page

JoeMac3313
16 New Member
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 8086
itsraghz
127 New Member
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
464
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
2144
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
2840
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
2540
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
3233
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
2744
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
2098
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
3782
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
2753
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"...
0
7254
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7094
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5677
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.