UseBean ....

Hi friends
I used KavaChart to draw some charts in my project.The program was running in another server .i copied the program to another server and try to run that i am getting error at the line
*<jsp:useBean id="chart" class="com.ve.kavachart.servlet.barApp" scope="page"/>*
Jar file is at the location
*./jakarta-tomcat-5.5.9/webapps/ROOT/WEB-INF/lib/kcServlet.jar*
Error is
org.apache.jasper.JasperException: /plantStockSummary.jsp(5,0) The value for the useBean class attribute com.ve.kavachart.servlet.barApp is invalid.
+     org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)+
+     org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)+
+     org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)+
+     org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1200)+
+     org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1160)+
+     org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)+
+     org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)+
+     org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2399)+
+     org.apache.jasper.compiler.Node$Root.accept(Node.java:489)+
+     org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)+
+     org.apache.jasper.compiler.Generator.generate(Generator.java:3372)+
+     org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)+
+     org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)+
+     org.apache.jasper.compiler.Compiler.compile(Compiler.java:294)+
+     org.apache.jasper.compiler.Compiler.compile(Compiler.java:281)+
+     org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)+
+     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)+
+     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)+
+     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)+
+     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)+
We are using linux OS.Please help
thanks

ya i open kc Servlet.jar file also
kcServlet.jar file is located at var/tomcat/webapps/ROOT/WEB-INF/lib
jsp file plantStockSummary.jsp is at ROOT folder
When i try to run the program i am getting error of
org.apache.jasper.JasperException: /plantStockSummary.jsp(5,0) The value for the useBean class attribute com.ve.kavachart.servlet.barApp is invalid.
     org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
     org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
     org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
     org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1200)
     org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1160)
     org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
     org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
     org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2399)
     org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
     org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
     org.apache.jasper.compiler.Generator.generate(Generator.java:3372)
     org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
     org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
     org.apache.jasper.compiler.Compiler.compile(Compiler.java:294)
     org.apache.jasper.compiler.Compiler.compile(Compiler.java:281)
     org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:26

Similar Messages

  • How to use "scope " attrubute in useBean tag

    Can anyone please tell me if I can use the same JavaBean Class to hold information form different pages? well, let me explain exactely what I want to do:
    I have a Java bean Class that holds a property 'Name':
    package ContactManager;
    public class Person {
    private String name="%";
    public String getName () {
    return this.name;
    public void setName (String my_name) {
    name = my_name + "%" ;
    I'm using this class to store temporarly the Criteria of search from a JSP/HTML page to send to a database for search and for UPDATE -> this of course is done in different HTML/JSP pages. The problem I have is that the first time I set the properties (when the user make a search) this value remains unchanged [-> the second time when the user asks for update, I try to use the same bean to keep the value => unfortuntly it returns me the old value]
    My question is: is the use of 'scope' attribute of the "jsp:useBean" tag can solve this problem? if yes how to use it? I've tryed to set the scope of the bean to page but that does not help :-(
    Pleaze help, I'm stuck.... Bellow is the 4 JSP pages for:
    - person_search.jsp / person_result.jsp
    - request_modify.jsp/ DoModify.jsp
    1 -person_search.jsp
    <%@ page import="java.sql.*" %>
    <HTML>
    <HEAD><TITLE>Person Search</TITLE></HEAD>
    <BODY><CENTER>
    <form method="POST" action="person_result.jsp">
    Name <input type="text" name="name" size="47"></p>
    <input type="submit" value="Submit" name="B1">
    <input type="reset" value="Reset" name="B2"></p>
    </form></body>
    </html>
    2- person_result.jsp
    <%@ page import="java.sql.*" %>
    <HTML><BODY>
    <jsp:useBean id="theBean" class="ContactManager.Person"/>
    <jsp:setProperty name="theBean" property="*" />
    Name<BR>
    <%
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    System.out.println("JDBC driver loaded");
    catch (ClassNotFoundException e) {
    System.out.println(e.toString());
    %>
    <%
    try {
    Connection con = DriverManager.getConnection("jdbc:odbc:ContactManager");
    Statement s = con.createStatement();
    String sql = "SELECT Client.ClientID, Client.Name FROM Client where Client.Name like " + "'" + theBean.getName() + "'";
    ResultSet rs = s.executeQuery(sql);
    while (rs.next()) {
    String myId = rs.getString(1);
    %>
    <TR>
    <TD><%= myId %></TD>
    <TD><a href="person_detail.jsp?id=<%= myId %>"><%=rs.getString(2)%></a></TD>
    <TD><a href="delete_person.jsp?id=<%= myId %>">Delete</a></TD><BR>
    </TR>
    <%
    rs.close();
    s.close();
    con.close();
    catch (SQLException e) {
    System.out.println(e.toString());
    catch (Exception e) {
    System.out.println(e.toString());
    %>
    </BODY>
    </HTML>
    3- request_modify.jsp
    <%@ page import="java.sql.*" %>
    <html>
    <head><title>AddressBook: Modifying Person <%= request.getParameter ("id") %></title> </head>
    <body bgcolor="#ffffee">
    <%
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    System.out.println("JDBC driver loaded");
    catch (ClassNotFoundException e) {
    System.out.println(e.toString());
    %>
    <%
    int rowsAffected = 0;
    try {
    Connection con = DriverManager.getConnection("jdbc:odbc:ContactManager");
    Statement s = con.createStatement();
    String sql = "SELECT Client.ClientID, Client.Name FROM Client where ClientID ="+ request.getParameter("id");
    ResultSet rs = s.executeQuery(sql);
    if (rs.next()) {
    %>
    Client Name is <input type=text name=name value=<%= rs.getString(2) %>> <br>
    <TD><a href="person_do_modify.jsp?id=<%= rs.getString(1)%>">Confirm Modify</a></TD>
    <%
    rs.close();
    s.close();
    con.close();
    catch (SQLException e) {
    System.out.println(e.toString());
    catch (Exception e) {
    System.out.println(e.toString());
    %>
    </BODY> </HTML>
    4- do_modify.jsp
    <%@ page import="java.sql.*" %>
    <html>
    <head><title>AddressBook: Modifying Address <%= request.getParameter ("id") %></title></head>
    <body bgcolor="#ffffee">
    <jsp:useBean id="theBean" class="ContactManager.Person" scope="page"/>
    <jsp:setProperty name="theBean" property="name"/>
    <%
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    System.out.println("JDBC driver loaded");
    catch (ClassNotFoundException e) {
    System.out.println(e.toString());
    %>
    <%
    int rowsAffected = 0;
    try {
    Connection con = DriverManager.getConnection("jdbc:odbc:ContactManager");
    PreparedStatement preparedStatement = con.prepareStatement ("UPDATE Client SET Name=? WHERE ClientID =?");
    preparedStatement.setString (1, theBean.getName());
    preparedStatement.setString (2, request.getParameter("id"));
    rowsAffected = preparedStatement.executeUpdate ();
    preparedStatement.close ();
    if (rowsAffected == 1) {
    %>
    done
    <%
    else{
    %>
    Not Modified
    <%
    con.close();
    catch (SQLException e) {
    System.out.println(e.toString());
    catch (Exception e) {
    %>
    </BODY></HTML>
    Thank you for the help.
    Sammy

    While a quick search on the <jsp:useBean> tag and the scope attribute will probably yield more information than I can summarize in a few sentences, I'm pretty sure that using the scope="page" attribute on a bean will cause that bean to be instantiated every time the page is loaded. In order for a bean to persist longer than the existance of that page (whether you're loading a new page, or reloading the same one), you'd need to set the scope to session or application (you'd probably want session).

  • How to assign the class value dynamically  in jsp:useBean ?its urgent

    Hi
    I want to set the class value of <jsp:useBean> dynamically
    when i am trying to this way
    <jsp:useBean id="<%=id %>" class="<%=beanclass %>" scope="request">
    <jsp:setProperty name="<%=id %>" property="*"/>
    </jsp:useBean>
    where beanclass is .class file that is to be used by the usebean tag
    i am getting following error
    The value for the useBean class attribute <%=beanclass %> is invalid.
    please help as soon as possible
    regards,
    Rameshwari

    You can not do that.The jsp:useBean and jsp:setProperty are action tags and not custom tags. Action tags get translated into Java code in the translation unit and are then compiled. Custom tag are backed by classes and the tag get translated into a method call of the class.

  • An error in jsp page useBean when i try to include the java bean package?

    Hi Sir,
    I am using import com.project.ShowData in java beans inorder to connect to the jsp.
    The jsp code goes like this:-
    <%@ page import="com.project.ShowData" %>
    <jsp:useBean id="jspuser1" class="com.viman.ShowData" scope="session"/>
    <jsp:setProperty name="jspuser1" property="*"/>
    Here the error is showing as cannot resolve symbols in com.project.ShowData.But i have given the same in java beans like this:-
    Package com.project;
    //import of package goes here
    public class ShowData
    //code goes here
    It seems that all are correct here.I have done few programs using this without any problem.But suddenly it is giving a problem like this.What is the problem here?It is quite Urgent.Thank u.
    Regards,
    m.ananthu

    Greetings,
    Here the error is showing as cannot resolve symbols in com.project.ShowData.But i have given the
    same in java beans like this:-Seeing the actual error would be more helpful. ;)
    Regards,
    m.ananthu Regards,
    Tony "Vee Schade" Cook

  • Jsp:useBean and assigning a value to that bean

    Hello,
    I have a type called Country and I have declared a bean using the "jsp:useBean" syntax.
    I then try to assign a value to that bean in a scriptlet. Eventually I try to retrieve the values using "jsp:getProperty". The problem is that it appears to null.
    Here is the code of the jsp
    <%@ page language="java" %>
    <%@ page import="com.parispano.latinamericaguide.*" %>
    <%
    /* We retrieve the Countries object from the servlet context. */
    ServletContext sc = getServletContext();
    Countries cs = (Countries)sc.getAttribute("countries");
    %>
    <jsp:useBean id="country" class="com.parispano.latinamericaguide.Country"/>
    <%
    /* If the request contains a country id, then we set the variable. */
    country = cs.getCountryFromId(Integer.parseInt(request.getParameter("countryID")));
    %>
    <html>
    <head>
    <title>Country details</title>
    </head>
    <body>
    <table>
    <tr><td>Name</td><td><jsp:getProperty name="country" property="name"/><!-- This is not working--></td></tr>
    <table>
    <%
    out.println(country.getName());//This is working
    %>
    </body>
    </html>This is the code for the bean
    package com.parispano.latinamericaguide;
    * @author Julien Martin
    * Represents a country.
    public class Country implements Comparable {
         private int id;
         private String name;
         private int landArea;
         private String capital;
         private String currency;
         private String flag;
         private String internet_domain;
         private String dialling_code;
         private float literacy;
         private float male_life_expectancy;
         private float female_life_expectancy;
         private String map;
         private int population;
         private int population_year;
         private float birth_rate;
         private int birth_rate_year;
         private float death_rate;
         private int death_rate_year;
         private int gdp;
         private int gdp_per_head;
         private int gdp_year;
         private float unemployment_rate;
         private int unemployment_rate_year;
         public Country() {
         public Country(
              int id,
              String name,
              int landArea,
              String capital,
              String currency,
              String flag,
              String internet_domain,
              String dialling_code,
              float literacy,
              float male_life_expectancy,
              float female_life_expectancy,
              String map,
              int population,
              int population_year,
              float birth_rate,
              int birth_rate_year,
              float death_rate,
              int death_year_rate,
              int gdp,
              int gdp_year,
              float unemployment_rate,
              int unemployment_rate_year) {
              this.id = id;
              this.name = name;
              this.landArea = landArea;
              this.capital = capital;
              this.currency = currency;
              this.flag = flag;
              this.internet_domain = internet_domain;
              this.dialling_code = dialling_code;
              this.literacy = literacy;
              this.male_life_expectancy = male_life_expectancy;
              this.female_life_expectancy = female_life_expectancy;
              this.map = map;
              this.population = population;
              this.population_year = population_year;
              this.birth_rate = birth_rate;
              this.birth_rate_year = birth_rate_year;
              this.death_rate = death_rate;
              this.death_rate_year = death_year_rate;
              this.gdp = gdp;
              this.gdp_year = gdp_year;
              this.unemployment_rate = unemployment_rate;
              this.unemployment_rate_year = unemployment_rate_year;
         public float getBirth_rate() {
              return birth_rate;
         public int getBirth_rate_year() {
              return birth_rate_year;
         public String getCapital() {
              return capital;
         public String getCurrency() {
              return currency;
         public float getDeath_rate() {
              return death_rate;
         public int getDeath_rate_year() {
              return death_rate_year;
         public String getDialling_code() {
              return dialling_code;
         public float getFemale_life_expectancy() {
              return female_life_expectancy;
         public String getFlag() {
              return flag;
         public int getGdp() {
              return gdp;
         public int getGdp_per_head() {
              return gdp / population;
         public int getGdp_year() {
              return gdp_year;
         public int getId() {
              return id;
         public String getInternet_domain() {
              return internet_domain;
         public float getLiteracy() {
              return literacy;
         public float getMale_life_expectancy() {
              return male_life_expectancy;
         public String getMap() {
              return map;
         public String getName() {
              return name;
         public int getPopulation() {
              return population;
         public int getPopulation_year() {
              return population_year;
         public int getLandArea() {
              return landArea;
         public float getUnemployment_rate() {
              return unemployment_rate;
         public int getUnemployment_rate_year() {
              return unemployment_rate_year;
         public void setBirth_rate(float f) {
              birth_rate = f;
         public void setBirth_rate_year(int i) {
              birth_rate_year = i;
         public void setCapital(String string) {
              capital = string;
         public void setCurrency(String string) {
              currency = string;
         public void setDeath_rate(float f) {
              death_rate = f;
         public void setDeath_rate_year(int i) {
              death_rate_year = i;
         public void setDialling_code(String string) {
              dialling_code = string;
         public void setFemale_life_expectancy(float f) {
              female_life_expectancy = f;
         public void setFlag(String string) {
              flag = string;
         public void setGdp(int i) {
              gdp = i;
         public void setGdp_per_head(int i) {
              gdp_per_head = gdp/population;
         public void setGdp_year(int i) {
              gdp_year = i;
         public void setId(int i) {
              id = i;
         public void setInternet_domain(String string) {
              internet_domain = string;
         public void setLiteracy(float f) {
              literacy = f;
         public void setMale_life_expectancy(float f) {
              male_life_expectancy = f;
         public void setMap(String string) {
              map = string;
         public void setName(String string) {
              name = string;
         public void setPopulation(int i) {
              population = i;
         public void setPopulation_year(int i) {
              population_year = i;
         public void setlandArea(int i) {
              landArea = i;
         public void setUnemployement_rate(float f) {
              unemployment_rate = f;
         public void setUnemployment_rate_year(int i) {
              unemployment_rate_year = i;
         public String toString() {
              return name;
         public int compareTo(Object o) {
              Country c = (Country)o;
              int cmp = name.compareTo(c.name);
              System.out.println(cmp);
              return cmp;
    }Can anyone please help?
    Thanks in advance,
    Julien.

    Thanks,
    I have added scope="application". It still show "null" indicating that the bean is not initialized with the properties. I would like a quicker way to initialize a bean property than invoking the setProperty tag for each property.
    Here is a simple example that demonstrates the problem:
    <%@ page language="java" %>
    <%@ page import="com.tests.*" %>
    <jsp:useBean id="monBean" class="com.tests.MonBean" scope="application"/>
    <%
    MonBean mb = new MonBean();
    mb.setName("toto");
    monBean= mb;
    %>
    <html>
    <head>
    <title>Lomboz JSP</title>
    </head>
    <body bgcolor="#FFFFFF">
    <jsp:getProperty name="monBean" property="name"/>
    </body>
    </html>And the bean
    package com.tests;
    public class MonBean {
    private String name;
    public String getName() {
         return name;
    public void setName(String name) {
         this.name = name;
    }This show "null".
    Any other idea why this is not working?
    Thanks,
    Julien

  • Jsp:useBean giving error while compiling JSP's in JDeveloper

    Hello,
    I am having another problem with JSP's in JDeveloper 10.1.3. jsp:useBean and jsp:setProperty are all giving problems. I am not sure what I need to do to get rid of this error
    Thanks,
    Lakshmisri

    Your original post mentions issues with jsp:useBean and jsp:setProperty, now you're talking about tag libraries and directives. Can you be more specific about what you're trying to do? Are you having problems getting JDev to recognize a tag library or are you having problems with the tag library when running the app? What directive are you trying to use that causes the termination error?

  • Jsp:usebean How to get value of an object from a bean

    I am new to JSP and am struggling from past few days to solve a problem. Consider the below scenario
    Class Book{
    private String author;
    public void setAuthor(String author)
    public String getAuthor(){
    return author; }
    Class Rack{
    private Book []books;
    public []Book getbooks()
    return books;
    public void setbooks([]Book val){....}
    Suppose Books gets populated only using Rack and I have Rack populate in my session, using jsp:usebean or any other tag how can I get value of author? Does using tag handle null value check of books, if books are not set by any chance?
    Regards,
    Dhyan

    I got a way out to access the attribute, i feel it is
    <jsp:usebean id="myRack" class="settings.Rack"/>
    <c:foreach var="book" item="myRack.books">
    </c:foreach>
    I am not able to check if this is correct or not because myRack.books is not having any value set by me in the request scope. How do i get instance of Rack class set by another page in the current request? I can get the value if i use scriptlet but i dont want to use scriptlet.
    I am continiously trying, if I get an answer, I shall post, else pls somebody guide.

  • Which one better to use - jsp:useBean or import statement

    Hi,
    I just want to know that which one is better to use jsp:useBean or import statement .
    I can instantiate and call method of myclass -
    1) by importing the class through import tag in jsp as <%@page import="myclass"%. or
    2). by using <jsp:useBean tag....
    i have these two option to do the same thing. i know that basically useBean is used to call setter and getter method of bean class and but it can be used to call a normal java file that have some logic .
    so what should i used , which one is better and why?
    useBean provides scope and object instance so no need to create object by new operator. and with import you have to create an instance .
    but which tag should i use in my jsp?
    i am confused???

    ok, means i can use jsp:useBean tag for all my
    classes that are not actually bean. so it will be
    instantiated at run time and provide efficiency .No. Jsp:useBean is used for java bean components.
    >
    but when should i use import statement in my jsp and
    it happen at translation time so will it create any
    type of burden for my code if i import multiple
    classes.For non-java beans, you need to import the classes, period.
    It's not a burden, it's a necessity.

  • Why do we need jsp:useBean???

    Hi All,
    I am going over both the J2EE tutorial and JSP1.2 spec.
    As far as I read, it seems to me that "jsp:useBean" is a way of creating a bean object.
    <jsp:useBean id="local" scope="application" class="Mylocales">
    If I put the class file in the import statement, can I create the object in the scriptlet
    <% Mylocales local = new Mylocales(); %>
    and set/get properties by calling
    local.setName(); // assume these methods are in the class
    local.getName();
    without using "jsp:setProperty" and "jsp:getProperty".In this way, isn't it a redundancy to have "jsp:useBean" in JSP spec? We can always create any kind of objects in the scriptlets.
    Since "jsp:useBean" has been there for years, I believe something must be wrong with my rationale. However, both the spec and the tutorial couldn't answer this question. Can anyone clear it up to me?
    Thx in advance.
    Kevin

    There's nothing wrong with your rationale; useBean IS a redundant tag, but it does provide some compact functionality without having to write extra code.
    http://java.sun.com/products/jsp/tags/11/syntaxref1115.html covers the syntax of this tag; one advantage of using this tag is the 'scope' attribute, that allows you to define, at object creation, just how long the object will be around. You can limit an object's scope to the page that declared it, or allow it to be accessed by any page that shares the same session, or request, or application.
    I do believe that the main point of this tag comes in at the design level; one of the strongest reasons to use JSPs at all is to separate out the application logic from the page presentation. This means that anyone who can use HTML should be able to maintain the JSP pages in the application. Instead of having to teach a non-programmer a little bit of code, just demonstrate the use of a single tag that can be reused throughout the application. The logical extension of this idea is the tag library.
    Myself, I mix and match as needed, but there are never more than a few lines of scriptlet code in my JSP pages. If there's more code than HTML in my JSP page, I'll go ahead and use a servlet instead.
    Anyway, I guess my point is that JSP pages are flexible, you can pick the functionality that you want to use, and the useBean tag isn't quite superfluous.

  • JSP useBean and Tomcat NoClassDefFoundError

    Hi,
    I have a webapp on tomcat whose structure is like this
    /tomcat
    --/webapps
    ----/mywebappname
    ------/WEB-INF
    --------/classes
    ----------MyBean.java
    When I use useBean class="MyBean" I get a NoClassDefFoundError for this particular class.
    I suspect this is some kind of classpath issue but do not know how to fix it. Help appreciated.

    place u'r class file in <tomcat-root>/classes folder.
    if there's no such folder ,u'll have to create it.

  • jsp: useBean.. and c: coding

    I am trying to understand this coding.
    1. What does the <jsp: useBean .. class="coreservlets.ShoppingCart"> mean? Are we bringing in the content of the ShoppingCart class?
    If we use <% import="coreserlets.*"> at the top of JSP, wouldn't this work to apply all the class in the application?
    2.What is the <c:> coding? I have never seen this before (I am pretty new with Java). Is this new version of Java?
    Thanks.
    Here is coding sample.
    <jsp:useBean id="cart" class="coreservlets.ShoppingCart" scope="session"/>
    <c:choose>
      <c:when test="${empty cart.itemsOrdered}">
        <h2><i>No items in your cart...</i></h2>
      </c:when>
      <c:otherwise>
        <table border=1 align="center">
        <tr bgcolor="#FFAD00">
          <th>Item ID</th>
          <th>Description</th>
          <th>Unit Cost</th>
          <th>Number</th>
          <th>Total Cost</th>
        </tr>
        <c:forEach var="item" items="${cart.itemsOrdered}">
           <tr>
             <td><c:out value="${item.itemID}"/></td>
             <td><c:out value="${item.shortDescription}"/></td>
             <td><fmt:formatNumber value="${item.unitCost}" type="currency"/>        
           </tr>
        </c:forEach>
        </table>
      </c:otherwise>
    </c:choose>

    I am trying to understand this coding.
    1. What does the <jsp: useBean ..
    class="coreservlets.ShoppingCart"> mean? Are we
    bringing in the content of the ShoppingCart class?You're telling the JVM that you're going to use an instance of that class.
    >
    If we use <% import="coreserlets.*"> at the top of
    JSP, wouldn't this work to apply all the class in the
    application?No, that's not what import does.
    2.What is the <c:> coding? I have never seen this
    before (I am pretty new with Java). Is this new
    version of Java?It's the JSP Standard Tag Library, or JSTL. It has core tags <c>, xml tags <xml>, formatting tags <format>, and SQL tags <sql>
    <jsp:useBean id="cart"
    class="coreservlets.ShoppingCart" scope="session"/>Looks like there's a ShoppingCart object in session scope.
    >
    Check to see if the shopping cart has items.
    c:choose>If no items, say so.
    >
    <c:when test="${empty cart.itemsOrdered}">
    <h2><i>No items in your cart...</i></h2>
    /c:when>If there are items, display them in a table.
    >
    <c:otherwise>
    <table border=1 align="center">
    <tr bgcolor="#FFAD00">
    <th>Item ID</th>
    <th>Description</th>
    <th>Unit Cost</th>
    <th>Number</th>
    <th>Total Cost</th>
    /tr>
    <c:forEach var="item"
    items="${cart.itemsOrdered}">
    <tr>
    <td><c:out value="${item.itemID}"/></td>
    <td><c:out
    value="${item.shortDescription}"/></td>
    <td><fmt:formatNumber
    value="${item.unitCost}" type="currency"/>
    </tr>
    c:forEach>
    </table>
    c:otherwise>
    </c:choose>
    If you're new to Java, best to learn the base language before tackling JSPs.
    %

  • Jsp:useBean

    I really shouldn't be trying to use JSP any more ...
    I have been having problems using JavaBeans in JSP pages now - every time a problem is solved, that other little thing that always wanted a go at annoying me arrives ...
    The code is:
    <jsp:useBean id="pollResult" scope="application" class="com.ora.jsp.beans.poll.PollBean" />Because another JSP page I created (using JavaBeans) worked, using a JavaBean from the directory com.ora.jsp.beans.userinfo.UserInfoBean, I assumed that THIS would work - but it didn't! The error was:
    org.apache.jasper.JasperException: /calculate.jsp(11,2) According to TLD or attribute directive in tag file, attribute test does not accept any expressionsAnother problem, is there a solution?
    Sincerely, I'm sorry to plague everyone out there with all my problems - maybe I should give up and become a potato farmer instead ...

    Hi
    My Calculate.jsp looks like this:
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <jsp:useBean id="pollResult" scope="application"
      class="com.ora.jsp.beans.poll.PollBean" />
    <jsp:useBean id="answer" class="com.ora.jsp.beans.poll.AnswerBean" >
      <jsp:setProperty name="answer" property="*" />
    </jsp:useBean>
    <c:choose>
      <c:when test="${answer.valid}" >
        <c:set target="${pollResult}" property="answer"
          value="${answer}" />
        <jsp:forward page="result.jsp" />
      </c:when>
      <c:otherwise>
        <jsp:forward page="poll.jsp" />
      </c:otherwise>
    </c:choose>I am using JSTL 1.1.

  • HELP: jsp:useBean not "working"

    I have written a JSP that utilizes some JavaBeans. With one, I do something similar to the following:
    <jsp:useBean id="BeanA" class="mypackage.myFirstBean" />
    That statement executes just fine, as the debug HTML statement that follows is printed using <c:out>.
    Then I follow that with something nearly identical:
    <jsp:useBean id="BeanB" class="mypackage.mySecondBean" />
    The debug statement after this second <jsp:useBean> call is not executed.
    The two beans have no-argument constructors and are in the same package, and both are found in the right hierarchy under WEB-INF/classes inside my WAR file. Also, both are named properly in the JSP. The only difference is that one "executes," and the other does not. I don't even get to call <c:set> on them to actually make them do some work!
    Any insight is appreciated. Let me know if there is anything else I can provide.
    Thanks for your help, and Happy New Year!

    The symptom you described is certainly curious.
    Can you put the second "useBean" line before the first one? Then please tell us if it "executes".

  • Jsp:useBean gives cannot be resolved to a type in Tomcat

    Hi, I am using Tomcat 5.5
    I have a simple JavaBean for test purposes :
    import java.io.Serializable;
        public class testBean implements Serializable {
            int number;
            public testBean() {
            public int getNumber() {
                return number;
            public void setNumber(int newValue) {
                number = newValue;
        }In a file called testBean.java
    I have successfuly compiled it and put the class file the WEB-INF/classes directory.
    I have the following JSP page :
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <jsp:useBean id="pub" scope="session" class="testBean" />
    <jsp:setProperty name="pub" property="number" value="1" />
    <html>
    <head>
    </head>
    <body>
    <jsp:getProperty name="pub" property="number" />
    </body>
    </html>When I open this jsp page I get the following error:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 2 in the jsp file: /test.jsp
    Generated servlet error:
    testBean cannot be resolved to a typeThis example is pretty minimal and I don't understand why it doesn't work. The error seems to be coming from the first JSP statement.
    Any help would be greatly appreciated.
    Thanks in advance.

    1. Put your bean class in a package.
    package test;
    import...........2. Put the .class file in web-inf/classes/test/testBean.class
    3. Specify the fully qualified name of the class in the useBean declaration.
    <jsp:useBean class="test.testBean" .../>Note: You'd be better off following the java bean naming conventions. Specifically your class name should be TestBean (first letter caps).
    ram.

  • UseBean & NoClassDefFoundError

    Hey
    OK. I am relatively new to JSP.
    So far I have installed Jakarta Tomcat on my PC. At the moment I am just throwing together a few simple bits of code so I can understand how it works.
    First of all I used the following code in file test.jsp located in jakarta-tomcat-3.3/webapps/ROOT .
    <%@ page import="java.util.*" %>
    <HTML>
    <BODY>
    <%!
    Date theDate = new Date();
    Date getDate()
    System.out.println( "In getDate() method" );
    return theDate;
    %>
    Hello! The time is now <%= getDate() %>
    </BODY>
    </HTML>
    This worked fine. However as my project progresses I would like to move the actual workings of the java out onto seperate java classes. I understand this involves the use of java beans. So there fore I used the following java class and .jsp file. I compiled the java and it gave me the error NoClassDefFoundError. I think its because I have not located the java class in the correct location. I have tried other places but it just doesn't work. Does anyone know where I should put my java class.
    This is the JSP file:
    <%@ page import="java.util.*" %>
    <html>
    <body bgcolor="white">
    <jsp:useBean id="date" class="test.test" scope="session"/>
    Hello! The time is now <jsp:getProperty name="date" property="getDate" />
    </body>
    </html>
    located in the same directory as above and again called test.jsp.
    And this is my java class located in:
    jakarta-tomcat-3.3\webapps\ROOT\WEB-INF\classes\test
    package dates;
    import java.text.DateFormat;
    import java.util.*;
         public class test{
              public Date getDate(){
                   Date theDate = new Date();
                   theDate = getDate();
                   return theDate;
    Please help.
    Cheers.
    Colm

    Looking at your original post, you say that you have the class file in jakarta-tomcat-3.3\webapps\ROOT\WEB-INF\classes\test. If your class is in the package "test", and you are running the JSP in the ROOT web application, that should be OK.
    The other issue is that your bean property needs to be gotten by following the bean patterns, so the "property=" should be "property=date" in order to invoke the getDate() method.
    So building a java class:
    * dateTest.java
    * Created on November 25, 2002, 12:11 PM
    package com.quovera;
    import java.util.Date;
    * @author  rweaver
    public class dateTest extends Object implements java.io.Serializable {
        private Date dateProperty = null;
        public Date getDateProperty() {
            return new Date();
    }Placing the code in classes/com/quovera, and executing the JSP:
    <%@page contentType="text/html"%>
    <html>
    <head><title>JSP Page</title></head>
    <body>
    <jsp:useBean id="beanInstanceName" scope="session" class="com.quovera.dateTest" />
    <h1> Get property dateProperty from com.quovera.dateTest
    <jsp:getProperty name="beanInstanceName"  property="dateProperty" /></h1>
    </body>
    </html>Prints out the date from the bean's dateProperty (which is actually just a new Date object):
    Get property dateProperty from com.quovera.dateTest Mon Nov 25 12:30:38 PST 2002

  • Jsp:useBean vs page import in JSP

    Hi,
    What is the difference between jsp:useBean vs page import in JSP?
    By using page import also I can call the method of the class, apart from jsp:useBean does have scope associated with it. I don't think there is any change between both the 2. Yes by using jsp:useBean we can set the property and get the property as well.
    Is there any major differences between the 2 and when to use which ? Please clarify.
    Thanks.

    797836 wrote:
    Hi,
    What is the difference between jsp:useBean vs page import in JSP?
    By using page import also I can call the method of the class, apart from jsp:useBean does have scope associated with it. I don't think there is any change between both the 2. Yes by using jsp:useBean we can set the property and get the property as well.
    Is there any major differences between the 2 and when to use which ? Please clarify.
    Thanks.Yes there is a difference.
    If you use import, then you have to create/use the reference object to use the class methods. And you can't define the scopes like session, page .. etc. Apart from this you will be using scriptlets <% %>.
    if you are using jsp:useBean , then you can skip the above activities. useBean takes care of it.
    or you can say jsp has provided a utility to access the beans without creating its object or using scriptlets.

Maybe you are looking for

  • How to change the font color of a particular row in af:table

    I have a <af:table> bounded to a readonly ViewObject and this view object is a collection of an sql query. Now when this table is rendered i want font color of the specific attributes to be changed based on certain logic. Eg. If my af:table is showin

  • Report not running through Forms menu

    Hi Gurus, In our reports we have used Query PL/SQL to reference cursor. When it is compiled and an executable 'rep' file is created, which when called through froms menu generates following error and aborts the report. REP-1401:'qr_1refcurds': Fatal

  • Finding photos after upgrade to 7.1.1 by location on a map

    I have updated my ipad to 7.1.1 but cannot find my photos by location on the map. I have followed the ipad manual where it days tap the > when viewing in years but I have no > icon. All my photos appeared on a map prior to upgrade - can anyone help?

  • Music player on 3500c

    It works fine, except for two things: 1) it doesn't support UTF-8 encoded ID3 tags 2) creating a playlist is major pain I consider point 1) to be a bug. The phone itself displays all filenames correctly, including those which are UTF-8 encoded. Howev

  • New 'Core Duo 2 Extreme'

    Hi All -- Not sure if this post is allowed - delete if necess. - it looks like there will be another speed upgrade to Intel Macs - not sure about MBP. Intel 'Core Duo 2 Extreme' chips are on their way. The next upgrade will have MBP jump into your la