Solved

Accessing ArrayList from a class and displaying it in a JSP page

Posted on 2004-10-08
2
324 Views
Last Modified: 2013-11-24
Hi
I have a class

 

import java.util.ArrayList;
import java.util.Iterator;
//import java.util.Collections;

/*

 */

/**
 *
public class ArrayList_Test {

public void myMethod(){

ArrayList a = new ArrayList();
//String str = "test";
    //a.add(str);
    try{
   
   a.add("India");
   a.add("USA");
   a.add("Britian");
   a.add("Australia");
    }catch(Exception e)
    {
          System.out.println("  "+e.toString());
    }
   
   System.out.println("  My Array List"+ a.toString());
   Iterator I = a.iterator();
   while(I.hasNext())
   {
      System.out.println(" NEXT "+ I.next());
   }
                  
}
public static void main(String args[]){
                        ArrayList_Test b = new ArrayList_Test();
                        b.myMethod();
                  }
                  
}


Now i have a JSP page

<%@ taglib uri="struts-logic.tld" prefix="logic" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<%@ page
language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"
%>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="IBM WebSphere Studio">
<META http-equiv="Content-Style-Type" content="text/css">
<LINK href="theme/Master.css" rel="stylesheet"
      type="text/css">
<TITLE>ArrayList.jsp</TITLE>
</HEAD>
<BODY>
<P>

<jsp:useBean id="array_test" class="ArrayList_Test" scope="application">
<jsp:setProperty name="array_test" property="*"/>
You entered<BR>
Name:<%/**= array_test. myMethod()**/%><BR>

</jsp:useBean>

<logic:iterate
                        id="array_test" type="id"
                        name="a" scope="application"
                        <LI>
                              The Id is: <jsp:property
                                                name="array_test" property="id"/>
                                                </LI>
<logic:iterate>
</P>
</BODY>
</HTML>



now i'm getting getting this error "Broken Link - /ArrayListJSP/struts-logic.tld - Standalone TLD files must be under the WEB-INF directory.      ArrayList.jsp      ArrayListJSP/WebContent      line 1"
I'm using WSAD for development and trying to display the ArrayList values in the above JSP page, pls see what's wrong, i'm a novice and step by step help will be good and i also have STRUTS support enabled. It would be good if i use STRUTS


thanks

0
Comment
Question by:Chakri25
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 2

Expert Comment

by:siliconeagle
ID: 12349100
how have you configured your taglib in the web.xml file?
you should have a line such as this in web.xml:-
<taglib>
  <taglib-uri>/struts-logic</taglib-uri>
  <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>

and the taglib TLD file shoud be in your WEB-INF directory.

you would use it in your page like this:-
<%@ taglib uri="/struts-logic" prefix="logic" %>
0
 
LVL 2

Accepted Solution

by:
siliconeagle earned 100 total points
ID: 12481695
did this help? havent heard anything on this thread for a while.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Unable to open debugger port in Intellij idea 6 592
json example 39 179
Non-recursive backtracking, using a stack 1 307
servlet example issue 6 62
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question