Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Using a JavaBean tags in a JSP page  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Author and ninkuma
Marshal
Posts: 66783
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a recording: place your bean in a package other than the default.
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for ur help,it's working right now.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!