0

I want to learn Java web programmign with Netbeans via Apache Tomcat server. I am beginner and my first project gets error when I add jsp:bean code. I can open index.html without any problem and I can add text etc. This is my error:

HTTP Status 500 – Internal Server Error
Type Exception Report
Message An exception occurred processing [/cevap.jsp] at line [18]

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

org.apache.jasper.JasperException: An exception occurred processing [/cevap.jsp] at line [18]

15: 
16:         
17:         <h1>Merhaba</h1>
18:         <jsp:useBean id="firstBean" scope="session" class="data.Person" />
19:         <jsp:setProperty name="firstBean" property="name" value="" />
20:         <jsp:getProperty name="firstBean" property="name" />
21:     </body>


Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:625)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:514)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

Root Cause

java.lang.RuntimeException: 
    data.Person.<init>(Person.java:1)
    org.apache.jsp.cevap_jsp._jspService(cevap_jsp.java:134)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:476)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

Note The full stack trace of the root cause is available in the server logs.
Apache Tomcat/9.0.24

When I use jsp:useBean code, I get the error, I could write something on the page but I cannot use jsp codes like jsp:useBean, jsp:setProperty, jsp:getProperty etc..

Like I said, this was my first try with server. I dont know to much about web applications.

    package data;

public class Person {

    String name;

    public Person() {
        name = null;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}
A.O.92
  • 13
  • 1
  • 5
  • Have you got a Person constructor without parameters? Your StackTrace clearly states that it can not "data.Person.(Person.java:1)" . Try to call Person p = new Person() in a Unittest or somewhere in your Java code. Since you do not provide the bean or the configuration thats the thing to check that comes into my mind. – Manuel Manhart Sep 14 '19 at 08:29
  • package data; public class Person { String name; public Person() { name = null; } public String getName() { return name; } public void setName(String name) { this.name = name; } } This is my Person.java code. – A.O.92 Sep 14 '19 at 11:09
  • I added my code to the question you can check it from there. – A.O.92 Sep 14 '19 at 11:10

0 Answers0