English 中文(简体)
JSP Hello, Error
原标题:JSP Hello Page Error

I am beginner in JSP and trying to do simple jsp page. ı want to set my class fields name and surname and print on the page. My class :

package org.mypackage.person;

/**
 *
 * @author cemalinanc
 */
public class Person {

    private String name;
    private String surname;

    Person()
    {
        name = null;
        surname = null;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the surname
     */
    public String getSurname() {
        return surname;
    }

    /**
     * @param surname the surname to set
     */
    public void setSurname(String surname) {
        this.surname = surname;
    }

}

页: 1 jsp与:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Hello World!</h1>
        <form name="input form" action="response.jsp">
            Name:
            <input type="text" name="name" value="" /> 
            Surname:
            <input type="text" name="surname" value="" />
            <input type="submit" value="Ok" />
        </form>
    </body>
</html>

我的答复。 jsp page

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <jsp:useBean id="mybean" scope="session" class="org.mypackage.person.Person" />
        <jsp:setProperty name="mybean" property="name" />
        <h1>Hello,     <jsp:getProperty name="mybean" property="name" />!</h1>
    </body>
</html>

I just want to set two fields in the class and print to screen both of them but i could not. Later i tried to print just name field but again could not. I take an error like:

The server encountered an internal error () that prevented it from fulfilling this request. org.apache.jasper.JasperException: /response.jsp (line: 15, column: 8) The value for the useBean class attribute org.mypackage.person.Person is invalid.

What is the problem with this?

如果你能给我一个想法,那将不胜感激。 非常感谢您的帮助。

问题回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签