• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using a JavaBean tags in a JSP page

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for ur help,it's working right now.
 
reply
    Bookmark Topic Watch Topic
  • New Topic