我是新手,请各位高手帮帮忙!
我找了javabean相关知识了,就是运行不出javabean,急啊!!!
我是先在dos环境下编译sampleBean.java,然后把sampleBean.class复制到
D:\Apache Software Foundation\Tomcat 5.5\webapps\jsp\WEB-INF\classes\bean
java源程序:
package bean;
public class sampleBean
{
private String sample="start value";
public String getSample()
{return sample;}
public void setSample(String newValue)
{ if(newValue!=null) sample=newValue;}
}
在D:\Apache Software Foundation\Tomcat 5.5\webapps\jsp下编写sample1.jsp
jsp程序:
<%@page contentType="text/html;charSet=2312"%>
<html>
<head><title>servlet使用jsp</title></head>
<jsp:useBean id="mybean" scope="application" class="bean.sampleBean"/>
<body>
<h2>使用javabean</h2>
<jsp:getProperty name="mybean" property="sample"/>
<jsp:setProperty name="mybean" property="sample" value="hhhh"/>
<jsp:getProperty name="mybean1" property="sample"/>
</body></html>
打开IE 输入http://localhost:8080/jsp/sample1.jsp
结果出错了:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Attempted a bean operation on a null object.
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
org.apache.jasper.JasperException: Attempted a bean operation on a null object.
org.apache.jasper.runtime.JspRuntimeLibrary.handleGetProperty(JspRuntimeLibrary.java:601)
org.apache.jsp.sample1_jsp._jspService(sample1_jsp.java:62)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
帮我看看!非常感激!
是不是还需要一些特殊配置呢?
如能出例子,那最好了。
3q!!!!