Unable to use jsp:useBean tag

when I use
<jsp:useBean id="addressBean" class="AddressBean" scope="session"/>
I get the following error
Exception Details: org.apache.jasper.JasperException
Unable to compile class for JSP No Java compiler was found to compile the generated source for the JSP. This can usually be solved by copying manually $JAVA_HOME/lib/tools.jar from the JDK to the common/lib directory of the Tomcat server, followed by a Tomcat restart. If using an alternate Java compiler, please check its installation and access path.
So my question is how to use the <jsp:useBean> tag in JSC

Please see my message How to set developer's mode for oracle jsp engine.
As a very early warning of the future, this way of setting configuration paramemter in web.xml for oracle jsp engine will be deprecated in the next major version of oc4j and desupported probably later on. Yes, it is still supported in 10.1.3 and the next major version, though.

Similar Messages

  • 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.

  • Using variables in a jsp:useBean tag

    I was wondeing if it is possible in any way to use variables in a jsp:useBean tag. Here is an example of what I am trying to do.
    <%
    String beanType = request.getParameter( "bean" );
    if( beanType.equals( "Bean1" ) ) {
    beanClass = "com.myCompany.Bean1";
    } else {
    beanClass = "com.myCompany.Bean2";
    %>
    <jsp:useBean name="<%= beanType %>" class="<%= beanClass %>"/>
    I also tried using this approach
    <%
    if( beanType.equals( "Bean1" ) ) {
    %>
    <jsp:useBean id="bean" class="com.myCompany.Bean1"/>
    <%
    } else if( beanType.equals( "Bean2" ) ) {
    %>
    <jsp:useBean id="bean" class="com.myCompany.Bean2"/>
    <%
    %>
    Neither approach seems to work. Is there any way around this problem?
    Thanks,
    Marcus.

    Hi,
    check:
    http://forum.java.sun.com/thread.jsp?forum=45&thread=398998&tstart=75&trange=15

  • How can i load A gui JTable bean through jsp:useBean tag in a jsp page

    Hi,
    i am chiranjit , i am in a jsp project . i am desparately looking a solution for below stated problem:
    i want to make a jsp page for master entry , that why i want to load a GUI Java bean in my jsp page.This GUI Bean contaning a JTable in which allow grid type data entry in the jsp page. But i am unable load that bean in the jsp page through jsp:useBean tag in my page.So if you have any solution then send in the forum as early as possible.
    Thank you
    chiranjit

    No can do. JSPs can only output plain HTML (and javascript...) They are not used like normal Java classes.
    If you need a complex GUI then you might use an Applet instead. If you want to use a JSP then you are stuck using normal HTML components, like <table> <form...> <input type="text"> etc...

  • Calling an inner class in a jsp:usebean tag

    Hi everybody !
    Here's my problem : working in my project on multiple pages, I'm using inner classes/beans to limitate my '.java' files but I'm stuck when calling that 'inner-bean' in my jsp:usebean tag.
    First, I tried to declare in the class parameter : 'class="MyPrincipalBean.theInnerBean" but jsp returns me a 'not found' message.
    I tried an other issue with this :
    'class="MyPrincipalBean$theInnerBean" but I encountered a 'Attempt to use a bean type without a void constructor in jsp:useBean tag (JSP 1.1 specification, 2.13.1)'. Since I can't find that specification, I'm sending an SOS.
    Am I on the good way ? If somebody as encoutered that sort of problem, it would be very kind of you to help me.
    Thanks for your help !
    [email protected]

    Thanks for your help!
    I must recognize that my explainations weren't really precise.
    My principal bean owns a table of my inner-class type :
    public class FirstBean extends EntityBean {
    private SecondBean[] tabSB;
    public SecondBean[] getTabSB() {...}
    public void setTabSB(SecondBean[] p_tabSB) {...}
    public class SecondBean {...}
    So I can call a specific bean from the tab in my Servlet for another page.
    But I think I have the solution and I need your advise :
    I tried this :
    <jsp:useBean id="FirstBean" class="<...>.FirstBean" scope="session" />
    <jsp:useBean id="SecBean" beanName="<...>.FirstBean$SecondBean" type="<...>.FirstBean$SecondBean" scope="request" />
    And would you believe it ? It seems to work ! But I have to test this farther to be sure. What do you think of it ?

  • Why do you use jsp:useBean?

    Hi,
    I have one "simple" question :) : When or why do you are using <jsp:useBean>,<jsp:getProperty> and <jsp:setProperty>?
    For practice, I am creating a form, sends the data to a servlet and the servlet "packs" the parameter into a Bean and put this Bean into a request- or SessionScope. After that, my resultpage could access the property name of the bean with (for instance) sessionScope.Bean.name.
    I wanted to use the 3 tags above first, but after I realised the way I describes above I didn't have to use these three jsp tags. Therefore I wonder when you are using these tags.
    Thnx
    Alex

    hi
    The component model for JSP technology is based on JavaBeans component architecture. JavaBeans components are nothing but Java objects which follow a well-defined design/naming pattern: the bean encapsulates its properties by declaring them private and provides public accessor (getter/setter) methods for reading and modifying their values.
    Before you can access a bean within a JSP page, it is necessary to identify the bean and obtain a reference to it. The <jsp:useBean> tag tries to obtain a reference to an existing instance using the specified id and scope, as the bean may have been previously created and placed into the session or application scope from within a different JSP page. The bean is newly instantiated using the Java class name specified through the class attribute only if a reference was not obtained from the specified scope. Consider the tag:
    sun site

  • Need help with the jsp:useBean tag

    Dear Fellow Java/JSP developers:
    I am trying to use the <jsp:useBean> tag in a jsp that displays the values from a javaBean that gets populated by another class.
    <%@ page contentType="text/html" pageEncoding="UTF-8"%>
    <%@ page import = "java.util.ArrayList"%>
    <%@ page import = "java.util.Iterator"%>
    <%@ page import = "salattimes.CalendarParse" %>
    <%@ page import = "salattimes.Salat" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
        </head>
        <body>
            <jsp:useBean id="test" scope="session" class="calendar.Time" />
            <% CalendarParse sTime = new CalendarParse();
                Time mytime = sTime.runExample();%>
            <%=mytime.getA() %>
            <%=mytime.getB() %>
            <%=mytime.getC() %>
            <%=mytime.getD() %>
            <%=mytime.getE() %>
        </body>
    </html>However, up to now, I am only able to display the values on my JSP page using the scriptlet
    <% CalendarParse sTime = new CalendarParse();
                Time mytime = sTime.runExample();%> to declare and create the object (the method call sTime.runExample(); populates the fields in the Java Bean), and the expressions:
    <%=mytime.getA() %>
             <%=mytime.getB() %>
             <%=mytime.getC() %>
             <%=mytime.getD() %>
             <%=mytime.getE() %>to present the values on the screen. What I would like to do is assign the object that I create to a javaBean reference declared in a <jsp:useBean> tag as follows:
    <jsp:useBean id="test" scope="session" class="calendar.Time" />
            <% CalendarParse sTime = new CalendarParse();
                test = sTime.runExample();%>and then present the values stored in the bean to the JSP page as follows:
    <jsp:getProperty name="test" property="a" />
            <jsp:getProperty name="test" property="b" />
            <jsp:getProperty name="test" property="c" />
            <jsp:getProperty name="test" property="d" />
            <jsp:getProperty name="test" property="e" />
            <jsp:getProperty name="test" property="f" />Is this possible? When I try the above, I get "null" as my output on the screen. When I try the first approach listed above, I get the values I am looking for. Is there a way to accomplish this using the <jsp:useBean> approach?
    Thanks to all those who reply.
    Sincerely;
    Fayyaz

    The code:
    <jsp:useBean id="calendar" class="calendar.CalendarParse" scope="session"/>
    <c:set var="time" value="${calendar.time}"/>Would be roughly equivalant to:
    calendar.CalendarParse calendar = new calendar.CalendarParse();
    Object time = calendar.getTime();I assumed that the CalendarParse object was in the calendar package because that was were your Time class was (when you used <jsp:useBean id="test" scope="session" class="calendar.Time" />"), but when I look back at your original post I see I was wrong and the use of calendar as both the incorrect package and the variable name was confusing. To make the code more similar to your original post the code should have read:
    <jsp:useBean id="sTime" class="salattimes.CalendarParse"/>
    <c:set var="myTime" value="${sTime.time}" scope="session"/>
    ${myTime.a}
    ${myTime.b}
    ${myTime.c}
    etc...Here is an explanation of the parts:
             /* name of the variable */  /* fully qualified class name, package.className */
    <jsp:useBean id="sTime"           class="salattimes.CalendarParse"/>
      /* name of the new object from bean */  /* source of object, variable.property */    /* Scope of new object */
    <c:set var="myTime"              value="${sTime.time}"             scope="session"/>
    /* data to display variable.property */
    ${myTime.a}Where a 'property' in a bean is defined as a method in the form of getProperty(). So the 'time' property is getTime() and the 'a' property is getA().

  • How to use JSP custom tag lib in PAR file?

    Hi All,
    I am trying to customize mastheaderpar file. For that I have downloaded relevant par file and making the changes accordingly.
    As part of the changes I would require to use JSP custom tag library in my par file.
    I have the TLD file and relevant classes in the jar file. I would like to know where and what kind of modifications have to be done to use the jsp custom tag library.
    I tried modifying some things in portalapp.xml but was not successful.
    Please help me on how to proceed with this? It would be great if you can provide the xml entry to use this tag library
    Thanks
    Santhosh

    Hi Johny,
    Thanks for the reply. Actually I am able to change colors etc. with out any problem.
    My requirement is to use XMLTaglib in mastheader par file. This tag lib is from apache tomcat. I have the relevant TLD and class files. I copied TLD file into taglib dir of portal-inf and class file in src api.
    And I have added the following line in portalapp.xml under component-profile section of default
    <property name="tlxtag" value="/SERVICE/Newmastheader/taglib/taglibs-xtags.tld">
    Is this the right way to use tag lib? Actually before adding this line I used to get the error saying "Error parsing taglib", but now the error does not occur and I am getting new error. This is an exception in one of the taglib classes.
    Could any one provide me some inputs on how to check this error?
    Thanks
    Santhosh

  • Hi, I have quick question about use of USEBEAN tag in SP2. When I specify a scope of SESSION for the java bean, it does not keep the values that I set for variable in the bean persistent.Thanks,Sonny

     

    Make sure that your bean is implementing the serializable interface and that
    you are accessing the bean from the session with the same name.
    Bryan
    "Sandeep Suri" <[email protected]> wrote in message
    news:[email protected]..
    Hi, I have quick question about use of USEBEAN tag in SP2. When I
    specify a scope of SESSION for the java bean, it does not keep the
    values that I set for variable in the bean persistent.Thanks,Sonny
    Try our New Web Based Forum at http://softwareforum.sun.com
    Includes Access to our Product Knowledge Base!

  • RE: Strange behavior with initialization in  jsp:useBean tags? (wl 5.1 sp6/8 on sol 8)

    Hello,
              I am trying to initialize a session scope bean using the <jsp:useBean ..>
              Init Code </jsp:useBean>
              syntax. This works fine for the initial page load -- the information in the
              bean
              is there and everything looks fine. However, when I do a reload of the page,
              then all of the information on the bean disappears. The setter methods of
              the
              bean are not getting invoked, nor are the beans constructers.
              However, one thing that I do notice is that after I modify the page, then
              in the WL output I see constructors called for the beans that I am using,
              then I see the compilation directive for the changed JSP. It almost looks
              like WL is creating some beans with the default constructors, then
              when my page loads, it creates some other beans using the initialization
              code.
              After a reload, it then stops using the beans that have been initialized and
              then uses those that have been created with the normal default constructors.
              This is on WL5.1 sp6 on Solaris 8. I also tried with sp8 but there
              was no difference in behavior.
              If anyone has any pointers I would appreciate it. I had thought that 5.1
              was up to the 1.1 JSP spec, but maybe I was mistaken. FWIW,
              here is the init code I am using:
              <jsp:useBean id="myFoo" scope="session" class="com.foo">
              FooDAO dao = new FooDAO();
              ArrayList listOfFoos = dao.getAllFoos(1);
              myFoo = (Foo) listOfFoos.get(0));
              </jsp:useBean>
              This snippet is being statically included with a <%@ include file %>
              by the page that I am invoking.
              Regards,
              Nathan
              [email protected]
              

    .... add the session binding interface to assist in your debugging. Post
              your results. It sounds like you are losing the session, but who knows ...
              Peace,
              Cameron Purdy
              Tangosol, Inc.
              http://www.tangosol.com
              +1.617.623.5782
              WebLogic Consulting Available
              "Nathan Cuka" <[email protected]> wrote in message
              news:[email protected]...
              > Hello,
              >
              > I am trying to initialize a session scope bean using the <jsp:useBean ..>
              > Init Code </jsp:useBean>
              > syntax. This works fine for the initial page load -- the information in
              the
              > bean
              > is there and everything looks fine. However, when I do a reload of the
              page,
              > then all of the information on the bean disappears. The setter methods of
              > the
              > bean are not getting invoked, nor are the beans constructers.
              >
              > However, one thing that I do notice is that after I modify the page, then
              > in the WL output I see constructors called for the beans that I am using,
              > then I see the compilation directive for the changed JSP. It almost looks
              > like WL is creating some beans with the default constructors, then
              > when my page loads, it creates some other beans using the initialization
              > code.
              > After a reload, it then stops using the beans that have been initialized
              and
              > then uses those that have been created with the normal default
              constructors.
              >
              > This is on WL5.1 sp6 on Solaris 8. I also tried with sp8 but there
              > was no difference in behavior.
              >
              > If anyone has any pointers I would appreciate it. I had thought that 5.1
              > was up to the 1.1 JSP spec, but maybe I was mistaken. FWIW,
              > here is the init code I am using:
              >
              > <jsp:useBean id="myFoo" scope="session" class="com.foo">
              > FooDAO dao = new FooDAO();
              > ArrayList listOfFoos = dao.getAllFoos(1);
              > myFoo = (Foo) listOfFoos.get(0));
              > </jsp:useBean>
              >
              > This snippet is being statically included with a <%@ include file %>
              > by the page that I am invoking.
              >
              > Regards,
              >
              > Nathan
              > [email protected]
              >
              >
              

  • How to Implement jsp:useBean tags

    Hi,
    I hav a trouble with using the Tag jsp:useBean
    Actually im using Tomcat4.1 webserver'
    I created a java file and compiled that
    When i included that class file,The Jsp Compiler seeming me a error that the Required class in not found
    Actually wht my problem is that i cannot find out the storage locations for the corresponding files
    I know where to save the jsp
    but i need to know where to put the class file and its source.Bcz that one which i want to use in that tag{<jsp:useBean>}
    I want to know what should i do
    With Regards
    Ganesh B

    Beans are regular Java classes that follow particular conventions defined by the JavaBean's specification. The don't extend from a particular class, they aren't packaged in a particular package, and - germane to the question - they aren't located in a special place on the server. The classes which are loaded into the JSP by the <jsp:useBean> construct are located in the same location as other classes in a web application. They are located in the classes directory of the WEB-INF directory of the web application directory itself. Or, if you bundle your classes into a jar file, then the jar file will be located in the lib directory of the WEB-INF directory. In either case, remember to use packages for your classes including your beans.

  • JSP - useBean tag works only for first request

     

    hey why donnu change the scope to PAGE, give a try.........
              Vishal Vishnoi wrote:
              > Using Weblogic 5.1 I am trying to work with a simple example of a JSP
              > page which has got a usebean tag. The tag is
              >
              > <jsp:useBean id="resourceTypes" type="java.util.ArrayList"
              > scope="request" />
              >
              > * This works only the first time I load the page.
              >
              > If I try to load the page again. I get the following error
              >
              > javax.servlet.ServletException: Could not find bean 'resourceTypes',
              > type 'java.
              > util.ArrayList' in scope
              >
              > --Vishal
              

  • Why use jsp:useBean?

    I got the below sample code in sun document. Here bookId is passed as a parameter in cart.remove method and sql query. I want to know why the statement "<jsp:useBean id="bookId" type="java.lang.String" /> " is used.
    <c:set var="bookId" value="${param.Remove}"/>
    <jsp:useBean id="bookId" type="java.lang.String" />
    <% cart.remove(bookId); %>
    <sql:query var="books"
    dataSource="${applicationScope.bookDS}">
    select * from PUBLIC.books where id = ?
    <sql:param value="${bookId}" />
    </sql:query>
    thanks,
    Vinodh

    The useBean tag has a side effect of creating a local scriptlet variable with the id "bookId"
    This variable is then used on the next line in the scriptlet code.
    In effect, it is executing the following code
    <c:set var="bookId" value="${param.Remove}"/>
    <%
    String bookId = (String)pageContext.findAttribute("bookId");
    cart.remove(bookId); %>which if you think about it, you could get rid of the <c:set> and have the scriptlet code access the variable directly.
    <%
    String bookId = request.getParameter("Remove");
    cart.remove(bookId); %>Mixing scriptlet and JSTL code in this fashion gets confusing.
    The scriptlet code here is part of the 1% of code that can't be replaced directly by JSTL (but could be replaced by a custom function/tag)
    However it more probably belongs in a servlet/bean.

  • Question about the jsp:useBean tag

    Hi, I'm a relative newcomer to jsp, but the following piece of javascript code has me very confused:
    <%@ page import="com.jinsoft.bank.web.*" %>
    <jsp:useBean id="account" class="AccountBean" />
    This will result in java.lang.ClassNotFoundException, and it complains that AccountBean cannot be found.
    However, when I fully qualify the class, it works:
    <%@ page import="com.jinsoft.bank.web.*" %>
    <jsp:useBean id="account" class="com.jinsoft.bank.web.AccountBean" />
    Am I doing something wrong?
    Isn't the import tag supposed to help?
    Thanks for any help!

    Hi Kim
    I'm really interested in the particular error that you are generating. I tried this out using Tomcat 3.2.3 and it doesn't seem to be a problem. What application Server are you using?
    Another way to find out if the problem is with the Application Server is to check the .java file that is created out of the jsp page before it is compiled. Individual Application servers have different ways of storing this intermediate .java file but most of them keep it if the compilation does not succeed.
    You may possibly have to file a bug if everything else checks out fine. Another point, are you able to import the same bean into a Servlet and use it there?
    Keep us posted.
    Good Luck!
    Eshwar Rao
    Developer Technical Support
    Sun microsystems inc
    http://www.sun.com/developers/support

  • Populating combobox in jsp page from javabean using jsp:getProperty tag

    hi,
    i am new to jsp, so i don;t know how to populate a combobox in jsp page with productid attribute from a javabean called Bid . i want to have a code to automatically populating combobox using the attribute value from javabean.
    please reply me.
    <jsp:useBean id="bidpageid" class="RFPSOFTWARE.Bid" scope="session" />
    <jsp:setProperty name="bidpageid" property="*"/>
      <table  width="50%" align="center" border="0">
       <tr>
        <td  width="30%" align="left"><h4><b><label>Date (dd/mm/yyyy) </label></b></h4> </td>
        <td><input type="text" name="date" size="11" maxlength="10" readonly="readonly" value="<jsp:getProperty name="bidpageid" property="date"/>"  > </td>
      </tr>
      <tr> <td > </td> </tr>
      <tr>
        <td  width="30%" align="left"><h4><b><label>ProductId </label></b></h4> </td>
        <td><select name="productid" tabindex="1" size="1" >
          <option  value="<jsp:getProperty name=bidpageid" />Sachin</option>
          <option value="Hello">Vishal</option>
        </select></td>
      </tr>  and the javabean for Bid is as follow :
    import java.util.Date;
    import RFPSOFTWARE.Product;
    public class Bid{
    private Product product;
    private Integer bid_id;
    private String description;
    private Date date= new Date();
    public Integer getBid_id() {
    return bid_id;
    public Date getDate() {
    return date;
    public String getDescription() {
    return description;
    public Product getProduct() {
    return product;
    public void setBid_id(Integer bid_id) {
    this.bid_id = bid_id;
    public void setDate(Date date) {
    this.date = date;
    public void setDescription(String description) {
    this.description = description;
    public void setProduct(Product product) {
    this.product = product;
    }

    No Sir,
    I think I did not explained clearly.what I try to say is I dont want to use JSTL.I am using only Scriptlets only.I can able to receive the values from the database to the resultset.But I could not populate it in Combobox.
    My code is :
    <tr>
    <td width="22%"><font color="#000000"><strong>Assign To Engineer</strong></font></td>          
    <td width="78%">
         <select NAME="Name" size="1">
    <option><%=Username%></option>
    </select> </td>
    </tr>
    in HTML
    and in Scriptlets:
    ps1 = con.prepareStatement
              ("SELECT Username FROM Users");
              rs2=ps1.executeQuery();
              System.out.println("SECOND Succesfully Executed");
              while(rs2.next())
                   System.out.println("Coming inside rs2.next loop to process");
                   Username=rs2.getString("Username");
                   System.out.println("Success");
                   System.out.println("The value retrieved from UsersTable Username is:"+Username);
    In the server(Jboss console) I can able to display the username but I could not populate it in the Combobox .
    Can you now suggest some changes in my code,Please..
    Thanks a lot
    With kind Regds
    Satheesh

Maybe you are looking for