Using Java Beans in Java Server Pages

Can we not use a method of Java Bean in a Java Server Page ?
I am trying to retrieve the user email from a java bean method "getUserEmail". I am instantiating the class, but when I try to use that in JSP tags, I am getting an error.
<jsp:useBean class = "formjavabean.application" id = "applicationId" scope = "session" />
<%@ page import="java.io.*, java.lang.*" %>
<%!
String user = applicationId.getUserEmail() ;
String f3 = "ftn03" ;
String f3not = "ftn03 file not uploaded";
...........I am failing in debugging that, can anyone help plz ?

Here is my whole code in parts:
First the head section:
<head>
<title> Fastran </title>
<jsp:useBean class = "formjavabean.application" id = "applicationId" scope = "session" />
</head>JSP part in the body section :
<%@ page import="java.lang.*, java.io.*" %>
<%!
private String f3 = "ftn03";
private String f3not = "ftn03 file not uploaded";
private String f7 = "ftn07";
private String f7not = "ftn07 file not uploaded";
private String f9 = "ftn09";
private String f9not = "ftn09 file not uploaded";
public String checkFile3()
    File ch3 = new File("C:\\JBoss\\jboss-4.0.5.GA\\bin\\Fastran\\ftn03") ;
    if (ch3.exists() == true)
        return f3 ;
    else
        return f3not ;
public String checkFile7()
    File ch7 = new File("C:\\JBoss\\jboss-4.0.5.GA\\bin\\Fastran\\ftn07") ;
    if (ch7.exists() == true)
        return f7 ;
    else
        return f7not ;
public String checkFile9()
    File ch9 = new File("C:\\JBoss\\jboss-4.0.5.GA\\bin\\Fastran\\ftn09") ;
    if (ch9.exists() == true)
        return f9 ;
    else
        return f9not ;
%>Java Script in the body section, using methods defined in the JSP part:
<script type="text/javascript">
        function validate_file ( )
                var file3 = "<%= checkFile3() %>" ;
                var file7 = "<%= checkFile7() %>" ;
                var file9 = "<%= checkFile9() %>" ;
                if ( file3 != "ftn03" || file7 != "ftn07" || file9 != "ftn09" )
                    alert("Please upload the required file") ;   
                    return ("fastran.jsp") ;
                else
                    return ("processForm.jsp") ;
        function validate_upload ( )
                valid = true;
                if ( document.val_file.filefield.value == "")
                        alert("Please select a file for upload") ;
                        valid = false;
                return valid;
    </script>Finally the form and button part of the page, in the body section:
<form name = "val_file" method="post" action="upload.jsp" name="submit" enctype="multipart/form-data" onSubmit = "return validate_upload();">
Upload Files: <input type="file" name="filefield" >&nbsp&nbsp<input type="submit" name="submit" value="Upload"><br>
<font color = "Red"><h5>(ftn03,ftn07, and ftn09)</h5></font><br><br><br>
Files on the server :<br><br>
<font color = "Green"><h5>
<%= checkFile3() %><br>
<%= checkFile7() %><br>
<%= checkFile9() %><br>
</h5></font>
<br><br><br><br><br><br><br><br><br>
<input type=button onClick="location.href='logintest.jsp'" value='Home'>  <input type=button onClick="location.href=validate_file()" value='Proceed' ><br>
</form>Now try this:
Change <%! to <%, or try using bean method as:
String userEmail = applicationId.getUserEmail() ;..........and that is my problem. I would really appreciate any help, thanks

Similar Messages

  • JAVA beans and JAVA related services require Oracle client to be installed?

    Can you please advice whether an application server that make use of JAVA beans and JAVA related services require Oracle client to be installed? For an example if the solution build based on Java and JBOSS to be used as application server, do we still require oracle client to be installed and configure the tnsnames in order to communicate to database server?

    SHANOJ wrote:
    Can you please advice whether an application server that make use of JAVA beans and JAVA related services require Oracle client to be installed? For an example if the solution build based on Java and JBOSS to be used as application server, do we still require oracle client to be installed and configure the tnsnames in order to communicate to database server?Oracle client is not required when JDBC is used to connect to the remote DB

  • Using KeyFilter Java Bean in Client Server Environment - Mr. Grover hope u r here !

    Hello,
    I will be grateful if some one can tell me how to use Keyfilter
    java bean in Forms 6.0 client server environment.
    Our requirement is to restrict entry in text field to just upper
    case characters at key punch rather than after navigating out of
    field.
    Thanx in advance.

    Are you using
    http://otn.oracle.com/sample_code/products/forms/content.html#jbp
    jc
    Since the readme file shows exactly what you have to do.
    Basically you set the implementation class for a text field to
    point to this class and make sure this class is accessable.
    Regards
    Grant Ronald
    Forms Product Management

  • Cannot compile java beans in my jsp page

    Hi all
    I have created jsp pages which contains java beans. Now its working fine on my machine(XP OS) but when i put it on windows 2000 server it gives the following error:
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: -1 in the jsp file: null
    Generated servlet error:
    [javac] Since fork is true, ignoring compiler setting.
    [javac] Compiling 1 source file
    [javac] Since fork is true, ignoring compiler setting.
         at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:130)
         at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
         at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:353)
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:370)
         at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:473)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:190)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
         at java.lang.Thread.run(Unknown Source)
    please help

    Ok, jsp pages to not contain java beans, java beans are separate classes which you access from a jsp.
    Is this what you have done, i.e. created classes under classes/yourPackage ?
    If so, you do not need to recompile the class when you move it, you can move the pre-compiled class file.
    In terms of your error, I have no idea, but it looks interesting!!
    The most likely cause is a difference in the JDK versions you are running on the different machines. If the JDK on windows 2000 is older, you may need to upgrade it.

  • Java bean + Map Tile Server

    We have Oracle 10g Release 2 And AS + Mapviewer Patch 4.
    Question:
    Is Java bean based API can use map tile server, i. e. to fetch tile from cache of Map Tile Server?
    Why i asking?
    We use function addMapCacheTheme, and mapviewer takes pic from the Map Tile Layer.
    In user guide no ever mention about this functions and about ability of java bean to use Map Tile Server.

    You can find a sample Java Swing application that does just that on my blog here:
    http://oraclemaps.blogspot.com/2008/09/displaying-map-tiles-in-your-java-swing.html
    It contains full source code and can be easily configured to display map tiles from any MapViewer instance.
    thanks

  • Use Java Bean or Java Importer

    I have created my java class to validate a user against LDAP and now I would like to use that class in my own 9i login form. In order to pass the class variable values to the form is it better to create a java bean or use the Java Importer? Which is better for performance?

    Mike,
    Java Beans added to Forms are downloaded to teh client as part of the application startup. The jar files get permanently cached on teh client until they are renewed on the server. For your original request, the funtionality already exists in a Forms9i demo
    http://otn.oracle.com/sample_code/products/forms/files/Forms9iOID_DEMO.zip
    Viewlet:
    http://otn.oracle.com/sample_code/products/forms/demo/9i/forms_services_demos/sso_oid_integration/viewlet/forms_integration_oid/OID90_viewlet.html
    To authenticate
    <Java Importer class package>.authenticateUser(<obj ORA_JAVA.JOBJECT>,user_dn VARCHAR2,password VARCHAR2) RETURN BOOLEAN;
    Frank

  • Question about main difference between Java bean and Java class in JSP

    Hi All,
    I am new to Java Bean and wonder what is the main difference to use a Bean or an Object in the jsp. I have search on the forum and find some post also asking the question but still answer my doubt. Indeed, what is the real advantage of using bean in jsp.
    Let me give an example to illustrate my question:
    <code>
    <%@ page errorPage="errorpage.jsp" %>
    <%@ page import="ShoppingCart" %>
    <!-- Instantiate the Counter bean with an id of "counter" -->
    <jsp:useBean id="cart" scope="session" class="ShoppingCart" />
    <html>
    <head><title>Shopping Cart</title></head>
    <body bgcolor="#FFFFFF">
    Your cart's ID is: <%=cart.getId()%>.
    </body>
    <html>
    </code>
    In the above code, I can also create a object of ShoppingCart by new operator then get the id at the following way.
    <code>
    <%
    ShoppingCart cart = new ShoppingCart();
    out.println(cart.getId());
    %>
    </code>
    Now my question is what is the difference between the two method? As in my mind, a normal class can also have it setter and getter methods for its properties. But someone may say that, there is a scope="session", which can be declared in an normal object. It may be a point but it can be easily solved but putting the object in session by "session.setAttribute("cart", cart)".
    I have been searching on this issue on the internet for a long time and most of them just say someting like "persistance of state", "bean follow some conventions of naming", "bean must implement ser" and so on. All of above can be solved by other means, for example, a normal class can also follow the convention. I am really get confused with it, and really want to know what is the main point(s) of using the java bean.
    Any help will be highly apprecaited. Thanks!!!
    Best Regards,
    Alex

    Hi All,
    I am new to Java Bean and wonder what is the main
    difference to use a Bean or an Object in the jsp. The first thing to realize is that JavaBeans are just Plain Old Java Objects (POJOs) that follow a specific set of semantics (get/set methods, etc...). So what is the difference between a Bean and an Object? Nothing.
    <jsp:useBean id="cart" scope="session" class="ShoppingCart" />
    In the above code, I can also create a object of
    ShoppingCart by new operator then get the id at the
    following way.
    ShoppingCart cart = new ShoppingCart();
    out.println(cart.getId());
    ...Sure you could. And if the Cart was in a package (it has to be) you also need to put an import statement in. Oh, and to make sure the object is accessable in the same scope, you have to put it into the PageContext scope. And to totally equal, you first check to see if that object already exists in scope. So to get the equivalant of this:
    <jsp:useBean id="cart" class="my.pack.ShoppingCart"/>Then your scriptlet looks like this:
    <%@ page import="my.pack.ShoppingCart %>
    <%
      ShoppingCart cart = pageContext.getAttribute("cart");
      if (cart == null) {
        cart = new ShoppingCart();
        pageContext.setAttribute("cart", cart);
    %>So it is a lot more work.
    As in my mind, a normal class can also
    have it setter and getter methods for its properties.True ... See below.
    But someone may say that, there is a scope="session",
    which can be declared in an normal object.As long as the object is serializeable, yes.
    It may be
    a point but it can be easily solved but putting the
    object in session by "session.setAttribute("cart",
    cart)".Possible, but if the object isn't serializable it can be unsafe. As the point I mentioned above, the useBean tag allows you to check if the bean exists already, and use that, or make a new one if it does not yet exist in one line. A lot easier than the code you need to use otherwise.
    I have been searching on this issue on the internet
    for a long time and most of them just say someting
    like "persistance of state", "bean follow some
    conventions of naming", "bean must implement ser" and
    so on. Right, that would go along the lines of the definition of what a JavaBean is.
    All of above can be solved by other means, for
    example, a normal class can also follow the
    convention. And if it does - then it is a JavaBean! A JavaBean is any Object whose class definition would include all of the following:
    1) A public, no-argument constructor
    2) Implements Serializeable
    3) Properties are revealed through public mutator methods (void return type, start with 'set' have a single Object parameter list) and public accessor methods (Object return type, void parameter list, begin with 'get').
    4) Contain any necessary event handling methods. Depending on the purpose of the bean, you may include event handlers for when the properties change.
    I am really get confused with it, and
    really want to know what is the main point(s) of
    using the java bean.JavaBeans are normal objects that follow these conventions. Because they do, then you can access them through simplified means. For example, One way of having an object in session that contains data I want to print our might be:
    <%@ page import="my.pack.ShoppingCart %>
    <%
      ShoppingCart cart = session.getAttribute("cart");
      if (cart == null) {
        cart = new ShoppingCart();
        session.setAttribute("cart", cart);
    %>Then later where I want to print a total:
    <% out.print(cart.getTotal() %>Or, if the cart is a JavaBean I could do this:
    <jsp:useBean id="cart" class="my.pack.ShoppingCart" scope="session"/>
    Then later on:
    <jsp:getProperty name="cart" property="total"/>
    Or perhaps I want to set some properties on the object that I get off of the URL's parameter group. I could do this:
    <%
      ShoppingCart cart = session.getAttribute("cart");
      if (cart == null) {
        cart = new ShoppingCart();
        cart.setCreditCard(request.getParameter("creditCard"));
        cart.setFirstName(request.getParameter("firstName"));
        cart.setLastName(request.getParameter("lastName"));
        cart.setBillingAddress1(request.getParameter("billingAddress1"));
        cart.setBillingAddress2(request.getParameter("billingAddress2"));
        cart.setZipCode(request.getParameter("zipCode"));
        cart.setRegion(request.getParameter("region"));
        cart.setCountry(request.getParameter("country"));
        pageContext.setAttribute("cart", cart);
        session.setAttribute("cart", cart);
      }Or you could use:
    <jsp:useBean id="cart" class="my.pack.ShoppingCart" scope="session">
      <jsp:setProperty name="cart" property="*"/>
    </jsp:useBean>The second seems easier to me.
    It also allows you to use your objects in more varied cases - for example, JSTL (the standard tag libraries) and EL (expression language) only work with JavaBeans (objects that follow the JavaBeans conventions) because they expect objects to have the no-arg constuctor, and properties accessed/changed via getXXX and setXXX methods.
    >
    Any help will be highly apprecaited. Thanks!!!
    Best Regards,
    Alex

  • Java.beans.Statement & java.sql.Statement

    My old code from jdk1.3.1 throws the ambiguous class thingie-mo-bob. Why did they implement the new java.beans.Statement, and is there anyway to make it default to the old java.sql.Statement without having to go through all the old code and add import java.sql.Statement. I have like 200 jsp files 'n it will take a loooong time!
    Pete

    There r two ways to do this.
    (i) One is Implement the java.sql.Statement
    like
    package java.beans;
    public interface Statement implements
    java.sql.Statement {
    }What? Are you suggesting he edit the source code for java.beans.Statement and make it implement java.sql.Statement?? I would most certainly not suggest that solution- beside violating the licensing agreement, it has troubling consequences since you are basically redefining the structure of a class in a way that makes no functional sense- that is, there is no reason for java.beans.Statement to implement methods like getConnection() and the other signatures of java.sql.Statement.
    I'm not sure if I'm reading your response correctly or not, but I would definitely not refactor java.beans.Statement just to get this problem solved with out editing files ... ... since java.sql.Statement is used so widely, perhaps they should have considered a different name for java.beans.Statement , although you hate to base a name off of what's going to cause the least problems, rather then what makes the most sense ... ... any way, I guess it doesn't matter now: the name has been selected .... I'd be interested to hear how you solved the problem.

  • Crystal Reports data connection using Java beans

    Hi
    My name is Bach Ong, i'm currently perform re-configuring Crystal reports 2008 to connect via
    Java bean to Jboss server, this uses look up service on JBoss server. The connection is using Connect
    look up using the properties:
    java.naming.provider.url=jnp://emgsydapp121:10499
    java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
    java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
    for file CRConfig.xml i put as follows:
    <JDBCURL></JDBCURL>
    <JDBCClassName></JDBCClassName>
    <JDBCUserName></JDBCUserName>
    <JNDIURL>jnp://emgsydapp121:10499</JNDIURL>
    <JNDIConnectionFactory>org.jnp.interfaces.NamingContextFactor
    y</JNDIConnectionFactory>
    <JNDIInitContext>/</JNDIInitContext>
    <JNDIUserName></JNDIUserName>
    Can you advise us if this step is correct, and is there any
    documentation that can guide us to right direction.
    for Java testing in Eclipse using remote call class it is working suing the following code:
            Properties p = new Properties();
            p.put(Context.INITIAL_CONTEXT_FACTORY,
            "org.jnp.interfaces.NamingContextFactory");
            p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
            p.put(Context.PROVIDER_URL, "jnp://emgsydapp121:10499");
             InitialContext ctx = new InitialContext(p);
      Date asAtDate = CrystalUtils.convertToDate("2014-01-01", CrystalUtils.relativeToToday(0), false);
         String asxCode = "BHP";
         ClosingPricesReportRequest criteria = new ClosingPricesReportRequest(asAtDate, asxCode);
         InitialContext context = new InitialContext(p);
         ClosingPricesReportService ejb = (ClosingPricesReportService) context.lookup(ClosingPricesReportService.REMOTE_JNDI);
         ClosingPricesReport report = ejb.createMTMClosingPriceReport(criteria);
         System.out.println(report.getClosingPrices()[0].getClosingPrice());
         testval = report.getClosingPrices()[0].getClosingPrice().toString();
         System.out.println(testval);
    when i run the tes code the results as follow:
    10:49:45,244 DEBUG [SecurityAssociation ] Using ThreadLocal: false
    10:49:45,338 DEBUG [MicroSocketClientInvoker ] SocketClientInvoker[709446e4, socket://emgsydapp121:10473] constructed
    10:49:45,338 DEBUG [MicroRemoteClientInvoker ] SocketClientInvoker[709446e4, socket://emgsydapp121:10473] connecting
    10:49:45,338 DEBUG [MicroSocketClientInvoker ] Creating semaphore with size 50
    10:49:45,338 DEBUG [MicroRemoteClientInvoker ] SocketClientInvoker[709446e4, socket://emgsydapp121:10473] connected
    10:49:45,369 DEBUG [ClientSocketWrapper ] reset timeout: 0
    10:49:45,650 DEBUG [InvokerRegistry ] removed SocketClientInvoker[709446e4, socket://emgsydapp121:10473] from registry
    10:49:45,650 DEBUG [MicroSocketClientInvoker ] SocketClientInvoker[709446e4, socket://emgsydapp121:10473] disconnecting ...
    10:49:45,650 DEBUG [SocketWrapper ] ClientSocketWrapper[Socket[addr=/10.137.2.40,port=10473,localport=64150].2cba5bdb] closing
    37.99000000000000198951966012828052043914794921875
    37.99000000000000198951966012828052043914794921875
    Can anyone assist me in convert the above settings to get access by Crystal reports.
    My attemp current are below:
    public class CFDClosingPricesRpt extends CrystalReport {    
        //Constructor
        public CFDClosingPricesRpt(){
            super(ClosingPriceBean.INSTANCE);
         * Returns the ResultSet for this report to Crystal.
         * @param asxCode
         * @param asAtDateString
         * @return
    public ResultSet getNewReport(String asxCode, String asAtDateString) {                     
         try {
             Properties p = new Properties();
             p.put(Context.INITIAL_CONTEXT_FACTORY,
             "org.jnp.interfaces.NamingContextFactory");
             p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
             p.put(Context.PROVIDER_URL, "jnp://emgsydapp121:10499");
             //InitialContext ctx = new InitialContext(p);
             clearCachedReportBeans();     
       Date asAtDate = CrystalUtils.convertToDate("2013-01-01", CrystalUtils.relativeToToday(0), false);
          asxCode = "BHP";
          ClosingPricesReportRequest criteria = new ClosingPricesReportRequest(asAtDate, asxCode);
          //ClosingPricesReportService ejb = (ClosingPricesReportService) ctx.lookup(ClosingPricesReportService.REMOTE_JNDI);
          ClosingPricesReportService ejb = (ClosingPricesReportService) ServiceLocator.getInstance().getService(ClosingPricesReportService.REMOTE_JNDI);           
          ClosingPricesReport report = ejb.createClosingPriceReport(criteria);
          // assemble Crystal-friendly DTO
          Collection closingPrices = Arrays.asList(report.getClosingPrices());
          for (Iterator iter = closingPrices.iterator(); iter.hasNext();) {
                    MBLXClosingPrice cp = (MBLXClosingPrice) iter.next();               
                    if (cp==null) continue;               
                    addReportBean(new ClosingPriceBean( report.getSuppliedDate(),
                                cp.getClosingPrice(),
                                cp.getAsxCode()));
      } catch (Throwable x) {     
          saveErrorMessage(x);
      return getAsResultSet();             
    Thanks
    Bach Ong

    Hi Don Thanks for the reply.
    I've was able to connect via Java beans and JNDI. But this one is going the JNDI of JBoss sever, which the JNDI already configure and working for Crystal reports v10.
    Bach

  • Using Java Bean in JSP to show database record

    I have links in my Tomcat container that if someone clicks on a specific link it should go to a Record page (Show.jsp) with all the values associated with a record from a database.
    For example if someone clicks on a specific link like this:
    LinkExample
    it would take you to a jsp with database info for someone named Jones and show you his info:
    Lastname = Jones
    Firstname = Mike
    City = San Diego
    I would like to do this using a Java helper class and bean so I dont have any database connection or Java code in my JSP.
    I created Java class file that has Database connection that works with a Java bean. I just dont know how to get the Show.jsp to work with the Java Bean and Java helper class file.
    Here is what I have for Show.jsp and this is the part I have been working on the longest but cant get it to work because it doesnt seem to work with the database:<jsp:useBean id="user" class="num.UserDB"/>
    //do I call getUser(lastname) here and if so how?
    <jsp:setProperty name="user" property="*"/>
    Last Name: <jsp:getProperty name="user" property="lastname"/><BR>
    First Name: <jsp:getProperty name="user" property="firstname"/><BR>
    City: <jsp:getProperty name="user" property="city"/><BR>My Java Helper class that compiles and connects to database:
    package num;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import num.User;
    public class UserDB
    public User getUser(String lastname)
    User user = new User();     
            try          
         Class.forName...//database connection stuff here
        ResultSet results = stmt.executeQuery("SELECT * from user where lastname = '" + lastname + "'");
         if(results.next() == true)
         results.next();
         user.setLastname(results.getString("lastname"));
         user.setFirstname(results.getString("firstname"));
            user.setFirstname(results.getString("city"));
         catch(Exception e)          
                   System.out.println("Exception...");               
       return user;
    }My Java Bean that compiles here:
    package num;
    public class User
      private String firstname;
      private String lastname;
    private String city;
      public User()
         //no arg constructor
      public User(String firstname, String lastname, String city)
           this.lastname = lastname;
              this.firstname = firstname;
              this.city = city;
      public String getLastname()
              return lastname;
      public void setLastname(String lastname)
         this.lastname = lastname;
      //more bean methods for all fields here
     

    Sorry if I wasnt specific enough. I have a link that passes a value (field that is passed is called lastname) to a JSP where I want to show record info for that value that is passed.
    My question is how do I show the database record info on Show.jsp for the lastname field value of Jones where I want to use a Java Bean and Database helper class in Show.jsp
    Here is the message I get when I hit the link (LinkExample) and it goes to Show.jsp:
    org.apache.jasper.JasperException: Cannot find any information on property 'lastname' in a bean of type 'num.UserDB'
    .....My UserDB class:
    public class UserDB
    public User getUser(String lastname)
    User user = new User();     
            try          
         Class.forName("org.gjt.mm.mysql.Driver");
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/dbconnone?user=smitherson&password=abcdefg");
        Statement stmt = conn.createStatement();
        ResultSet results = stmt.executeQuery("SELECT * from user where lastname = '" + lastname + "'");
         if(results.next() == true)
         results.next();
         user.setLastname(results.getString("lastname"));
         user.setFirstname(results.getString("firstname"));
                         user.city(results.getString("city"));
         catch(Exception e)          
             System.out.println("Exception..." + e);          
       return user;
    }Bean class:
    package num;
    public class User
      private String firstname;
      private String lastname;
      private String city;
      public User()
         //no arg constructor
      public User(String firstname, String lastname, Sting city)
          this.firstname = firstname;
           this.lastname = lastname;
    this.city = city;
      public String getFirstname()
              return firstname;
      public void setFirstname(String firstname)
         this.firstname = firstname;
      public String getLastname()
              return lastname;
      public void setLastname(String lastname)
         this.lastname = lastname;
      public String getCity()
              return city;
      public void setCity(String city)
         this.city = city;
      

  • Can we run java bean from forms client server??

    Hi,
    The OLTP application we are planning to build has lot of gui e.g
    tabs, drag and drop etc. Our aim is to make it web enabled but
    the network bandwidth available is small 16 - 64K . So even
    thoughwe plan toi use applet , we seriuosly doubt how good it
    will perform on such low network bandwidth. [The system will
    have 100 users]
    Q1. What will be a reasonable bandwidth to run an oltp
    application (say maintenance )
    Hence we are thinking of developing with developer 6i and
    deploying our application in client server mode, which can
    easily be web enabled in future. But we also have to integrate
    visual interfaces like gantt chart, which are not available with
    forms. We plan to use third party java component (e.g ILOG
    jviews), so that in future we can easily web enable the entire
    application.
    Q2. Can we run forms with java bean in client server mode? If
    not, what are the products to be installed on each machine to
    run it without using 9ias?
    best regards

    Yes. We can run sql loader from client machine.
    C:\Karthik>sqlldr user/pass@database data='test.csv' control='test.ctl' log='test.log' bad='test.bad'
    You can go through the following link for better understanding.
    http://www.oreilly.com/catalog/orsqlloader/chapter/ch01.html

  • Java Bean access in a JSP Tag handler class

    Hello Everybody,
    I am trying to access my java bean(ErrorBean.java) in th doEndTag() method of the tag handler class(MyTagHandler.java) and iam getting an "CLASSCAST EXCEPTION"
    I am doing it like this in the tag handler class.
    MyBeans.ErrorBean errorBean = (MyBeans.ErrorBean)pageContext.getSession().getAttribute("ErrorBean");
    Where MyBeans is the package in which my Error Bean is and iam placing the ErrorBean object in the session object before it comes to the jsp page where i have the jsp Custom tag:
    <%@ taglib uri="/WEB-INF/taglib.tld" prefix="errors" %>
    <errors:message/>
    <%@ include file="footer.jsp"%>
    I was of the opinion that i was casting it right...can anyone help me to find ...where iam doing it wrong...its really URGENT ..PLEASE

    Friend that did not work either ...
    u know what...the ErrorTagHandler class is comiling fine with out errors but in the jsp page when the custom tag is hit..this error is showing up when i see the server log.
    can you throw some light on this..
    thanks..
    Firasath

  • Java Beans in 11g !

    Hi everyone,
    We are using 11gr2 Forms/Reports 64-bit on Windows Server 2008 64-bit.
    Now we want to use JAVA BEANS in our application.
    Suggest me link and steps for installing/using JAVA BEANS compatible for 11gr2 Forms/Reports.
    Kindly tell me benefits of using JAVA BEANS in our applications.
    Thanks vth Regards.
    Bhatt.

    Advantage of java beans is you can enhance the behavior of forms. Forms is as you know applet based running on the client. (There is a different technology associated with inserting your own java code into the loop on the application server, should you want to do that.) So with beans in theory you can get more code to run on the client and do things like read and write files on the client, communicate with devices on the client, etc.
    Regarding doing that I think the executive summary is mostly look up Fbean in forms builder help.
    How I came to that tentative conclusion (I haven't gotten mybean to work yet! What do I know?) follows.
    Home of much forms info:
    http://www.oracle.com/technetwork/developer-tools/forms/overview/index.html
    Java beans are java obviously one has to acquire a certain level of expertise in java to deal with them but more importantly how to understand how to communicate between forms and the bean? It's hard for formists, living their lives at the outside of forms, who come up with an idea of something exceptional they want to do in forms, to translate that into the bean world. Then you have to think like a form and that's unknown territory.
    One problem is terminology: what is a PJC and what is a bean? Is a bean a PJC? I have yet to definitely figure that out. The paper below says: "A javabean is a pjc which is of an unspecialized type". However after that was written seems like in many cases when people are referring to "pjc"'s they are thinking the pjc is a specialized type.
    "Oracle9i Forms provides two mechanisms for extending the client with Java. The
    Pluggable Java Component (PJC) mechanism, which was introduced with Forms
    6i, and the newer Oracle9i Forms specific, enhanced JavaBean support
    mechanism." (paper 2 below).
    I was reading this document from 2000 which is interesting:
    Paper 1:
    http://www.oracle.com/technetwork/developer-tools/forms/documentation/269054-130573.pdf
    It's talking about handlers and views and it's quickly getting over my head as I don't know enough forms internals to make much of this. For example I would like to write a bean that can print a small form. I have a proof of concept in java (6) that can print text to the default printer. So next step, create a bean that can get the data out of the form. From my formist perspective here I am in a bean how do I access some fields in a record in a block in forms? It's tough going. What does that mean in this handler/view world? Or do I have to be in the form and think of sending data to the bean and telling it to print it?
    Paper 2:
    http://www.oracle.com/technetwork/developer-tools/forms/documentation/269054-130573.pdf
    Starts out with more on the handler/view thing. Unfortunately I am totally mvc or handler-view impaired. It escapes me totally.
    "The Handler class is responsible for both maintaining the current value of any data and controlling the visual representation of the data."....vs.... "The View class is singularly responsible for presenting the data to the user in some
    manner and handling user input. The View class may allow the data to be changed
    by the user.". What? I am lost I have no idea what the handler does and what the view does. How about a discussion that is strictly goal oriented? If you want to do this, you have to talk to the (Handler| View)? Don't leave it to me to understand the handler/view thing and then figure it out from that. (This mvc thing is precisely what repels me about jdeveloper. You can't embrace jdev if you haven't drunk the mvc koolaid.)
    Further on in the paper they bring up fbean:
    "So in Oracle9i Forms a new simpler mechanism was introduced to allow you to integrate JavaBeans and Java
    Applets as custom components without writing any Java Code at all. This is all handled using a PL/SQL package in Forms called FBean.
    "FBean provides a full PL/SQL API to allow interaction with any public methods,
    properties and events that a JavaBean or Applet exposes."
    Now you're talking! This is more like it!:
    "Executing Methods
    Methods on the JavaBean are executed using one of the variety of
    FBean.Invoke methods. Like the property getters and setters there are various
    versions of this method which handle calling methods on the JavaBean that return
    different datatypes (or return void):
    • FBean.Invoke_Char()
    • FBean.Invoke_Bool()
    • FBean.Invoke_Num()
    • FBean.Invoke()
    Ok now that we know about the fbean thing we can find fbean in the forms builder help system. Looking good. I am pretty sure that somewhere in there you have to get your bean in a jar file and sign it (not a trivial proposition) and
    change the forms server configuration to include your jar file. I also think that the bean has to import frmall.jar and some of the packages regarding that view stuff. A tutorial about fbean and all these details from start to finish would be super!
    So you can talk to another applet? Really? Can this still be done considering all the security concerns in current browsers?

  • Urgent - Embedding visual java beans in JSP

    I have a custom TextBox .
    I want to embed that into my JSP, and want the JSP to be able to read the value / set the value of this text box as and when manipulated.
    How do I go about it?
    Should I usr <jsp:useBean> for viaula components or <jsp:plugin>
    Thank you.

    I do not want to use Applets.
    I want to embed my cuustom visual java bean in a JSP page.
    I am trying to figure some way out.

  • CE-AdHoc Reporting-Java bean connnectivity

    Hi,
    I'm creating ad-hoc reporting utility, using CE xi. And i need to set Java Bean as data source.
    Can anyone please specify the procedure for that?
    My bean is in c:\testJava.
    I've specified <JavaBeanClassPath> and <JavaDir> in CRConfig.xml
    following is the JSP, which is giving 'Invalid Pointer' error.
    <%@page contentType="text/html"%>
    <html>
    <head><title>JAVA BEAN</title></head>
    <body>
    <%@ page import= "java.net.*, java.util.Locale,
    com.crystaldecisions.sdk.occa.report.application.ReportClientDocument,
    com.crystaldecisions.sdk.occa.report.lib.PropertyBag,
    com.crystaldecisions.sdk.occa.report.lib.Strings,
    com.crystaldecisions.sdk.occa.report.lib.PropertyBagHelper,
    com.crystaldecisions.sdk.occa.report.reportsource.IReportSource,
    com.crystaldecisions.sdk.occa.report.data.*,
    com.crystaldecisions.report.web.viewer.CrystalReportViewer"
    %>
    <%
    //Create a report document object
    ReportClientDocument rptDoc = new ReportClientDocument();
    //assume RAS service is running on the same machine as RAS SDK -
    //and attach this report to the local machine
    InetAddress ip = InetAddress.getLocalHost();
    rptDoc.setReportAppServer(ip.getHostName());
    //instead of opening an existing .rpt, create a new empty report
    rptDoc.newDocument();
    //Create two table objects
    Table tblA = new Table();
    //Create a connection info object and property bag for the connection
    ConnectionInfo ci = new ConnectionInfo();
    PropertyBag pb = new PropertyBag();
    //place all of the database connection information into the property bag
    pb.put(PropertyBagHelper.CONNINFO_DATABASE_DLL, "crdb_JavaBeans.dll");
    pb.put(PropertyBagHelper.CONNINFO_DATABASE_NAME, "CR9SampleDataSourceBean.class");
    pb.put(PropertyBagHelper.CONNINFO_SERVER_NAME, "c:/xxtestJava");
    pb.put(PropertyBagHelper.CONNINFO_SERVER_TYPE, "Java Beans Connectivity");
    //attach the property bag to the connection info object
    ci.setAttributes(pb);
    ci.setUserName("");
    ci.setPassword("");
    ci.setKind(ConnectionInfoKind.CRQE);
    //set the names of the tables to be added
    tblA.setName("getResultSet");
    //attach the tables to the connection info object
    tblA.setConnectionInfo(ci);
    //Use the Database Controller to add the two tables to the report
    rptDoc.getDatabaseController().addTable(tblA, null);
    %>
    </body>
    </html>

    Hi,
    I'm creating ad-hoc reporting utility, using CE xi. And i need to set Java Bean as data source.
    Can anyone please specify the procedure for that?
    My bean is in c:\testJava.
    I've specified <JavaBeanClassPath> and <JavaDir> in CRConfig.xml
    following is the JSP, which is giving 'Invalid Pointer' error.
    <%@page contentType="text/html"%>
    <html>
    <head><title>JAVA BEAN</title></head>
    <body>
    <%@ page import= "java.net.*, java.util.Locale,
    com.crystaldecisions.sdk.occa.report.application.ReportClientDocument,
    com.crystaldecisions.sdk.occa.report.lib.PropertyBag,
    com.crystaldecisions.sdk.occa.report.lib.Strings,
    com.crystaldecisions.sdk.occa.report.lib.PropertyBagHelper,
    com.crystaldecisions.sdk.occa.report.reportsource.IReportSource,
    com.crystaldecisions.sdk.occa.report.data.*,
    com.crystaldecisions.report.web.viewer.CrystalReportViewer"
    %>
    <%
    //Create a report document object
    ReportClientDocument rptDoc = new ReportClientDocument();
    //assume RAS service is running on the same machine as RAS SDK -
    //and attach this report to the local machine
    InetAddress ip = InetAddress.getLocalHost();
    rptDoc.setReportAppServer(ip.getHostName());
    //instead of opening an existing .rpt, create a new empty report
    rptDoc.newDocument();
    //Create two table objects
    Table tblA = new Table();
    //Create a connection info object and property bag for the connection
    ConnectionInfo ci = new ConnectionInfo();
    PropertyBag pb = new PropertyBag();
    //place all of the database connection information into the property bag
    pb.put(PropertyBagHelper.CONNINFO_DATABASE_DLL, "crdb_JavaBeans.dll");
    pb.put(PropertyBagHelper.CONNINFO_DATABASE_NAME, "CR9SampleDataSourceBean.class");
    pb.put(PropertyBagHelper.CONNINFO_SERVER_NAME, "c:/xxtestJava");
    pb.put(PropertyBagHelper.CONNINFO_SERVER_TYPE, "Java Beans Connectivity");
    //attach the property bag to the connection info object
    ci.setAttributes(pb);
    ci.setUserName("");
    ci.setPassword("");
    ci.setKind(ConnectionInfoKind.CRQE);
    //set the names of the tables to be added
    tblA.setName("getResultSet");
    //attach the tables to the connection info object
    tblA.setConnectionInfo(ci);
    //Use the Database Controller to add the two tables to the report
    rptDoc.getDatabaseController().addTable(tblA, null);
    %>
    </body>
    </html>

Maybe you are looking for