Best way to call EJB - Servlet or Tag Library

Hi,
What is the best way to call an EJB from a JSP? We are using Weblogic 7.0(moving to 8.1 beta). WE have a form on a JSP that needs to get data from an EJB. Our flow goes from JSP --> Controller servlet or tag library -->EJB "Bean" Controller ---> EJB. The specfic EJB we need to populate drop downs and fields will be called by a bean controller. Is it better to call the bean controller using a tag library in the jsp or go to the controller servlet to get the data? If servlet is the answer, where do I lookup the EJB Home and call the create from within the servlet? Any help would be greatly appreciated!!
Thanks!

IMO, if you are following some design patterns, like the MVC framework, the best thing is to populate the model(entities that contain the business data) and call the respective getXX methods from the model on the JSP page. The reason for doing so is to keep JSP pages away from any other work other than to just display the business data contained in the respective business entities.
The model can be populated in the servlet and either set in the request or session attribute as per the requirement.
The EJB can be looked up in the servlet as and when required. I would suggest to make use of the Service Locator Pattern to do a look up for the EJB Remote Interface and accordingly make the business calls.
Hopefully this answers some of your questions.

Similar Messages

  • Best way to call EJBs from JavaBeans/JSP

    Does anyone have a favorite way for getting EJB data from a JavaBean into
              your JSPs?
              I'm looking for a way of caching the EJBHome references so the beans don't
              have to do a lookup on each page, each time they are called.
              Thanks,
              -TB
              

    How does this HelperClass keep the references cached after it looks them up?
              Is it a singleton object, or does it keep the references in static fields?
              "Argyn Kuketayev" <[email protected]> wrote in message
              news:3b1e468b$[email protected]..
              > make a HelperClass, which will have a method getXXXHome()
              > inside the Helper class you may implement cashing.
              >
              > thanks,
              > Argyn
              >
              > T. Bailey wrote in message <[email protected]>...
              > >Does anyone have a favorite way for getting EJB data from a JavaBean into
              > >your JSPs?
              > >
              > >I'm looking for a way of caching the EJBHome references so the beans
              don't
              > >have to do a lookup on each page, each time they are called.
              > >
              > >Thanks,
              > >-TB
              > >
              > >
              >
              >
              

  • What is the best way to call a servlet from another servlet?

    I have a project with 9 servlets (class project). The way I have been moving from servlet to servlet is like this
    doPost(...)
    {      response.setContentType(CONTENT_TYPE);
    PrintWriter out = response.getWriter();
    out.println("<html>");
    out.println("<head><title>Functions</title>");
    out.println(f"<form name=frm6 method=post action=/servlet2");
    out.println("<input type=submit name='btn' value='servlet2'>");
    out.println("</form>");
    So I have these 9 servlets - I call any 8 of them from the first servlet so I have 8 buttons on 8 forms <form=frm1, frm2, ...frm8 method = post...> But when I bring up the first servlet only 6 buttons show up. I was thinking about using hyperlinks instead, but I would like to do this with buttons. I wanted to do this with javascript and the location object, but I was advised to use jsp. I just want to move from one servlet to the next. Any suggestions appreciated for the best/preferred method for moving from one servlet to the next.
    Thanks

    I think you may need some clarification of terminology etc..
    First off, JSP isn't an alternative to javascript, it's an alternative to coding a servlet. A JSP is a mixture of java code and HTML and is translated into a servlet by the system. JSPs are primarilly for generating HTML pages with variable content. JSPs very frequently generate HTML which includes Javascript.
    You probably shouldn't think of what you're doing as one servlet invoking another, that does happen; a servlet can transfer an transaction to another servlet or JSP. In fact it's standard practice that a servlet does the logical stuff (like interpretting form data) then transfers to a JSP to generate the response page. However in this case it's the browser that can invoke one of the 8 servlets, the first servlet merely creates the page from which they are invoked.
    It's not obvious why only some of your buttons are showing up. In a case like this use the "view source" option on your browser to find out what HTML the servlet is actually delivering. What's wrong should be evident from that.
    You can put a hyperlink arround a button, or an image. Mostly people turn up their noses at the buttons supplied by HTML and use their own images for buttons. You
    can do somthing like this:
    <img src="/images/button3.png" border="0">
    (Of course this arrives as a GET transaction not a POST).
    Or you can do a bit of javascript like:
    <img src="/images/button3.png" style="Cursor: pointer;"
    onclick="document.locations.href='/servlet3';">

  • What is the best way to call a pageflow action from JavaScript?

    What is the best way to call a pageflow action from JavaScript?
    Thanks,
    John

    John,
    How would I do this from a grid??? Unfortunately there are no JavaScript attributes
    on any of the grid tags that I can see.
    Thanks,
    John
    "John H" <[email protected]> wrote:
    >
    Thanks John!
    "John Rohrlich" <[email protected]> wrote:
    John,
    If you want to put up a confirm dialog before calling an action from
    an
    anchor it is done as follows.
    Here is an example from code of mine that deletes a customer order,if
    the
    user confirms the delete. I pass the order id as a parameter.
    - john
    Here is the JavaScript -
    function confirmDelete() {
    if(confirm('Continue with order delete?'))
    return true;
    else
    return false;
    Here is a sample anchor tag -
    <netui:anchor action="requestToDeleteOrder" onClick="return
    confirmDelete(); return false;">
    Delete
    <netui:parameter name="orderId" value="{container.item.orderId}"/>
    </netui:anchor>
    "John H" <[email protected]> wrote in message
    news:402138f5$[email protected]..
    Thanks for the replies. I figured it was going to require buildingmy own
    url
    to call the action. I had hoped there was an easier way to do it.Rich,
    the
    reason I want to do this is because I want to call the JavaScript
    function
    confirm()
    when a user clicks on a link (in a repeater/grid) to drop a record,I only
    want
    to call the drop action if the user confirms the drop. Maybe thereis a
    better
    way to do what I am trying to do??? I really appreciate any help
    you
    guys
    can
    give me on this, I am pretty new to this sort of stuff.
    Thanks,
    John
    "Rich Kucera" <[email protected]> wrote:
    "John H" <[email protected]> wrote:
    What is the best way to call a pageflow action from JavaScript?
    Thanks,
    JohnTry figuring out the URL to the pageflow action, create a hidden
    form
    in the
    page, then use JS to submit the form. Why would you want to though,
    isn't
    the server going to want to send you to the next page?

  • Best way to inject EJB's in Struts 2

    Hi all,
    I'd like to ask you what do you think is the best way to inject EJB's in Struts 2 Actions (and perhaps other struts classes such as type converters).
    I've read and implemented both a Struts 2 Interceptor and used CDI. About CDI I've read there's a discussion whether the injected resource should be a private field or injected through the constructor which would help testing.
    Personally I seem to prefer CDI as it looks a bit simpler after you are familiar a bit with the technology.
    What is your preferred solution and why?

    Make sure you are using JDeveloper with a "regular Oracle DB" and not Oracle XE - Oracle XE doesn't have support for JPublisher.
    And make sure you are trying to invoke this from the database navigator window and not from the connection manager of your application.
    Anton - I think you are mixing JPublisher with something else - maybe with Java stored procedures?
    JPublisher just creates a JDBC wrapper that calls the functions in the DB - it doesn't run inside the DB so I don't get your point about the mini JVM?
    So it basically does exactly what you recommended: "access PL/SQL procedures from java directly?"

  • What is the best way to call a report from within a report

    What is the best way to call a report from within a report(master / Detail concept)
    A type of drill down report
    Oracle Database 10g
    Forms 10.1.2.0.2
    Report Builder 10.1.2.0.2

    Hi
    Have a look in this link, certainly you will get fix, if not just post a comment on blog, will get reply soon
    http://windows7bugs.wordpress.com/?s=oracle+10g+bug

  • Best way to call

    which is the best way to call a scotland mobile phone from skype? i been using pay as u go credit and its 8 cents a min and was wondering if a monthly thing or a subscription is the way to go

    Translation patterns are for internal use to manipulate a number and then a route pattern will be responsible for pushing it out the gateway or some other method.  If this DID is still being sent to you you could either manipulate this at the CUBE and hairpin it backout or send it to CUCM and hairpin it back after it gets translated with a translation pattern out a route pattern.  I would recommend doing everything at the gateway unless you want to keep some record that the number is in use which CUCM can do more effectively.
    This DID being used for a fax is elsewhere offnet at this point I take it?  Make sure you have the proper CSS's and partitions set for hair pinning if you do this on CUCM since by nature forwarding to external numbers is disabled by default (or at least it used to be as I recall).

  • Best way to call oracle db from BPEL 2.0

    Hi
    Anybody knows which is the best way to call select or call store procedures from BPEL 2.0 ? Do I need to use JCD (java collaboration definition in repository-based projects -caps 5.x) and oracle eWAY to interact with oracle database?
    Regards.

    You can also create a new WSDL with a concrete binding to DATABASE, as explained on http://wiki.open-esb.java.net/Wiki.jsp?page=CreatingAWSDLDocumentForTypeDATABASE
    BRs
    Kris

  • What is the best way to call SSH commands through Java technologies

    What is the best way to call SSH commands through Java technologies

    I don't think you can specify the password at the prompt using ssh. Plink has the -pw command option for passwords. What I did was except ssh to ask me and write the password programmatically through the outputStream I obtained from my Process object. I looked for "password: ", and then wrote the password with a trailing newline.
    Both plink and ssh will also ask if you trust the host if it is the first time you are connecting to it. So before just writing the password, check if the program wants verification from you: normally supplying "y" or "n". This should only have to happen the first time the client connects. It looks like thisPLINK:
    The server's host key is not cached in the registry. You
    have no guarantee that the server is the computer you
    think it is.
    The server's key fingerprint is:
    1024 f8:43:61:4c:a2:5b:77:be:5b:a7:bb:1f:f7:79:b3:b7
    If you trust this host, enter "y" to add the key to
    PuTTY's cache and carry on connecting.
    If you want to carry on connecting just once, without
    adding the key to the cache, enter "n".
    If you do not trust this host, press Return to abandon the
    connection.
    Store key in cache? (y/n)
    SSH:
    The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
    RSA key fingerprint is e1:02:13:c8:52:c2:23:41:9b:5b:58:2c:18:e6:59:af.
    Are you sure you want to continue connecting (yes/no)?What I did was read character by character from the inputStream until I found things of interest ... like "password: ". You only need to search for this in your method which will launch the ssh or plink Process. Once you have verifyed yourself, you can just pass commands to the Process, which is an ssh connection.
    My suggestion is to read() each byte from the Process's inputStream and write it to stdout. Look and see what you need to be looking for so you can interactive with the program correctly. You can't use readLine here becuase when the ssh asks for the password it does not print a newline. I do know for sure, that ssh will simply print, "passowrd: ". Plink will print this as well if the -pw option is not supplied.

  • HT1364 I just bought a new PC and now have ample space on my C drive to house my music Library which is currenlty installed on a external drive.  What is the best way to install and move the itunes library to my C Drive?

    I just bought a new PC and now have ample space on my C drive to house my music Library which is currenlty installed on a external drive.  What is the best way to install and move the itunes library to my C Drive?

    If the entire library is on the external drive then simply copy the iTunes folder into <User's Music> on the new computer, then install iTunes. If you've already installed iTunes you will want to remove the empty iTunes folder in <User's Music> first.
    If it turns out you only have the media folder on the external drive then take a look at this post...
    tt2

  • HT1589 what's the best way to move content to a new library I created ie a holiday music only library?

    what's the best way to move content to a new library I created ie a holiday music only library?

    Sophie:
    Welcome to the Apple Discussions. You're only hope to recover the library as it once was is to: 1 - if you have a backup copy of your iPhoto Library or 2 - you can put everything back exactly the way it was in the Finder.
    Otherwise you'll have to start over with a new library and import the Originals folder from your current library as follows:
    Creating a new library while preserving the Events from the original library.
    Move the existing library folder to the desktop.
    Open the library package like this.
    Launch iPhoto and, when asked, select the option to create a new library.
    Drag the Originals folder from the iPhoto Library on the desktop into the open iPhoto window.
    This will create a new library with the same Events as the original library if you have the Finder checkbox unchecked in the Events preference pane.
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've created an Automator workflow application (requires Tiger), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 08 libraries and Leopard. iPhoto does not have to be closed to run the application, just idle. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.

  • Is this the best way to redirect using servlet?

    I making a servlet application where the user sends some FORM value to a servlet. I want the servlet to redirect to the answer page after processing the page. Do you think the following code is the correct way of doing?
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            response.setContentType("text/html;charset=UTF-8");
            PrintWriter out = response.getWriter();
            String dnaText = request.getParameter("dnaText");
            /*Getting the tranlated output from dnaToRna method*/
            String finalVal = null;
            String link="http://www.mail.yahoo.com";
            try{
                 finalVal = String.valueOf(dnaToRna(dnaText));
                 response.sendRedirect(link);
                }catch(Exception ex){}
        }

    Many thanks for replying.
    My output file have lots of html code and I dont want to make my servlet heavy with unnecessary code. So I have decided to use another page result.jsp as output file. In result.jsp I intend to call these objects which is storing the value here to display the result.
    As I am new to jsp. I am still in the processing of thinking the best way to handle errors. I have created a method which takes in int values and returns corresponding String values. Like this
    public class DnaToRna extends HttpServlet {
       String error=" * NULL *";
    private String printError(int i) {
            if(i==1){
                error = "There is an error in String to char array";
            }else if (i==2){
                error = "There is an error in your DNA sequence";
            return error;
        }Since error is declared as a class object, if there is no error then I think it should rerun the String NULL. Which can be used to tell people if there is no error. On the contrary if there is really an error, I can use this to tell what is exactly causing the error.
    Although I am new to web programing. I think this would be nice.
    Here is the other method
    public String dnaToRna (String dnaText) throws Exception{
                /*Trim()*/
                dnaText = dnaText.trim();
                /*Codes for Dna to Rna translation*/
                if(Pattern.matches(".*[^atgc]+.*",dnaText))
                return printError(2);
                return dnaText.replaceAll("t","u");
                }

  • Best way to call screen in BOR method

    Hi,
    I'm new to BOR objects. I have a requirement to create to a screen to accept values and perform validation on the value.
    As I'm using FOP(EWBC), So in the steps the best way looks like using BOR objects.
    Can any body please guide me what is the best way to create and call a screen in the BOR method?
    Thanks in advance
    Rohan

    IMO the best way is to create a Function Module and call it from your BOR method

  • What is the best way to use EJB modules with JAX-WS?

    Hi.
    I am doing a project that returns EAN13 encoded data to external java clients.
    I think I need to use a webservice that send response, a webservice client that send the request, and other project that transforms a data to an EAN encoded data, returns it and store it in MySql database.
    It is possible that I need to authenticate users for every request made.
    -I have created a EJB module contained into Glassfish for the webservice
    -I have created a Common Java project with 3 layers: Entities, bussines and data access layer for mysql database
    -I have a project for the webservice client with JAX-WS ( is the best choice? or Would be better JAX-RPC? )
    **How would you suggest me create the structure of the project with all the java power?*
    **Could you help me with goods tutorial of design patterns about webservices using EJB and the best way for use databases for this kind of projects ( I have heard about JNDI, Hibernate, Session EJB, ... )?*
    **Would be better use other EJB module instead of a Common java project that has classes?*
    h3. {color:#333399}I shall be pleased with your help{color}

    Kappy is dead on correct about Bridge Mode as a requirement for the Time Capsule.
    Do you know how to check to see if the Time Capsule is configured this way?
    Next question.....you really should not try to have two wireless networks....one Arris and another Time Capsule.....unless it is absolutely necessary. Two wireless routers in close proximity can create wireless interference effects that can cause problems with either...or both...networks.
    Best to turn off the wireless on one router to keep the chances of wireless interference between routers minimized.
    Are both the Arris and Time Capsule providing wireless signals?

  • Best way to call methods on similar objects without an interface

    Hi,
    I have two objects that i need to iterate, they both have the same method i need to call during iteration, but those two objects are from different libraries and i cannot change them to add them as implement interface...
       for (Iterator it = documents.iterator(); it.hasNext();) {
               Document1 document = (Document1) it.next();
               document.getName();
    But I can also get a documents's collection where the object is Document2 and not Document1 that also has getName(), what's the best way to implement this? I mean i know i can just add if conditions to say if (instanceof) do this or that.. but I don't think this is good as everytime there's a new type of doc i'd have to add one more...
    Any suggestions?
    Thanks,

    I have two objects that i need to iterate, they both have the same method i need to call during iteration, but those two objects are from different libraries and i cannot change them to add them as implement interface...
    You already know what you need to do. You just don't want to do it.
    You can't treat two (or more) instances the same if they aren't the same. Here are three methods:
    1. Add code (like you propose) to determine which type you have
    2. Create your own classes that extend those classes and have your own class implement your own interface that has the 'getName' method. When you create instances of your own class the constructor can have code that determines which type you have and then use the appropriate 'getName' method. Your app code would use your own classes instead of the ones from the libraries
    3. Use reflection to call the 'getName' method.

Maybe you are looking for

  • Email adress adding automatically to contacts. How can I deactivate this to happen?

    Each email that I send got their adress added automatically in 'contact' or 'adress book'. How can I stop this to happen?

  • Complex human task route management in Oracle SOA Suite

    Hello. I am struggling to implement a complex role/route model for a human task. Maybe somebody will give me some advice? I need to: Assign a task to least busy user (this is easily done in Assigment UI for Human Tasks) If user rejects the task it sh

  • Weird image view error

    when i take a portrait photo with my iphone, and import it into my mac pro it appears correctly. When i try to apple that picture as a desktop background, or say upload it to myspace it automatically rotates the picture into landscape mode. But if i

  • Indesign CC Files Not Opening

    Running windows 7. Just installed Indesign CC and deleted CS6. Now Indesign files won't display as Indesign files in Explorer and won't open from Explorer or Bridge. How can  I resolve this issue.

  • Can't import .tif file

    iPhoto won't import a large tiff file of a pano, one about 50K x 3K pixels, 852MB. Wondering if the problem is that it's a tiff, or the file size, or the megapixel count, or something else? It was saved in photoshop with no image compression, 'interl