Using two beans in a jsp

what's the syntax for declaring two different beans in a JSP ?
can we have two <jsp:useBean...> tags ??
<jsp:useBean id="view" type="org.ab.GenericView" scope="request"></jsp:useBean>

You can have include many <jsp:useBean> tags. Use different id/scope combinations.
e.g.
<jsp:useBean id="view" type="org.ab.GenericView" scope="request"></jsp:useBean>
<jsp:useBean id="anotherview" type="some class" scope="request"></jsp:useBean>
<jsp:useBean id="thirdid" type="some class" scope="session"></jsp:useBean>

Similar Messages

  • Defining the path for the use of beans in a JSP

              Hello,
              I would like to use a bean in a JSP file, via the <jsp:usebean> directive.
              I didn't find any property (weblogic property) which could define the path
              to the directory of my beans classes.
              So :
              1) i have put the path of this directory in the weblogic classpath in the weblogic
              start script.
              2) i made the same with the java classpath.
              Both solutions don't work at all.
              Any suggestion would be appreciated.
              Thanks in advance.
              

              We use the \weblogic\myserver\serverclasses for beans..
              of course we pack beans into jar files, and these jar files are included into
              the wls classpath..
              "Sylvain R." <[email protected]> wrote:
              >
              >Hello,
              >I would like to use a bean in a JSP file, via the <jsp:usebean> directive.
              >I didn't find any property (weblogic property) which could define the
              >path
              > to the directory of my beans classes.
              >So :
              >1) i have put the path of this directory in the weblogic classpath in
              >the weblogic
              >start script.
              >2) i made the same with the java classpath.
              >
              >Both solutions don't work at all.
              >
              >Any suggestion would be appreciated.
              >Thanks in advance.
              >
              

  • Importing Bean Class to JSP

    Hi here's my bean
    import java.util.*;
    public class leaveChange extends Object implements java.io.Serializable
         String Name;
         String Grade;
         String Pattern;
         int numDays;
         Date startDate;
         Date endDate;
    Now to use this bean in my JSP page what do I do ?
    I tried
    <%@ page import="leaveChange"%>
    but got following error
    [javac] C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\Devannualleave\newDev\advancedOptions_jsp.java:8: '.' expected
    [javac] import leaveChange;
    [javac] ^
    [javac] 1 error
    Thanks in advance

    Update
    changed Bean class to
    package test;
    import java.util.*;
    public class leaveChange extends Object implements java.io.Serializable
         String Name;
         String Grade;
         String Pattern;
         int numDays;
         Date startDate;
         Date endDate;
    JSP File
    <%@ page import="test.leaveChange" %>
    and have in my WEB-INF/classes/test
    my Bean Class
    but get the following error
    [javac] C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\Devannualleave\newDev\advancedOptions_jsp.java:8: package test does not exist
    [javac] import test.leaveChange;
    [javac] ^
    [javac] 1 error
    Any help ?

  • Impossible to access a bean from a JSP in NES 4.0

    We are trying to use a bean in a JSP using the common tag <jsp:useBean id="... /> in a Netscape Enterprise Server 4.0.
    Always we obtain the same error: "JSP compilation error: java.lang.Exception: JSP parse error (line 43) - Incomplete tag ending of /jsp:useBean". Someone can help us?
    Thanks.

    Check NAS4.0 supports jsp 0.92 specs?
    use this tag...
    <USEBEAN name="..." type="..." lifespan="..." >
    </USEBEAN>

  • Embedding a bean in a jsp  application

    guy's
    i am trying to use a bean in my jsp page ,but i dont know how to deploy my bean with my page ,so please tell me how to deploy my bean with my page step by step.
    thanks
    john

    Put your bean / class into a package :
    WEB-INF/classes/yourPackage/yourClass
    Then in your jsp header
    <jsp:useBean id="yBean" class="yourPackage.yourClass" scope="session">
    To use the bean in jsp
    yBean.getYourMethod();
    Theres loads of stuff in these forums and on google if you get stuck......

  • Insert data into table from JSP page using Entity Beans(EJB 3.0)

    I want to insert data into a database table from JSP page using Entity Beans(EJB 3.0).
    1. I have a table 'FRIENDS', (in Oracle 10g database).
    2. It has two columns, 'NAME' and 'CITY'. Both have datatype strings(varchar2).
    3. Now from a JSP page, having two textfields, 'NAME' and 'CITY', I want to insert data into table 'FRIENDS'.
    4. In between JSP and database is a Entity Bean(EJB 3.0) and a stateless session bean.
    5. I am using JDev as editor.
    Please provide me code ASAP or link with similar example.
    Thank you.
    Anurag

    Hi,
    I am also trying that scenario. So u can
    Post the jsp form data to a Servlet which will act as a Controller.
    In the servlet invoke the business method.
    Similar kind of app is in www.roseindia.net
    Hope this would help u.
    Meanwhile if u get any optimal solution, pls post it.
    Thanks,
    Happy Java Coding.

  • Problem using a bean in JSP on Tomcat 5.0.28

    Hi,
    I'm new to JSP, I've installed Tomcat 5.0.28 and I'm able to run JSP but when I try an asp wich uses a bean it gives me this error, the directory structure is
    testingProject with the first.jsp
    testingProject\WEB-INF\classes\myPackage with the test.class
    the first.asp
    <%@ page import="myPackage.Test" %>
    <html><head><title>Test</title></head>
    <body bgcolor=white>
    <jsp:useBean id="list" class="myPackage.Test"> </jsp:useBean>
    <jsp:getProperty name="list" property="value1" />
    <%=list.value1%>
    <p>
    </body></html>
    the Test.java
    package myPackage;
    public class Test{
    String value1="testinggggggggg";
    public void Test(){
    public String getValue1(){ return value1}
    the error
    thanks in advance
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 6 in the jsp file: /first.jsp
    Generated servlet error:
    C:\Program Files\Apache Group\Tomcat 5.0\work\Catalina\localhost\testingProject\org\apache\jsp\first_jsp.java:60: cannot resolve symbol
    symbol : variable value1
    location: class myPackage.Test
    out.print(list.value1);
    ^
    1 error
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)
         org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:412)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)

    There are two ways of getting info from the bean.
    1) the jsp:getProperty tag, which seems correct in your code
    2) the <%= ... tag. In that case you must write a valid java expression. In your case: list.getValue1()

  • Two managed beans in same jsp page

    Hello
    First this could be a stupid question, but i just can't find a solutions on this problem.
    I wondering that could it be a two managed beans in same jsp page, here is a example:
    index.jsp
    <t:commandLink disabled="#{listBean.currentPage == 1}" id="previous2" type="button" immediate="true" style="font-size:small" action="#{listBean.previousPage}">
    <h:outputText value="Edellinen" id="prev"/>
    </t:commandLink>
    <t:commandLink disabled="#{listBean.currentPage == listBean.totalPages}" id="next2" type="button" immediate="true" style="font-size:small;" action="#{listBean.nextPage}">
    <h:outputText value="Seuraava" id="next"/>
    </t:commandLink>
    then i have a dataTable like this:
    <t:dataTable value="#{customerListBean.customerBeans}"
    binding="#{customerListBean.dataTable}" preserveDataModel="true" style="text-align:left">
    My problem is that when i push a commandLink it doesn't refresh a dataTable. Does anyone know a solution here or is this just a impossible way to do it?
    Thanks for help.

    when i push nextPage (commandLink) it's call action
    and count a new range of dataset and after that it's
    calls a method which is declared on subClass and that
    method get a new data of database on given params.
    and put it on DataTable.
    So listBean is upper class and customerListBean
    extends on ListBeanNo, it doesn't work that way as you expected. You have created two independent instances. They doesn't communicate automatically with each other or so. Just use one CustomerListBean instance and call the inherited methods of ListBean on the #{customerListBean} managed bean instance.

  • Using web beans in JSP

    I would like to know how create a tree using Web Beans that Jdeveloper provides. Using the web object editor I could add two Beans which mapped to JSTree and JSTreeData(in oracle.jdeveloper.jsp.wb package), though I don't know the difference between them. I tried to include Both these beans in the JSP(which appear as tags) but I am unable to render the tree. Let's say I have a parent node (text: row1, url: url1, 3 childs) and 3 child nodes (text: row2..row4, url: url2..url4, each with no childs). How do I write it in the JSP to render it properly
    -Rajeev

    I would like to know how create a tree using Web Beans that Jdeveloper provides. Using the web object editor I could add two Beans which mapped to JSTree and JSTreeData(in oracle.jdeveloper.jsp.wb package), though I don't know the difference between them. I tried to include Both these beans in the JSP(which appear as tags) but I am unable to render the tree. Let's say I have a parent node (text: row1, url: url1, 3 childs) and 3 child nodes (text: row2..row4, url: url2..url4, each with no childs). How do I write it in the JSP to render it properly
    -Rajeev

  • Using java bean with jsp

    hello friends,
    i'm new to jsp. i want to create an html form that accepts username and a value from four radio buttons and display back the entered name and checked radio button's value using java bean.
    i use the <jsp:setProperty id="" property="*"> method. i don't know how to access the radio buttons value from the html.
    also when i use an additional field other than username the jsp page is showing error.
    Please give me the correct method to use java bean with jsp in this circumstance.
    thank you.

    thank you, but i have a problem left. the case is like this.
    i got the jsp and bean worked fine when i have a sinle input text field.
    but when i added a second text field i recieved the following error.
    javax.servlet.ServletException: basket.newbean.getUserPass()Ljava/lang/String;
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
         org.apache.jsp.newform.process_jsp._jspService(process_jsp.java:69)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    where userPass is the new form element. I have made the subsequent chanes in my bean program and jsp file.
    pls hlp.

  • Using session bean in JSP

    Dear All
    I write a BorrowList session bean and tested OK in console mode. I can't use it in the JSP, Dose any body tell me How can I create this bean in the JSP and when should I place the bean classes(Home, Bean and Remote).
    I'm now using the BEA Weblogic 7.0
    I'm appreicate if anybody can help me.
    Best Regards
    YU

    U may be used the code similar to following :
    Context context = new InitialContext.();
    Object obj = (Object)context.lookup("Your JNDI name");
    YourHome home = (YourHome)obj.portableRemoteObject.narrow(obj,
    YourHome.class);
    YourRemote remote = home.create();
    System.out.println("your Business methods : "+remote.businessMethod1());
    Put this code or whatever code used in ur console client in JSP and invoke the businessMethods using remote object.
    I worked with BEAWeblogic 5.1, I think similar case may be there with BEA Weblogic7 also.
    First, make a jar file with ome.Remote and Bean by using the deploymenttool, then compile with ejb compiler, the new Jar is the complete deployable file. Take this file and register in weblogic.properties file that is specify the path of the Jar file in the weblogic.properties file. and put the JSP in public-html directory and start the server. if the bean is deployed successfully, open JSP file in a browser then it will work.... if the bean is not deployed you won't get any result.
    I can say, just placing the initialContext part of code on the JSP and running the JSP. I think, this may helps u...
    Ramana

  • Using BI Bean in JSP

    Hi,
    Can anyone please provider some pointers on using BIBeans in a JSP page. There are few options in my knowledge.
    1)Using BI-Beans API for writing our own JSP tags.
    2)In Jdev(10g) there seems to be some support for Graphs through ADF.
    3)JSP and UIX tags provided BI-Graph beans.
    thanks
    Rahul

    U may be used the code similar to following :
    Context context = new InitialContext.();
    Object obj = (Object)context.lookup("Your JNDI name");
    YourHome home = (YourHome)obj.portableRemoteObject.narrow(obj,
    YourHome.class);
    YourRemote remote = home.create();
    System.out.println("your Business methods : "+remote.businessMethod1());
    Put this code or whatever code used in ur console client in JSP and invoke the businessMethods using remote object.
    I worked with BEAWeblogic 5.1, I think similar case may be there with BEA Weblogic7 also.
    First, make a jar file with ome.Remote and Bean by using the deploymenttool, then compile with ejb compiler, the new Jar is the complete deployable file. Take this file and register in weblogic.properties file that is specify the path of the Jar file in the weblogic.properties file. and put the JSP in public-html directory and start the server. if the bean is deployed successfully, open JSP file in a browser then it will work.... if the bean is not deployed you won't get any result.
    I can say, just placing the initialContext part of code on the JSP and running the JSP. I think, this may helps u...
    Ramana

  • Is it possible to use two diff forms in same jsp/jsf page?

    Hi all,
    My requirement is to submit the form based on selection of radio button.
    since half part needs to be jsp based which is not using any tags etc.
    But i am trying to use some jsf based component which requires to be inside <f:view><h:form> of
    <%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
    <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
    i.e. some <c:comboBox>
    </h:form> </f:view>
    Now earlier i was submitting the form as
    <form action="/techstacks-v2_1/reportAction.do" method="post" name=doSearch id='doSearch'>
    But now i found, in order to use combo box component which is entirely jsf based i need to use <f:view><h:form> which is kind of taking over the previous form submission mechiansm.
    I am trying to keep them separate as two differnt forms.
    one entirely jsp based and other as jsf based.
    Now my question is can i use such way of doing so or is there any better way of implementing so.
    My friend suggested that i can pass the value of jsf based form in hidden form to a input box of form to be submitted finally instead of submitteing two diff forms.
    but in that case also i ahev to use two forms in a single jsp/jsf page.
    suggest me something which can really work out.
    thanks
    vijendra

    You can use as many forms as you want as long as you don't nest forms. The HTML spec probibits that.

  • Precompiling a JSP that uses a bean

    Hi,
              I am facing a problem when I startup Weblogic with precompiling ON.
              I have a JSP that uses a bean. When the JSP is being compiled, Weblogic is
              actually trying to instantiate the bean and is executing code in the
              constructor of the bean !
              When I use the weblogic.jspc compiler to compile the JSP, no such thing
              happens.
              So this happens only when I precompile such a JSP when starting up Weblogic
              server.
              - Why does weblogic attempt to instantiat the bean ?
              - Is there any way to tell weblogic "dont instantiate this bean now" ?
              Also, the compiler is unable to find a class that is required by the bean. However, this class is there in the /applications/..../WEB-INF/lib in a JAR file. So why is the class not being found ?
              Thanks,
              Jay
              

    Do a stack trace from the constructor to determine who is calling it, and
              maybe why ...
              Peace,
              Cameron Purdy
              Tangosol Inc.
              << Tangosol Server: How Weblogic applications are customized >>
              << Download now from http://www.tangosol.com/download.jsp >>
              "Jayakumar Nandakumar" <[email protected]> wrote in message
              news:3bb0f6d6$[email protected]..
              > Hi,
              > I am facing a problem when I startup Weblogic with precompiling ON.
              >
              > I have a JSP that uses a bean. When the JSP is being compiled, Weblogic is
              > actually trying to instantiate the bean and is executing code in the
              > constructor of the bean !
              >
              > When I use the weblogic.jspc compiler to compile the JSP, no such thing
              > happens.
              >
              > So this happens only when I precompile such a JSP when starting up
              Weblogic
              > server.
              >
              > - Why does weblogic attempt to instantiat the bean ?
              > - Is there any way to tell weblogic "dont instantiate this bean now" ?
              >
              > Also, the compiler is unable to find a class that is required by the bean.
              However, this class is there in the /applications/..../WEB-INF/lib in a JAR
              file. So why is the class not being found ?
              >
              > Thanks,
              > Jay
              

  • May i use the session bean in the jsp

    <%@ page import="sms.EJB.*,sms.UserDetailEJB.*" %>
    <%
    if (request.getParameter("userid")!=null && request.getParameter("password") !=null && request.getParameter("userLevel")!=null)
    UserHome userHome look up...
    UserLocal userLocal;
    userLocal = userHome.create(userid,password,userlevel);
    %>
    <html>
         <head>
              <title>Insert One Page</title>
         </head>
         <body>
         <form action="/testing/insertOne.jsp">
              <h1 align="center">Insert into User Database !</h1>
              <table align="center">
                   <tr>
                        <td bgcolor ="#FFFCCC">User Name :</td>
                        <td bgcolor ="#FFFCCC"><input type="text" name="userName" size="12" maxlength="12"></td>
                   </tr>
                   <tr>
                        <td bgcolor ="#FFFCCC">Password :</td>
                        <td bgcolor ="#FFFCCC"><input type="password" name="password" size="12" maxlength="12"></td>
                   </tr>
                   <tr>
                        <td bgcolor ="#FFFCCC">User Level :</td>
                        <td bgcolor ="#FFFCCC"><input type="text" name="userLevel" size="12" maxlength="12"></td>
                   </tr>
              </table>
              <p align="center"><input type="submit" name="submit" value="add it"</p>
         </form>
         </body>
    </html>
    May i use the session bean like this, if i dont want to use the data access object
    may i use this...

    Hey it apperars to me like heero82 is using session facade and all he has to do is use session bean to make one business call on session bean. Now if u say it is not correct then i would like to know the better way to doing so.
    I can imagine one ways is use business delegate. Just make new of java class in jsp and let that java class do lookup and delegate the call to session facade.
    Let me know inpout on this
    pranav

Maybe you are looking for

  • Ipod Touch wont reconize router password.

    I recently bought a new Belkin wireless router(dont know what one but it was the 50$ model.) and I was able to access wifi with it just fine for the first few days. It accepted the password I put in the first time I ran it. But for some odd reason no

  • Automatic relashionship between records

    Hello, our users find it a bit time consuming to recreate the links (which seems implicit) between the different records. 1) An account contains contacts. One creates an opportunity and wants to associate a contact of this account. Why do we need to

  • Configuration between SAP PI and BPM in SAP PO

    Dear Experts, I am working on SAP PO 7.31 and want to carry out configuration between SAP PI and BPM in SAP PO. I carried the post installation activities in NWA i.e. CTC. Helplessly , I could not find any documents and notes to refer the configurati

  • Reg: Weblogic handling of poison messages

    Hi I am using a j2ee application in weblogic 10.3.1 listening to MQ Queue using jms bindings created through jms admin Now my requirement is , when there is an exception in the application due to any resource like DB ,(Exception is thrown causing bac

  • Is Captivate 8 trial version compatible with Windows RT 8.1?

    I'm unable to execute  Captivate 8, 30 day trial version, on my Windows RT Surface tablet.  I've downloaded and unzipped, but when I right click to execute, I get a message that this software cannot execute on this computer; before I give up,I'm just