Hi guys,
can you give me a hand with this thing? I'm trying to understand how to use javaBean. What's wrong with this exmple? It seams that my jsp page does not inizialize mioBean.
//this is my bean that uses a class called db
//db class contains a method called getTableName(id) that returns a String[]
package mioPkg;
public class mioBean{
String[] tabella;
int mioIndice;
int index;
db d = null;
public mioBean(){
d = new db();
tabella = d.getTableName("3");
mioIndice = tabella.length;
}
public void setIndex(int index){
this.index=index;
}
public int getIndex(){
return index;
}
public String getTabella(){
return tabella[index];
}
public void setTabella(int index, String value){
tabella[index] = value;
}
}
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>Visualizza tabella</title>
</head>
<body bgcolor="white">
<jsp:useBean id="table" scope="page" class="mioPkg.mioBean"> </jsp:useBean>
<form name="visTab" action="prova.jsp" method="post">
<select name="tabelle">
<c:forEach var="i" begin="${1}" end ="${mioIndice}">
<jsp:setProperty name="table" property="index" value="${i}"/>
<jsp:getProperty name="table" property="tabella"/>
<option>${tabella}</option>
</c:forEach>
</select>
</form>
</body>