*
The moose likes JSP and the fly likes  Setting up directory structure for Bean Component in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark " Setting up directory structure for Bean Component in JSP" Watch " Setting up directory structure for Bean Component in JSP" New topic
Author

Setting up directory structure for Bean Component in JSP

naveen jayant
Greenhorn

Joined: Jun 11, 2007
Posts: 6
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
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60739
    
  65

The JSP FAQ covers this issue, was it not helpful?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
naveen jayant
Greenhorn

Joined: Jun 11, 2007
Posts: 6
Thanks Bear!
I got solution..
bye
 
Consider Paul's rocket mass heater.
 
subject: Setting up directory structure for Bean Component in JSP
 
Similar Threads
Error - Please Help!!!
Where in Tomcat3.1 should i put .jsp files, .java files(Beans files)
The value for the useBean class attribute StringBean is invalid
import package problems??
import package problem???