jsp..& bean...[help]

Discussion in 'Java' started by \(¯`·.¸FlacK¸.·´¯\), Oct 20, 2004.

  1. 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("");
    %>
    <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)
    \(¯`·.¸FlacK¸.·´¯\), Oct 20, 2004
    #1
    1. Advertising

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

    kevin Guest

    "\(¯`·.¸FlacK¸.·´¯\)" <Togliere nospam e gli asterischi *: t*o*m*m*y*8*2*> wrote in message news:<>...
    > 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

    > 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("");
    > %>
    > <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)
    kevin, Oct 21, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Benjamin Stewart

    To bean or not to bean...

    Benjamin Stewart, Jun 30, 2003, in forum: Java
    Replies:
    0
    Views:
    804
    Benjamin Stewart
    Jun 30, 2003
  2. David Thielen
    Replies:
    2
    Views:
    787
    Marek Lange
    Sep 12, 2003
  3. Takeshi
    Replies:
    0
    Views:
    502
    Takeshi
    Jan 28, 2004
  4. kumar
    Replies:
    1
    Views:
    540
    Wendy S
    Feb 13, 2004
  5. jill
    Replies:
    5
    Views:
    15,576
Loading...

Share This Page