0
javaとjsp間のListの受け渡し
お世話になります。
Eclipse3.4.2とTomcat5.5を使用しxmlから取得したデータをArrayListに格納し
jspにListをforwardし一覧を表示するサーブレットを作成しようとしています。
-----------------main.java----------------------
ArrayList<String> aid = new ArrayList<String>();
DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = dbfactory.newDocumentBuilder();
org.w3c.dom.Document doc = builder.parse(new File("log.xml"));
Element root = doc.getDocumentElement();
NodeList list = root.getElementsByTagName("page");
for(int i=0; i < list.getLength() ; i++){
Element element = (Element)list.item(i);
String id = element.getAttribute("id");
aid.add(id);
}
request.setAttribute("id",aid);
RequestDispatcher rd = request.getRequestDispatcher("index.jsp");
rd.forward(request,response);
---------------------jsp---------------------------
<%@ page contentType="text/html;charset=Windows-31J"
pageEncoding="Windows-31J" %>
<%
request.setCharacterEncoding("Shift_JIS");
String id = (String)request.getAttribute("id");
%>
<html><body>
<%= id %>
</body></html>
---------------------------------------------------
考えてみれば当然の事だと思うのですがこのjspではListを受け取ることができません。
解決方法や参考になるサイトがありましたらどなたかご教示ください
よろしくお願いします。