JavaBeans versus Imports

Hi,
I'm wondering what's the main difference between using a normal java bean (not EJB) with getter and setter methods and importing a java class file directly into the jsp code. in other words, instead of using the <%jsp: useBean ... %> we use the <%@ page import=".."....%> Both are relatively keeping the bulk of the Java out of the jsp pages so are there any advantages using one over the other? Thanks in advance
Best Regards

The usage of JavaBeans is a nice complement to JSTL and the JSP 2.0 Expression language. You will see the benefit once you review them.
The import statement really just makes common code available where JavaBeans is a a resuable component.

Similar Messages

  • JavaBeans Model Import

    Hi all,
    Could someone explain requirements for JavaBeans Model Import introduced since SP9?
    For me wizard rejects even plain empty classes or classes with single String property
    Do I need to define some documentation tags as with XMI model???
    Thanks in advance,
    VS

    Thanks, Karin
    I get several steps further.
    However,  after resolving relations and clicking finish I get the following error in NW log (and nothing is imported, of course):
    !MESSAGE Nov 15, 2004 5:55:46 PM          com.sap.ide.webdynpro.ui.service.ServicesUI          [
    Thread[ModalContext,5,main]] Error: Internal error
       Plugin name: Web Dynpro Model Editor Services
       Plugin ID  : com.sap.ide.webdynpro.service.modeleditor
       Class      : com.sap.ide.webdynpro.service.modeleditor.ModelService
       Method     : doImportJavaBeanModel()
       Message    : Failed to create model .com[/code]
    See line in bold -- wizard does not add dot (".") when concatanating package name and model name (or it is just error in logging itself???)
    Regards,
    VS

  • Key Mapping activates Versus Import Manager

    Hello,
    I have Key mapping activated in the console and Supress Unchaged Records activated in my syndication map.
    Case  : I import files (suppliers catalogs) to MDM via Import Manager manually. I am not sure about it, but since I activated Key mapping property,
    I noticed that for each supplier ID in the Supplier table, a lot of remote keys were created. Previously I only had one remote key for each supplier and now I have a list of other supplier's ID. ( Existent or nonexistent supplier IDs). This becomes an issue for my import, because  when I try to import a file where the supplier id does not exist in the MDM ( this scenario used to block my import and this is what a expect, as supplier is a key in my mapping),  the system automatically maps that nonexistent supplier to other supplier.
    Can you help me to understand if this is caused for the key mapping property ? Any Idea ?
    Thank you very much
    Luciana.

    Hello Stanley,
    The remote keys are form the same remote system.
    My story is : When I am importing a file , suppose my file has an invalid supplier ID. ( this means this supplier is not in the lookup table Suppliers)
    1)The import manager will give me a message such as : Map Supplier ID Values. This behavior was expected.
    2)I decided to test the automap. The invalid supplier was not mapped to a different value. I am ok with that.
    3)If the user ( dont ask me the reason ;-)) decides to map that invalid supplier ID to a different one, he/she is allowed to do so. I remember when the key mapping was not activated this option did not exist. The map and automap button was deactivated.
    What I am trying to make sure is : a remote key will be created for invalid suppliers ONLY if I choose to map it with a different supplier ID.
    Do you have any comments about it ?
    Thank you very much
    Luciana.

  • Stage size versus imported file size

    I am new to the flash universe ... I am running Flash CS3 Pro on a Mac OSX 10.5.8
    Why is the stage size larger or file size always smaller when I import a file into Flash.
    I create a new project (Action Script 3.0), change the Stage size to 125 px x 162 px. Then import jpg images at that same pixel size, but they never fill the entire stage.
    Any help would be great, thanks.
    Greg
    SOCS MAG

    When you alter (reduce) an image's size in Flash it can display the wavy lines.  What you might try to overcome that is to right click the image in the library, select Properties, and in the image properties panel select the option to allow smoothing.
    As far as what is going on with Phtoshop not creating the images to the dimensions you specify, you may need to check the manual.  I have never had a problem, though I never really used Photoshop much.  Try using Fireworks if you have it and see how it fairs.

  • When toe use a JavaBean versus a taglib?

    From my knowledge so far (probably basic knowledge) it appears that custom taglibs for an application could easily be used as java Beans.
    I was just reading a book which gave examples of how to use tags and create your own taglib for an application. It seems that all the taglib just is used to call functions, and a bean can be used in the same way.
    For example,
    <%@ taglib prefix = "myQuery" uri = "..." %>
    <%@ taglib prefix = "c" uri = " ... " %>
    ${myQuery.setId(1)} // Here to set any value really
    <c:set var = "items" value="${myQuery:getItems()}" scope="application" />
    My question is is this method OK to use the call to setId or should I use a Bean?
    <jsp:useBean id="myQuery" class="..." >
    <jsp:setProperty name="id" property="1">
    <c:set var = "items" value="${myQuery.getItems()}" scope="application" />

    Perhaps the Java Bean is not the proper way to
    connect with databases? I read about the sql tag,
    but I don't want all that stuff in my JSP page - I'd
    like it in the background.Good call. The JavaBean is the best place to put the DB stuff, not a taglib...
    If I have a Bean, that has a void function in it...The key is to call the void function from some other setter or getter funtion in the bean that JSTL will call:
    >
    For example, I have a class which is going to connect
    to a database and run queries. So, I would first
    set the properties needed by the query (<c: set
    target="...")Use the setter methods to store the values locally in the bean...
    run the queryNot yet....
    get the properties back (${someBean.someValue})This calls a Object getSomeValue() method. The first part of the getSomeValue method would be to call the 'run the query' function that connects to the database, does the SQL, etc, and returns a representation of the data. This method would then read that representation and convert it such that the web page can handle it.
    <general idea in code>
    private java.util.Map runQuery() {
        //get values needed for the connection
        makeDBConnection();
        ResultSet rs = getResultsOfQuery(/*whatever params*/);
        java.util.Map results = fillMapFromResultSet(rs);
        return results;
    public String getSomeValue() {
      java.util.Map results = runQuery();
      return (String) results.get("SomeValue");
    }>
    But how can I run the query without using a scriplet?
    I read about using a taglib for that, but if I create
    a separate tag and call the query function, wouldn't
    the Java Bean not have access to that?

  • Import JavaBean Model - Invalid class

    Hi,
    I wanted to import a JavaBean Model as described in the Tutorial "Using EJBs in Web Dynpro Applications" (see: https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/1f5f3366-0401-0010-d6b0-e85a49e93a5c).
    Problem: i always get an error "Invalid class - JavaBean not available for import", when i want to select a local jar file as JavaBean source, althrough the jar-file contains a valid bean.
    Note:I also dont have a radio button in my GUI for selecting "Deploy time" as mentioned in the Tutorial and as i have seen in a screenshot in the Blog /people/balaramnaidu.bankuru/blog/2006/04/23/importing-complex-javabean-model-into-webdynpro-by-creating-relationships-for-the-model-classes . in this Blog there is already a question about this, but this question has never been aswered...

    Wolfgang,
    See my tips on troubleshooting JavaBean Model Import: /people/valery.silaev/blog/2005/08/30/javabean-model-import-when-it-really-works
    Valery Silaev
    SaM Solutions
    http://www.sam-solutions.net

  • Using Complex Data Types in Import JavaBean Model

    Hi,
    I have searched and read forums and weblogs related to import javabean model.
    But I am not clear about how to use complex data types like ArrayList, Collection etc in my java bean.
    If I use these complex datatypes in my bean, when creating model in WDF it displays the Complex data elements in Model Relation. I dont know how to use this model relation in my WD project.
    Anyone please explain the<b> step by step solution</b> about using complex data type(used in Bean) in WD Project.
    Thanks,
    Krishna Kumar

    Hi Krishna,
    Valery`s blog contains sample code ( http://www.jroller.com/resources/s/silaev/Employees.zip )
    Another blogs from this area:
    /people/anilkumar.vippagunta2/blog/2005/09/02/java-bean-model-importer-in-web-dynpro
    /people/valery.silaev/blog/2005/08/30/javabean-model-import-when-it-really-works
    And forum topics:
    Import JavaBean Model
    Problem Importing JavaBean Model in NetWeaver Developer Studio
    Issue on "Import JavaBean Model"
    import  JavaBean Model: no executable Methods?
    JavaBeans Model Import
    POLL : JavaBean Model Importer
    JavaBean-Model
    Invalid Class - Javabean not available for import
    WebDynpro Using JavaBean Model ->Please Help
    Best regards, Maksim Rashchynski.

  • Import Java Bean model in Web dynpro DC

    Hi all,
    I have created the following DC's on a track:
    1. EMPDic (Type: Dictionary) - DC that contains the database table.
    2. EMPEjb (Type J2EE) - DC that contains the EJBs that have business logic. Created a public part EMPpp that containd the bean classes.
    3. EMPEar (Type J2EE) - DC that contains the EMPEjb module.In Used Dcs added EMPpp
    4. EMPCmd (Type: Java) - DC that acts as the command bean.
    Created 2 public parts 'compile'(Type:compilation) and 'deploy' (Type:assembly). In Used DCs added EMPpp.
    5. EMPWd (Type: Webdynpro) - DC that will contain the Java Bean Model and the application. In Used DCs added 'compile' and 'deploy'.
    Q1.) Now when i try to import the Java bean model by selecting the radio button "public parts of used DCs" and look at the dropdown, i am not able to see any of the jar's related to my command bean DC.
    If i select the radio button "project(source folder)" and click Next it says 'No JavaBeans for import'. Am i missing something?
    Q2) Could someone tell me the exact steps from pt. 4 onwards. ie. whether it is necessary to create the 2 public parts for EMPCmd DC and what should it contain.
    Thanking you in advance.

    Hi Melwyn,
    check the NWDI tutorial, it will help you:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/c0b53558-6df6-2910-cfbf-a63316bb0fad
    kind regards
    Stefanie

  • JavaBean Models, Command Bean and J2EE Design Pattern

    Hello,
    I have read the available "How To", “Using EJBs in Web Dynpro Applications” where the author mentions that one should use a Command Bean (according to J2EE Design Patterns) so that one can invoke business methods in a Session Bean from our Web Dynpro Application. Well, although, I have read some available articles in the internet about J2EE design patterns, I still have some questions about command beans and its usage in Web Dynpro applications.
    I have developed a WD App which uses EJBs to read data from the DB.
    Let's suppose I only have two tables: BOOKS and AUTHORS.
    Let’s also suppose I have to Entity Beans (one for each table) and a Session Bean with two methods: Book[] getAllBooks() and Author[] getAllAuthors();
    I also have a Command Bean which I imported in my WD App.
    My questions are:
    How should I design my Command Bean?
    Can I have only one Command Bean with two methods each calling one of the methods of the Session Bean?
    Or instead should I design two Command Beans, one for each call?
    In the last case do the methods must be named <b>execute</b> or can I name them whatever I want?
    Furthermore, how should I store the data in my command bean? In instance variables?
    If so, can I use array of a class representing a record in the database table (for instance, classes Book and Author) or do I have to store the data in a generic collection (such as ArrayList for instance)?
    I ask this last question because if I try to store the data in an array when I am importing the Command Bean as a JavaBean model I always get an error.
    One last question: Can the Command Bean execute method directly return the data or should I always store the data in an instance variable an then get it using getter methods?
    I know this questions are more about J2EE Design Patterns and JavaBeans specification than they are about Web Dynpro but I also have doubts about the rules that the command bean must obey in order to accomplish a successful JavaBean model import in WD.
    Some guidance or tips would be highly appreciated.
    King Regards

    I have the same problem.
    Does anyone know the solution?
    Thanks
    Davide

  • Java Bean Importer

    Hi
    I am trying to import a Java bean into webdynpro component. I have exposed the Java bean class as public part and I am using this as a used DC in webdynpro.
    I am trying to create a model from Java bean importer and i select the Jar of the java bean I am getting the following error.
    java.lang.Exception: Invalid Class - JavaBean not available for import
    Class :javax/ejb/CreateException
    Jar :C:\Documents and Settings\Administrator\.dtc\1\DCs\ibm.com\jdidemo\maint\java\_comp\gen\default\public\CommandBean\lib\java\comjdidemomaintjavaCommandBean.jar
         at com.sap.ide.metamodel.importers.javabean.JavaBeanAnalyser.identifyClassesForJar(JavaBeanAnalyser.java:1187)
    Any help is appreciated.
    Regards
    NagaKishore V

    Hi,
      please check the steps to be implemented to import the Jave Bean.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/1f5f3366-0401-0010-d6b0-e85a49e93a5c
    Please refer the blog as well.
    /people/valery.silaev/blog/2005/08/30/javabean-model-import-when-it-really-works
    hope that helps.
    Regards,
    S.Divakar
    Message was edited by: Divakar Salla

  • 'invalid class-java beans not available for import

    Hi Experts,
    i am using java bean model in my Web Dynpro Application.
    for that one i have created command bean(Customer) and in my command bean i am using some other class(CustomerInfo) as reference. this CustomerInfo class contains 4 attribtes(name ,id ,etc  all are of type String)
    when i try to import these 2 class into web dynpro (using java bean model),for the Customer class it
    is giving an error message 'invalid class-java beans not
    available for import'.but 2nd class(CustomerInfo) is imported successfully with out giving the error.what might be reason.
    any help will be appriciated
    Thanks in advance
    With Regards
    Naidu

    Naidu,
    Please try to repeat JavaBean model import when running IDE in console mode (correspondign short-cut should be available in Windows Start menu, otherwise just copy original short-cut, edit it and change in command string "javaw" to java).
    Post here what is shown on console during import.
    VS

  • Updating JavaBean model to reflect changes in classes

    I have a Model that was created from a bean using the JavaBean Model import utility. Everything works great...
    My question is how do I update this model as I add beans to the jar file? Do I have to delete and recreate the model again each time?

    Hi Tom,
    if you mean reimporting of Java Bean Model,it's available with latest release of J2EE stack.if u are woring on 6.4,u have to delete the existing model and recreate it.
    With Regards
    Naidu

  • Thumbnails in Project Window

    I have a Konica Minolta 7D. When I import RAW photos from my camera initially the full-sized photos appear in the Project. The second time I open the Project, however, thumbnails are displayed in the Project Screen along with the full-size versions. If I delete the thumbnails then, upon opening the Project again, the full-sized images are unable to load in the Viewer. (They are displayed in the Viewer but the "loading..." sign is perpetually shown.) I am then unable to export or email those images.
    Any ideas as to what causes this problem? Otherwise I love Aperture and its features.

    Ditto for me. Imported directly from my Minolta A1, RAW. I think, the thumbnails appeared as separate images in the project view immediately after I deleted a light table. But I'm not sure what really triggered it. Deleting such a thumbnail would render the full-sized image useless. After deleting re-importing the images: Same thing.
    Them again I deleted the images. And, from within the Finder, I copied the images from the camera to the hard-drive via USB. In Aperture, I imported these from the hard-drive (instead from the camera). Since then I could not reproduce the thumbnail bug.
    The mere fact of importing via USB from the camera versus importing from the hard-drive seems to make the difference. Never had a problem importing to iPhoto via USB.

  • Calling Stored Procedures through JDBC

    Hello!
    I would like to implement a call to a stored procedure through JDBC. This call I suppose to embed in JavaBean to import Bean as model.
      A) Shoud this call be implemented inside ordinaly JavaBean or inside EJB?
      B) How can I determine DataSource? Is it possible through JNDI?
      C) Is there any tutorials or examples?
      D) Could anybody give some code texts on this theme?

    we use quite a similar architecture here (2 ORACLE DBs, a DB link from one instance to the other). However, we use the db links in functions (not in stored procedures). but a simple select using the db link also works with JDBC. do you use the very same db instances / schemas / users+passwords on all your different test environments? so far, we havent' noticed any problems with ORACLE queries (stored procedures, functions, etc.) that work in sqlplus/worksheet but not with JDBC. do you use the latest ORACLE JDBC drivers (9.2.0.3)?

  • How to configure the .EAR to the OC4J server step by step ?

    I have configured the JavaBean of the OC4J server with the following step:
    1.create the eosp.ear with the JDeveloper's wizard
    2.copy the eosp.ear to the OC4J Server with the Path:
    J2EE_HOME/applications/
    3.modify the server.xml and add the following words:
    <application name="eosp" path="../applications/eosp.ear" auto-start="true"/>
    4.restart the OC4J server and show the information:
    Auto-deploying eosp (New server version detected)...
    5.create the new JSP and this source code is:
    <%@ page import="com.beautybeard.eosp.common.*"%>
    <%@ page import="com.beautybeard.eosp.constant.*"%>
    6.visit the JSP and show the error information:
    Error parsing JSP page /eosp/usr_profile/login.jsp
    Syntax error in source/eosp/usr_profile/login.jsp.java:5: Package com.beautybeard.eosp.common not found in import.import com.beautybeard.eosp.common.*; ^/eosp/usr_profile/login.jsp.java:6: Package com.beautybeard.eosp.constant not found in import.import com.beautybeard.eosp.constant.*; ^2 errors
    why?
    why can not find the package?
    please help me out

    Hi Sky-
    It looks like you have a web application only.
    You need to create a war file as described above. A war file is a jar'd file containing your web components, including your javabean class files, etc. JDeveloper 9i can do this for you. You've already done the hard work. Suppose that the project you have created that contains your javabeans, etc in JDev 9i is called myproject (with myproject.jpr as the project file). Right click on the myproject.jpr in the JDev navigator and select 'new...', go to Deployment Profiles and select J2EE Web Module (WAR File) - a general screen will pop up asking you to save the deployment profile (you can just use the default if you want). Once you select OK on that, you will get a screen that calls itself the J2EE Web Module Deployment Profile Settings. This is the screen that you can use to enter your information.
    Your servlet and javabean classes will go into WEB-INF/classes subdirectory that you see to your left in this window. Simply select the WEB-INF/classes entry and it will display a list of your java sources (it will only place the compiled output in this directory - there is a toggle for it).
    Once you have specified that your javabean and servlet classes go in this directory, you should be set. Go ahead and save / close. In your navigation screen under your project (myproject.jpr or whatever your project name is) you will see your files, jsps, etc and something called webapp1.deploy (if you accepted the default). If you right-click on that, you will get a menu that asks a number of things, one of which is to Deploy to EAR file. Select that entry and it will create an ear file for you. You can play with the various settings to change the name of the ear file, but that's about all you have to do. Once this is completed, you can put the EAR file on your linux box or wherever you want, adjust your server.xml and default-web-app.xml files and launch the app!
    Good luck!
    Ray
    Hi,Ray
    Thank you for giving me the detail information!
    I'm sorry that I can not give the detail and clear problem ,which make you delusoried.
    ok,now I give you my aim.
    1. I will construct my application system with JavaBean(not EJB),Servlet,JSPs (linux+IAS+JDeveloper+Oracle8i database)
    2. I will package business function with JavaBean. example:
    * CheckLogin.java
    package com.beautybeard.eosp.javabean.usrprofile;
    import com.beautybeard.eosp.common.*;
    import com.beautybeard.eosp.data.*;
    import java.io.*;
    import java.lang.*;
    public class CheckLogin{
    public CheckLogin()
    //do nothing here
    public boolean getCheckLogin(){
    3. I will control the request and response with Servlets.
    example:
    *CheckLoginSevlet.java
    package com.beautybeard.eosp.servlet.usrprofile;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    import java.sql.*;
    import com.beautybeard.eosp.servlet.*;
    import com.beautybeard.eosp.javabean.usrprofile.*;
    public class CheckLoginServlet extends DefaultServlet
    public void service(HttpServletRequest req,HttpServletResponse res) throws IOException, ServletException
    //use the JavaBean
    CheckLogin cl = new CheckLogin();
    if (cl.getCheckLogin){
    res.sendRedirect("login.jsp");
    }else{
    res.sendRedirect("err.jsp");
    4. I will display the result with JSPs:
    example:
    <%//login.jsp%>
    <%@ page import="com.beautybeard.eosp.common.*"%>
    <%@ page import="com.beautybeard.eosp.data.*"%>
    5. I have success on running the above steps in the 9iJDevelper(pure java) environment(OS:Windows 2000 Server), and now I will move the JSPs ,Servlets,JavaBeans to the Server(linux) without the JDeveloper's deployment wizard.
    how to configure the IAS to carry my point?
    thank you!
    Sky liu

Maybe you are looking for

  • How can I fix a problem with PGA Tour shot tracker?

    PGA Tour Shot Tracker will not display for the full field. It appears momentarily and then goes all black. I've disabled FlashBlock, AdBlock, and still no help. It (Shot Tracker) will work for groups and individual players, however.

  • Router Crashes w/multiple types of clients (b/g)

    I've got a WRT54GS that i'm using with several G devices without problems, but anytime I turn on my handheld pocket pc with wireless-b, the router hangs. I'm not using the WRT54GS for DHCP, and I'm using WEP-128 and I have the latest firmware on the

  • IPad Mini Microphone not very sensitive.

    Has anyone else tried Facetime or Google+ Hangouts and found the microphone to be pretty poor?  I need to actually put my mouth an inch or so away for anyone to hear me.  I would try my iPhone 4 headphones but I don't think that mic ever worked.  Cur

  • JWS 2.0 Giving Error !!!

    Hello, Friends!! I am using JWS 2.0 with JDS 1.2.2. Till yesterday, My site was running quite properly but since yesterday, I have start facing a "Typical Error". The Error looks like this : (Heading) Messenger Service Message from web_server to web_

  • Report builder menu disappeared

    hello all ! i am running report builder 6i, i have windows NT 4 installed on my machine, every thing was running fine till yesterday, but when i opend report builder today, the standard windows gui menu which contains all options like : File Edit Vie