want to try out a simple
JSP example that uses beans. The code is
given below . What I don't understand is where do I have to put these files. I have configure Bean in Web.xml file .I guess the file I have really doubts about is StringBean.java which is the bean file. I tried putting all in
C:\tomcat4\webapps\webdir\WEB-INF\classes but nothing seems to work. I
keep getting this error:
org.apache.jasper.JasperException: Unable to compile class for JSP
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 15 in the jsp file: /StringBean.jsp
Generated
servlet error:
F:\naveen\Tomcat 5.0\work\Catalina\localhost\JspBean\org\apache\jsp\StringBean_jsp.java:56: cannot find symbol
symbol : class StringBean
location: class org.apache.jsp.StringBean_jsp
StringBean stringBean = null;
^
So can someone help me determine the correct directory structure and
where to put files. Thanks.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Using
Java BEAN With JSP</TITLE>
</HEAD>
<BODY>
<TABLE BORDER=5 ALIGN="center">
<TR><TH CLASS="TITLE">
Using Java BEAN With JSP</TABLE>
<jsp:useBean id="stringBean" class="StringBean"/>
<OL>
<LI>Initial Value:
<I><jsp:getProperty name="stringBean"
property="message"/></I>
<LI>Initial value from jsp expression:
<I><%= stringBean.getMessage()%><I/>
<LI><jsp:setProperty name="stringBean"
property="message"
value="Best
string Bean"/>
value after setting property:
<I><jsp:getProperty name="stringBean"
property="message"/>
<LI><% stringBean.setMessage("my favourite");%>
value after setting property with scriptlet:
<I><%=stringBean.getMessage()%></I>
</OL>
</BODY>
</HTML>
JSP bean:
public class StringBean {
private String message = "No message specified";
public String getMessage() {
return(message);
}
public void setMessage(String message) {
this.message = message;
}
}
Help Me..
waiting for repply