aspose file tools*
The moose likes JSP and the fly likes Using a JavaBean tags in a JSP page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Using a JavaBean tags in a JSP page" Watch "Using a JavaBean tags in a JSP page" New topic
Author

Using a JavaBean tags in a JSP page

Jaya Sree
Greenhorn

Joined: May 29, 2004
Posts: 2
hi guys,I am new to JSP technology.I try to insert java bean tags in JSP page.
the code is given below.

public class Book
{
private string title;
public Book()
{}
public string getTitle()
{
return title;
}
public void setTitle(string title)
{
this.title=title;
}
}

I saved this file as Book.java in web-inf/classes.

and my jsp code is given below.
<html>
<body>
<jsp:useBean id="myBook" class="Book" />
<jsp:setProperty name="myBook" property="title" value="Beginning JSP" />
<jsp:getproperty name="myBook" property="value" />
</body>
</html>


I got an error saying that unable to compile class file for JSP.
do i have to configure the web.xml file?
can anybody please help me with an answer?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61054
    
  66

This is a recording: place your bean in a package other than the default.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
And also the correct syntax for the <jsp ropery> tag is


<jsp:getProperty name="beanName" property="propName"/>


were there must be getPropName method defined in your bean class.

Your source code has a lowercase "p" and your bean class does not have a getValue method defined in your bean component.




I hope this helps.

Craig.
Jaya Sree
Greenhorn

Joined: May 29, 2004
Posts: 2
Thanks for ur help,it's working right now.
 
jQuery in Action, 2nd edition
 
subject: Using a JavaBean tags in a JSP page