jsp..& bean...[help]

  • Thread starter \(¯`·.¸FlacK¸.·´¯\)
  • Start date
¯

\(¯`·.¸FlacK¸.·´¯\)

Hi!
I have tried to run a little example that I have found in Internet on Java
bean, but it doesn't work, it give me an error.
I use Tomcat and I put class file in webapps\ROOT\WEB-INF\classes.
I must put something library for the bean?
I have put the code and the error below.

Thank you very much..bye


----------------------------------------

<html>
<head><title>Utilizzo del Bean</title></head>
<body>
<jsp:useBean id="utente" scope="session" class="InfoUtente"/>
<jsp:setProperty name="utente" property="nome" value="Zina&Tram"/>
<%
utente.setNome("Zina&Tram");
utente.setEmail("(e-mail address removed)");
%>
<jsp:getProperty name="utente" property="nome"/>
<% out.println(utente.getNome());
out.println(utente.riassunto()); %>
<% utente.aggiornaPV();
out.println(utente.getPagineViste()); %>
</html>

---------------------------------

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;
}

}

-------------------------





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: /InfoUtente.jsp
Generated servlet error:
C:\Programmi\Tomcat\jakarta-tomcat-5.0.27\work\Catalina\localhost\_\org\apac
he\jsp\InfoUtente_jsp.java:45: cannot resolve symbol
symbol : class InfoUtente
location: class org.apache.jsp.InfoUtente_jsp
InfoUtente utente = null;
^


An error occurred at line: 4 in the jsp file: /InfoUtente.jsp
Generated servlet error:
C:\Programmi\Tomcat\jakarta-tomcat-5.0.27\work\Catalina\localhost\_\org\apac
he\jsp\InfoUtente_jsp.java:47: cannot resolve symbol
symbol : class InfoUtente
location: class org.apache.jsp.InfoUtente_jsp
utente = (InfoUtente) _jspx_page_context.getAttribute("utente",
PageContext.SESSION_SCOPE);
^


An error occurred at line: 4 in the jsp file: /InfoUtente.jsp
Generated servlet error:
C:\Programmi\Tomcat\jakarta-tomcat-5.0.27\work\Catalina\localhost\_\org\apac
he\jsp\InfoUtente_jsp.java:49: cannot resolve symbol
symbol : class InfoUtente
location: class org.apache.jsp.InfoUtente_jsp
utente = new InfoUtente();
^


An error occurred at line: 10 in the jsp file: /InfoUtente.jsp
Generated servlet error:
C:\Programmi\Tomcat\jakarta-tomcat-5.0.27\work\Catalina\localhost\_\org\apac
he\jsp\InfoUtente_jsp.java:64: cannot resolve symbol
symbol : class InfoUtente
location: class org.apache.jsp.InfoUtente_jsp

out.write(org.apache.jasper.runtime.JspRuntimeLibrary.toString((((InfoUtente
)_jspx_page_context.findAttribute("utente")).getNome())));
^
4 errors




org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandle
r.java:84)

org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:3
32)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:412)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)

org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:5
11)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2
95)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 
K

kevin

\(¯`·.¸FlacK¸.·´¯\) said:
Hi!
I have tried to run a little example that I have found in Internet on Java
bean, but it doesn't work, it give me an error.
I use Tomcat and I put class file in webapps\ROOT\WEB-INF\classes.

The .jsp file needs to be compiled by tomcat into a java class it can
execute, (the first time it is used, or after changes). To do this it
needs to resolve the references in it to bean classes. It is telling
you that your .jsp file failed to compile, because it can not find the
bean class.

put the bean class file in
a) the <tomcat install>/shared/classes directory (some have
/common/classes)
where all jsp's will see it

b) the WEB-INF/classes directory of the directory the jsp is in.
where it will see it.

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,149
Members
46,695
Latest member
StanleyDri

Latest Threads

Top