Ciao qualcuno mi può aiutare? Non riesco a far girare la mia jsp che usa il tag jsp:useBean. Ho creato il bean come una classe .java nel modo seguente:
package pkgRuotaAdvert;
//Creo l'oggetto Rotator
public class Rotator {
/*Creo un vettore di tipo array di stringhe "images[]" che contiene i nomi dei file
* delle immagini delle copertine dei libri. */
private String images[] ={ "images/advjHTP1.jpg", "images/cppHTP4.jpg",
"images/iw3HTP2.jpg", "images/jwsFEP1.jpg", "images/vbnetHTP2.jpg"};
/*Creo un vettore di tipo stringa "links[]" che contiene i link ai libri
* delle pubblicità */
private String links[] = { "http://www.amazon.com/exec/obidos/AS...itelassociatin",
"http://www.amazon.com/exec/obidos/AS...itelassociatin",
"http://www.amazon.com/exec/obidos/AS...itelassociatin",
"http://www.amazon.com/exec/obidos/AS...itelassociatin",
"http://www.amazon.com/exec/obidos/AS...itelassociatin"};
//Creo un indice, che servirà a ciclare tra le
//5 pubblicità proposte
private int selectedIndex = 0;
//Metodo che ritorna il nome dell'immagine numero selectedIndex, posto che l'indice cicli
public String getImage() {
return images [selectedIndex];
}
//Metodo che ritorna il link all'immagine numero selectedIndex, posto che l'indice cicli
public String getLink() {
return links[selectedIndex];
}
/*Aggiorna l'indice selectedIndex in modo che la prossima chiamata a getImage() e
* getLink() ritorni una pubblicità diversa. */
public void nextAd() {
selectedIndex = (selectedIndex + 1) % images.length;
}
Poi lo utilizzo nella seguente jsp:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- Invoco l'azione jsp:useBean -->
<jsp:useBean id="rotator" scope="session"
class="pkgRuotaAdvert.Rotator"></jsp:useBean>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Esempio AdRotator</title>
<style type="text/css">
.big {
font-family: helvetica, sans-serif, arial;
font-weight: bold;
font-size: 2em;
}
</style>
<%-- Aggiorno la pubblicità, richiamando il metodo nextAd() dell'oggetto rotator --%>
<%
rotator.nextAd();
%>
</head>
<body>
<p class="big">Esempio AdRotator</p>
<p>
<a href="<jsp:getPr
operty name = "rotator" property = "link">">
<img src="<jsp:getProperty name = "rotator" property = "image">"
alt="Pubblicità"></img>
</a>
</p>
</body>
</html>
Quando lancio la jsp mi dice:
HTTP Status 500 - /adRotator.jsp (line: 37, column: 11) According to TLD, tag jsp:getProperty must be empty, but is not
type Exception report
message /adRotator.jsp (line: 37, column: 11) According to TLD, tag jsp:getProperty must be empty, but is not
description The server encountered an internal error that prevented it from fulfilling this request.
exception
Qual è il problema?