javaBeans and JSP

F

focode

hello i am learning JSP , ia m using tomcat apache web server , i am
trying a javabean example , but i am confused where to place the
compiled class file , i am putting the jsp and the bean class in
webapps folder . the example is listed below



<%@ page import="beans.MessageBean" %>
<HTML>
<HEAD>
<TITLE>Using a JavaBean</TITLE>
</HEAD>
<BODY>
<h1>Using a JavaBean</h1>

<% MessageBean m = new MessageBean(); %>

The message is: <%= m.msg() %>

</BODY>
</HTML>

and the bean is as follows...
package beans;


public class MessageBean
{
public MessageBean()
{
}

public String msg()
{
return "Hello from JSP!";
}
}
 
L

Lew

focode said:
hello i am learning JSP , ia m using tomcat apache web server , i am
trying a javabean example , but i am confused where to place the
compiled class file , i am putting the jsp and the bean class in
webapps folder . the example is listed below

I repeat the answer given the first time you posted this question, in the
"apache tomcat" thread:
http://pdf.coreservlets.com/
> actually in the system varible , we have to set the paths of JAVA_HOME
> and CATALINA_HOME , i [sic] have made it and it is working now , while
> learning the javabeans example im [sic] confused where to keep the class
> files the example is as below

Did you read
<http://tomcat.apache.org/tomcat-6.0-doc/index.html>
?

Classes go into the classpath rooted at
application-root/WEB-INF/classes
 
A

Arne Vajhøj

focode said:
hello i am learning JSP , ia m using tomcat apache web server , i am
trying a javabean example , but i am confused where to place the
compiled class file , i am putting the jsp and the bean class in
webapps folder . the example is listed below


<%@ page import="beans.MessageBean" %>
<HTML>
<HEAD>
<TITLE>Using a JavaBean</TITLE>
</HEAD>
<BODY>
<h1>Using a JavaBean</h1>

<% MessageBean m = new MessageBean(); %>

The message is: <%= m.msg() %>

</BODY>
</HTML>

and the bean is as follows...
package beans;


public class MessageBean
{
public MessageBean()
{
}

public String msg()
{
return "Hello from JSP!";
}
}

WEB-INF/classes/beans/MessageBean.class

And that should hopefully be in whatever book you are
learning from.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top