主题:新手请教:jsp调用javaBean!
我用的是jdk1.4,tomcat4.1;
jsp文件放在 C:\tomcat\webapps\ROOT\myapp\test 目录下;
----
<BODY>
<jsp:useBean id="hellobean" scope="application" class="test.helloworld"/>
<%=hellobean.getHi()%>
<hr>
<%
hellobean.name="JSP";
out.print(hellobean.getHi());
%>
</BODY>
----
java 文件编译后 helloworld.class放在
C:\tomcat\webapps\ROOT\myapp\WEB-INF\classes\test
package test;
public class helloworld
{
public String name="My first bean";
public String getHi()
{
return "Hello from"+name;
}
}
编译提示:
package test don't exist;
--------------------------
.jsp文件和.calss文件应放哪?
jsp文件放在 C:\tomcat\webapps\ROOT\myapp\test 目录下;
----
<BODY>
<jsp:useBean id="hellobean" scope="application" class="test.helloworld"/>
<%=hellobean.getHi()%>
<hr>
<%
hellobean.name="JSP";
out.print(hellobean.getHi());
%>
</BODY>
----
java 文件编译后 helloworld.class放在
C:\tomcat\webapps\ROOT\myapp\WEB-INF\classes\test
package test;
public class helloworld
{
public String name="My first bean";
public String getHi()
{
return "Hello from"+name;
}
}
编译提示:
package test don't exist;
--------------------------
.jsp文件和.calss文件应放哪?