Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

initialize bean problem

843836Dec 29 2004 — edited Dec 29 2004
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>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 26 2005
Added on Dec 29 2004
3 comments
107 views