|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Sep 2003
Città: Milano
Messaggi: 4623
|
[JSP] Il mio primo Bean.. non va
ciao, sto provando a scrivere il mio primo bean Usando Eclipse:
Nuovo progetto Web Dinamico -> nuova classe: Codice:
public class InfoUtente {
private String nome = null;
private String email = null;
private int pagineViste;
public InfoUtente() {
pagineViste=0;
}
public void aggiornaPV(){
pagineViste++;
}
public int getPagineViste(){
return pagineViste;
}
public void setNome(String value) {
nome = value;
}
public String getNome() {
return nome;
}
public void setEmail(String value) {
email = value;
}
public String getEmail() {
return email;
}
public String riassunto(){
String riassunto = null;
riassunto = "Il nome dell'utente è"+nome+",";
riassunto+= "il suo indirizzo e-mail è: "+email;
riassunto+=" e ha visitato "+pagineViste+" del sito";
return riassunto;
}
}//InfoUtente
poi nuova JSP -> Codice:
<html> <head><title>Utilizzo del Bean</title></head> <body> <jsp:useBean id="utente" scope="session" class="InfoUtente"/> </body> </html> mi dico: va beh vediamo lo stesso: RunAs ->on Server ->mi fa selezionare Tomcat 6 regolarmente installato Si avvia Tomcat e mi da errore: Codice:
HTTP Status 500 - type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 4 in the jsp file: /index.jsp InfoUtente cannot be resolved to a type
__________________
Ho trattato con : lahiri, czame, RC, allXXX, dfruggeri, JMM, Paperone, xej, Pappez, iperfly, Red81, Playmake, ryan78, Rob66, XP2200, Peach1200, faberjack, Stewie82, supermario_bros, hft500, Axelscorpio, pipes lee, Piccolospazio, RohanKish, miki66, kabira85 |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Sep 2007
Messaggi: 754
|
Ma la classe è in pakage?
__________________
http://www.tevigroup.it/ |
|
|
|
|
|
#3 |
|
Senior Member
Iscritto dal: Sep 2003
Città: Milano
Messaggi: 4623
|
la classe anche se sconsigliato non è in un package, ho fatto semplicementa "aggiungi classe" e mi ha messo il file java nel default package e me lo ha regolarmente compilato nella build /classes il fatto è che... il file web.xml dovrebbe contenere qualche info? eclipse fa tutto da se? è così Codice:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>primoWeb</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
__________________
Ho trattato con : lahiri, czame, RC, allXXX, dfruggeri, JMM, Paperone, xej, Pappez, iperfly, Red81, Playmake, ryan78, Rob66, XP2200, Peach1200, faberjack, Stewie82, supermario_bros, hft500, Axelscorpio, pipes lee, Piccolospazio, RohanKish, miki66, kabira85 |
|
|
|
|
|
#4 |
|
Senior Member
Iscritto dal: Sep 2007
Messaggi: 754
|
Nel'xm nn deve esservi niente metti il bean in un pakage e riporva
Codice:
<jsp:useBean id="utente" scope="session" class="net.codersforum.samples.InfoUtente"/>
__________________
http://www.tevigroup.it/ |
|
|
|
|
|
#5 | |
|
Senior Member
Iscritto dal: Sep 2003
Città: Milano
Messaggi: 4623
|
Quote:
__________________
Ho trattato con : lahiri, czame, RC, allXXX, dfruggeri, JMM, Paperone, xej, Pappez, iperfly, Red81, Playmake, ryan78, Rob66, XP2200, Peach1200, faberjack, Stewie82, supermario_bros, hft500, Axelscorpio, pipes lee, Piccolospazio, RohanKish, miki66, kabira85 |
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 00:58.




















