aspose file tools*
The moose likes Struts and the fly likes Accessing ArrayList from a class and displaying it in a JSP page [Struts frameWork] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Accessing ArrayList from a class and displaying it in a JSP page [Struts frameWork]" Watch "Accessing ArrayList from a class and displaying it in a JSP page [Struts frameWork]" New topic
Author

Accessing ArrayList from a class and displaying it in a JSP page [Struts frameWork]

S Sand
Greenhorn

Joined: Oct 08, 2004
Posts: 13
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 roperty
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 framework


thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

Moving to the Web App Frameworks forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4753
    
    7

The error message translates to: "Make sure that the file struts-logic.tld exists in the WEB-INF directory"


Junilu - [How to Ask Questions] [How to Answer Questions]
S Sand
Greenhorn

Joined: Oct 08, 2004
Posts: 13
Thanks Junulu for replying
i' have the struts-logic.tld in WEB-INF/lib folder,
when i try to copy or move to WEB-INF WSAD[websphere stuido app dev] sayd remanme it, maybe i should cut and paste

Also my main concern is whether my approch is right, normally how do you display a ArrayList object in a class on to a JSP page
-Using struts framework :iterate tag?
-Normal jsp:UseBean?
-Write a Scriplet?

Please advice a step by step code will be great
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4753
    
    7

Originally posted by chakri sandur:

Also my main concern is whether my approch is right, normally how do you display a ArrayList object in a class on to a JSP page
-Using struts framework :iterate tag?
-Normal jsp:UseBean?
-Write a Scriplet?


I just made a Blog entry about this last night. Prefer c:forEach over logic:iterate
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing ArrayList from a class and displaying it in a JSP page [Struts frameWork]