public String[] getZahl(){ //code of method 1 return zahl;}public void setZahl(String[] filename){ //code of method 2 zahl = filename;}
Bean:package testbean.src;import java.io.*;import java.sql.*;public final class Dokum extends java.lang.Object implements Serializable{ private String[] zahl; public Dokum() throws SQLException, FileNotFoundException, IOException { //code of constructor zahl = new String[]{"erstens", "zweitens"}; } public String[] getZahl() throws SQLException { //code of method 1 return zahl; } public void setZahl(String[] filename) throws SQLException, FileNotFoundException, IOException { //code of method 2 zahl = filename; } public void toFile(int userid, String[] filename) { }}JSP:<%@page contentType="text/html"%><%@ page import="java.lang.reflect.*" %><%@ page import="java.lang.*" %><%@ page import="java.util.*" %><%@ page import="testbean.src.Dokum" %><jsp:useBean id="dokum" scope="page" class="testbean.src.Dokum"/><%! String filename[] = new String[100]; %><%! int userid = 23; %><html><head><title>Dokumentenmanagement</title></head><body>die seite läuft...<%filename = dokum.getZahl();int laenge = Array.getLength(filename);dokum.toFile(userid, filename);for (int i = 0; laenge < i ; i ++){ %> Datei: <%=filename[i]%> <%}%><jsp:getProperty name="dokum" property="zahl"/></body></html>