mardi 20 avril 2021

Jakarta Server Pages doesnt find property

I'm trying to use jsp with Java and therefore I created the function getBestellung() . This function connects to my database and get's some entries out of it. The method itselfs works, but when I try to get the return value I get the following error on my Tomcat server: org.apache.jasper.JasperException: Cannot find any information on property [data] in a bean of type [com.example.CSA_Server.DBFunc]

This is the Class looks like:

import com.example.CSA_Server.Bestellung;

import org.omg.CORBA.PUBLIC_MEMBER;

import java.sql.*;

public class DBFunc implements secrets{

    public static Connection conn() throws SQLException {
        Connection conn = DriverManager.getConnection(url, user, password);
        System.out.println("Verbindung wurde hergestellt");
        return conn;
    }

    public static String getBestellung() throws SQLException{
        Connection conn = conn();
        String query = "SELECT * FROM Bestellung";
        Statement statement = conn.createStatement();
        ResultSet result = statement.executeQuery(query);
        Bestellung b1 = null;
        while(result.next()) {
            long bID = result.getLong("B-ID");
            long kID = result.getLong("K-ID");
            b1 = new Bestellung(bID, kID);
        }
        String string = String.valueOf(b1);
        conn.close();
        //System.out.println(string);
        return string;
    }


}

The JSP looks the like:

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<jsp:useBean id="time" class="com.example.CSA_Server.TimeServlet" scope="request" />
<jsp:useBean id="data" class="com.example.CSA_Server.DBFunc" scope="request" />
<!DOCTYPE html>
<html>
<head>
    <title>JSP - Hello World</title>
</head>
<body>
<h1><%= "Hello World!" %>
</h1>
<p>Das ist ein Probetext</p>
<br/>
<a href="hello-servlet">Hello Servlet</a>
<LI>Hallo du da</LI>
<LI><jsp:getProperty name="time" property="time"/></LI>
<LI>Du bist: <%request.getParameter("name");%></LI>

<p><jsp:getProperty name="data" property="data"/></p>
<p>Data: <%request.getParameter("data");%></p>
</body>
</html>

Most of the time, when I refresh the page there is no error. When there is no error the following value is showed: class com.example.CSA_Server.DBFunc

After refreshing multiple times I get the mentioned error.

Is there an issue with the getBestellung() function or is the jsp Syntax wrong?




Aucun commentaire:

Enregistrer un commentaire