I have a setting.java
class and in this class I read my data from a file and I want to use this data with jsp:useBean
in my index.jsp
page.
this class code is bellow:
public class setting {
private boolean setstatus=false;
private String title="Test";
public boolean changeheader(String text) {
return true;
}
public boolean settitle(String text) {
return true;
}
public void getTitle() throws IOException{
BufferedReader br ;
try {
br = new BufferedReader(new FileReader("C:\\Users\\Farshid\\workspace\\STPT\\WebContent\\file\\title.txt"));
this.title = br.readLine();
System.out.println("\nline: " + this.title + "\n");
br.close();
} catch (FileNotFoundException e1) {
e1.printStackTrace();
System.out.println("Error");
}
}
}
And this is my index.jsp codes:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>
</title>
</head>
<body>
<jsp:useBean id="settitle" class="com.stpt.project.setting" scope="page">
<jsp:getProperty property="title" name="settitle" />
</jsp:useBean>
</body>
</html>
And these are my errors:
type Exception report
message Cannot find any information on property '*' in a bean of type 'com.stpt.project.setting'
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Cannot find any information on property '*' in a bean of type 'com.stpt.project.setting'
org.apache.jasper.runtime.JspRuntimeLibrary.getReadMethod(JspRuntimeLibrary.java:824)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1081)
org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:1125)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2377)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2429)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1380)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1181)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2377)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2429)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2435)
org.apache.jasper.compiler.Node$Root.accept(Node.java:474)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2377)
org.apache.jasper.compiler.Generator.generate(Generator.java:3517)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:250)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:657)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Finally my IDE is eclipse and my server is apache tomcat7.0.