tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Суржин Константин Вадимович <Surzhin.Konstan...@vniizht.ru>
Subject jsp to servlet
Date Tue, 27 Oct 2015 11:45:36 GMT
Hi.
win XP. 
Apache Tomcat 8.0.15
jdk8
animal.jsp (page code below)
Animal.java(page code below)

line 10 -> animalBean_0 = new org.animal.Animal();
and all right.

line 16 ->  animalBean_1 = (Animal) java.beans.Beans.instantiate(this.getClass().getClassLoader(),
"Animal");
but I need a line 1 in animal.isp  and I get differing code ( not new org.animal.Animal();)
and ☹
HTTP Status 500 - /animal.jsp (line: 16, column: 8) The value for the useBean class attribute
Animal is invalid.
and ☹
org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.animal_jsp

Maybe something is missing or incorrect on this page?? http://wiki.apache.org/tomcat/FAQ/Class_Not_Found


================
animal.jsp
================
1 <%@page import="org.animal.Animal"%>
2 <%@page language="java" contentType="text/html" pageEncoding="UTF-8"%>
3 <!DOCTYPE html>
4 <html> 
5    <head>
6        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
7       <title>JSP Page</title>
8    </head>
9    <body>
10        <jsp:useBean id="animalBean_0"  class="org.animal.Animal" scope="session">
11            <%-- intialize bean properties --%>
12            <jsp:setProperty name="animalBean_0" property="name" value="puppy" />
13            <jsp:setProperty name="animalBean_0" property="age" value="12" />
14        </jsp:useBean>
15         Sample Bean: <%= animalBean_0%>
16        <jsp:useBean id="animalBean_1" class="Animal" scope="session">
17           <%-- intialize bean properties --%>
18            <jsp:setProperty name="animalBean_1" property="name" value="floppy" />
19            <jsp:setProperty name="animalBean_1" property="age" value="2" />
20       </jsp:useBean>  
21        Sample Bean: <%= animalBean_1%>
22    </body>
23 </html>

==================
Animal.java
==================
package org.animal;
public class Animal {
    private String name = "no name";
    private Integer age = 0;
    public Animal(){
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Integer getAge() {
        return age;
    }
    public void setAge(Integer age) {
        this.age = age;
    }
    @Override
    public String toString() {
        return "Animal [name=" + name + ", age=" + age + "]";
    }
}
Mime
View raw message