How to understand EJB and JSP

just now i read some articles about EJB and it make me a little confused in what i have understood about EJB and JSP ( at least i thought i understood them, but now ....()
1. i found that in most JSP examples, the javabeans are used but not the EJB, right? so i have a qustion, an EJB can be used in JSP or not? and how if it can? why if it can not?
...still have a lot of question ....
thanks a lot

Hi,
1. i found that in most JSP examples, the javabeans
are used but not the EJB, right? so i have a qustion,
an EJB can be used in JSP or not? and how if it can?
why if it can not?It can be there for more of the examples,but you can invoke the EJB from the JSP also .Actual EJB is entirely the different concept whose foundation is build on the Distributed Technology.I advice you to read the Mastering EJB which is freely available at http://theserverside.com
before starting coding.The EJB is a vast concept and requires time and strong core foundation to understand,once it is clear then you understand it true potential...
...still have a lot of question ....You queries are welcome here!!!
regards
Vicky

Similar Messages

  • How to master good design with EJB and JSP?

    I use JSP to calling EJB. But the .jsp file is complex and it's difficult to maintain...I just want to work higher efficent with EJB,JSP and JavaBean. I want to know is there a good design with EJB and JSP? and is there any good material about MVC for EJB,JSP and JavaBean?

    You should read the J2EE blueprint available on this website. Better download the PDF, and print it for yourself so you can read it anytime.

  • Propagation of ctx between EJB and JSP

    Hello,
    Does anybody know how to propagate the Security
    Context between EJB and JSP so that when I login in my JSP page the user will be after recognized in my EJB system ?
    Thanks
    Francesco

    try this...as a test..
    take a simple Contact ejb (as simple as you can make it, just a name and email address). In the ejb-jar.xml set up a role, for example, user, and restrict the access to only this role for all methods.
    try to access the ejb from a jsp, and you should get the login form identified in your web.xml file.
    make sure that the ejb is noted in the web.xml file, also.
    this should work...
    no try this...identify a role in your web.xml file, (user, for example) and restrict the access to the a particular jsp which is not calling the ejb. IF you navigate to this jsp, you should get the login prompt...
    this should work....
    now the tough part
    in your application.xml create a role with the same name, user. By doing this, you have created a global role, and connect the two together.
    Now point your browser to the restricted jsp with no calls to the ejb...you should get the login, so login in.
    now navigate to your jsp which is unrestricted, but calls the restricted ejb...
    there should now be no login prompt.
    This should work.

  • How to use EJB in JSP...urgent!!!

    hello,
    i am novice programmer in EJB.
    i am using weblogic 6.1 ...
    my problem is how to use EJB in jsp page.
    my code is as follow..but its not displaying any result.
    <%@ page import="javax.naming.InitialContext,
    javax.naming.Context,
    java.util.Properties,
    firstEJB.First,
    firstEJB.FirstHome"%>
    <%
         long t1 = System.currentTimeMillis();
         System.out.println(t1);
         Properties props = new Properties();
         p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.TengahInitialContextFactory");
         props.put(Context.PROVIDER_URL, "localhost:7001");
         Context ctx = new InitialContext(props);
         FirstHome home = (FirstHome)ctx.lookup("FirstEJB");
         First bean = home.create();
         String time = bean.getTime();
         bean.remove();
         ctx.close();
         long t2 = System.currentTimeMillis();
    %>
    <html>
         <head>
              <style>p { font-family:Verdana;font-size:12px; }</style>
         </head>
         <body>
              <p>Message received from bean = "<%= time %>".<br>Time taken :
              <%= (t2 - t1) %> ms.</p>
         </body>
    </html>
    please tell me the solution.

    Hi, I don't know if it may be the cuase of your problems, but you should narrow the Object obtained doing the lookup, like this:
    FirstHome home = (FirstHome) PortableRemoteObject.narrow(ctx.lookup("FirstEJB"), FirstHome.class);

  • How to combine servlet and jsp

    I'm doing a project. My friend using jsp. and i using servlet..
    we are confused, how to combine servlet and jsp. or we can just use redirect??
    but it's still doesn't work properly...thanks for your helpp

    You can use RequestDispatcher interface for calling a JSP from a Servlet, or vice-versa.
    Following is the code for sending output to a JSP page from a servlet:
    javax.servlet.RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(�/Ashu.jsp�);
    request.setAttribute(�Name�,�Ashutosh�);
    dispatcher.forward(request,response);
    - Ashutosh

  • How To Use EJB in JSP

    I've used beans in JSP.. but how to use EJB's in beans ??
    EJB's are deployed in Oracle 8i
    Please Help
    Thank You.

    Please find the answer in this HOWTO:
    http://technet.oracle.com:89/ubb/Forum2/HTML/006404.html
    HOWTO's are archived on the JDeveloper Documentation page:
    http://technet.oracle.com/docs/products/jdev/listing.htm (Click on Documentation Tab)
    Thanks,
    -Roel.

  • JNDI tree access for code outside servlets and EJBs and JSPs

    Can code outside EJBs, Servlets and JSPs have access to the JNDI tree?
    For example, in a web application, web.xml has a env-entry declaration which I want to access from a POJO which is called by a JSP in the web app. Is this permissible?

    Can code outside EJBs, Servlets and JSPs have access
    to the JNDI tree?
    For example, in a web application, web.xml has a
    env-entry declaration which I want to access from a
    POJO which is called by a JSP in the web app. Is
    this permissible?Yes. Read the JNDI tutorial.

  • How to use servlets and JSP for my homepage?

    servlets and JSP are server-side program. If my homepage is on some web-hosting websites, can I upload the servlets and JSP to run it? if possible, where can I find such a web-hosting place?
    sraiper

    Not many hosts offer JSP or Servlet support (and some do but then stop and never give you a refund, grrrrrrr!!!!).
    Also, ones that do support it can often be more expensive. There are some free ones but all the one's I've come across have problems that made them unsuitable for my needs.
    Here is a list of hosts that support Java:
    http://www.thejspbook.com/resources/category.jsp?id=1005&name=JSP+web+hosting
    I can't comment on any from that list, however I use http://www.positive-internet.com they are a bit pricey but they have excellent support and are always happy to help with any Tomcat (the JSP/Servlet server they use)configuration issues or needs that you may have.

  • EJB and JSP Potential

    I am new to JSP and don't know it's potential.
    I need a user to access a url and give it some conditions and receive the information back (pretty simple).
    How can I use an existing EJB that Authenticates a user and another bean that retrieves data from a DB with JSP?
    Can I use our existing EJB's with JSP or should I use JSP alone?

    A JSP can do anything Java can do. The JSP file gets turned into a Servlet and compiled. To access an EJB you just do it in the same way you would do in a normal Java client.
    Hope this helps.

  • How to install servlet and jsp on win xp?

    I am new in jsp and servlets. I would like to follow some jsp books and examples. The j2eesdk-1_4-dr-windows-eval.exe is already installed on my computer. I can write and run java codes. I downloaded the jsp-2_1-edr-api.zip file from http://java.sun.com. I extracted and moved to dir:\Sun\AppServer\ folder. When I search, I cannot see any jsp.jar file as some documents say, nor servlet.jar. How can I install jsp and servlet on windows xp? Any help? I will be very grateful.

    For starters, you would probably have better luck getting an answer on the general Java forums, since this a very general question- it is hard to see how this is specific to the Web Application Framework technology, except of course that it uses JSP and servlets naturally,
    But to try to help you here, more information is needed: from exactly where are you do\wnloading the file jsp-2_1-edr-api.zip and what is the product title of this file? I ask this since a general search of sun.com returns no evidence of the existence of this file.
    Also, what documents are being referred to here?
    Thanks

  • How to understand Credit and Debit account.....

    Hi,
    As an SD consultant, what's your understanding on Credit and Debit those FI terms.
    Like Sales revene or Sales return scenario...
    How those process interacted with Credit and Debit...
    Thanks.

    Accounting Principle is lad down on Golden Rule as under:
    Personal Account:
    Debit - The Receiver
    Credit - The Giver
    Real Account:
    Debit - What Comes In
    Credit - What Goes Out
    Nominal account:
    Debit - All Expenses and Loses
    Credit - All Income and Gains
    To illustrate with Example:
    When We raise an Invoice to Customer, the Accounting Entry is as under:
    Customer Account ...........Debit
    To Sales..........................Credit
    To Taxes..........................Credit
    In SAP, Based on Mapping of G/l Account in T.code: VKOA and OB40, relevant G/L account are triggered. G/L accounts as disigned such that it would take cage of Debit and Credit, if mapping is correct in T.code: VKOA and OB40.
    Regards,
    Rajesh Banka
    Edited by: Rajesh Banka on Aug 7, 2008 9:34 AM

  • How to run EJB with JSP as client on TOMCAT - JBOSS server

    Hi all,
    I am having my EJB component successfully deployed on JBOSS server. My core-java client is able to access the same. But when I use the JSP page which is on Tomcat server, I am getting following exception. Please help me out.
    Exception Report:
    org.apache.jasper.JasperException: sealing violation
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.load(JspServlet.java:125)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:161)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:171)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:328)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:407)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:251)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:977)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:196)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:977)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2041)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
         at org.apache.catalina.valves.ValveBase.invokeNext(ValveBase.java:242)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:414)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:975)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:159)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:977)
         at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:818)
         at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:897)
         at java.lang.Thread.run(Thread.java:484)
    Root Cause:
    java.lang.SecurityException: sealing violation
         at java.net.URLClassLoader.defineClass(URLClassLoader.java:234)
         at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
         at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at org.apache.catalina.loader.StandardClassLoader.findClass(StandardClassLoader.java:648)
         at org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader.java:987)
         at org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader.java:906)
         at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:136)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
         at java.lang.Class.newInstance0(Native Method)
         at java.lang.Class.newInstance(Class.java:237)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.load(JspServlet.java:123)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:161)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:171)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:328)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:407)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:251)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:977)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:196)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:977)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2041)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
         at org.apache.catalina.valves.ValveBase.invokeNext(ValveBase.java:242)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:414)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:975)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:159)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:977)
         at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:818)
         at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:897)
         at java.lang.Thread.run(Thread.java:484)
    Please let me know what the problem is as I am new to EJB.
    Thanx a lot
    Unmesh

    Hi
    Even i have the same problem...
    i have deployed the ejb in jboss..
    but i cannot even run the core-java client program
    can u pls mail me the code...
    and the directory path
    thanks a lot
    cheers
    simreen

  • How to connect EJB by JSP??

    I kowm,EJB1.1 hadn't been connect by JSP.Now,How to connect EJB2.0 by jsp.
    EJB'container/server is woblogic.Thanks for your replaying!!

    Hi,everyone,I hava found out its anwsers.
    The method :
    Now,if we hava writted a EJB,using IAS for conainer/server.
    JNDI named "happy".
    CODE:
    <%@page import="javax.naming.*;"%> //jndi
    <%@page import="javax.rmi.PortabieRemoteObject;"%>
    //rmi
    <%page import="happy.*;%>
    //EJB's home/remoteInterface
    <%
    InitialContext ctx=new InitialConrect();
    //Init
    Object ref=ctx.lookup("Happy");
    //using JNDI,you get Object'sinterface
    HappyHome hoppyhome;
    happyhome=(SampleHome)PortableRemoteObject.narrow(ref.HappyHome.class);
    HappyRemote remote=happyremote.creat();
    //forllowing,you can use EJB's method by remote calling.
    %>
    WELCOME FOR YOUE ADVISE!!!

  • EJBs and JSPs error

    Hi!
    I'm deploying a new application using the deploy tool from J2SDKEEE1.2.1.
    It has a bean (Entity CMP Bean) called Product (ProductEJB, ProductHome, Product) which works if I test it with a console-based client.
    My problem is that I want to query it using a JSP. I don't want to use JavaBeans (<jsp:useBean...) and write the simple code straight to the .jsp file.
    But the JSP, when getting compiled on the server, is unable to find the Product and ProductHome classes needed in the code.
    I tried to put these in WEB-INF/classes but it still won't work.
    I'm pretty new at this EJB stuff (I'm a Resin user). Please help!
    THX!

    Make sure your import-statements include the package where the classes reside.

  • EJB and JSP. Strange behaviour with buttons

    I have an EJB (called Vault) which (apart from all the essential stuff) contains only:
    public String getIndex()
    return Integer.toString(++index);
    private int index = 0;
    I have a page which displays three buttons. Each time a button is clicked, the EJB getIndex() is called, and the value reported. I would expect to get the sequence of numbers 1, 2, 3, 4, ... whenever any button is clicked. And so I do, until I change to a previously clicked button when it displays the same value it displayed when that button was last clicked! In this case, not only does the EJB give the wrong answer, but System.out.println gives no output! (Same problem?) Pressing the button again gives the expected value from the sequence. Continually clicking the same button gives the expected result.
    This is a simplified version of code that was presenting a similar problem; on re-pressing a button, old data was being displayed.
    HTML/JSP code below.
    Any insights would be greatly appreciated.
    John
    Frame page defines javascript for three buttons:
    <HTML>
    <HEAD>
    <TITLE>Vault</TITLE>
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Hiding Script
    function fnAction(action)
    var str = "DisplayData.jsp?Action=" + action;
    treeFrame.location.href=str;
    function one()
    fnAction("doOne");
    function two()
    fnAction("doTwo");
    function three()
    fnAction("doThree");
    // end hiding script -->
    </SCRIPT>
    </HEAD>
    <FRAMESET onLoad="initialize()" FRAMEBORDER="0" FRAMESPACING="0"
    BORDER="0" rows="250, *">
    <FRAME SRC="Browse.html" NAME="treeFrame">
    </FRAMESET>
    </HTML>
    Initial page Browse.html
    <HTML>
    <HEAD>
    <TITLE>Browse</TITLE>
    </HEAD>
    <BODY>
    <form>
    <INPUT TYPE=BUTTON OnClick="javascript:top.one()" VALUE="1">
    <INPUT TYPE=BUTTON OnClick="javascript:top.two()" VALUE="2">
    <INPUT TYPE=BUTTON OnClick="javascript:top.three()" VALUE="3">
    </form>
    </BODY>
    </HTML>
    DisplayData.jsp
    JSP page used to call EJB functions:
    <%@ page import="webvault.Vault,webvault.VaultHome,javax.ejb.*,
    java.math.*, javax.naming.*, javax.rmi.PortableRemoteObject,
    java.rmi.RemoteException" %>
    <HTML>
    <HEAD>
    <TITLE>DisplayData</TITLE>
    <SCRIPT LANGUAGE="JavaScript">
    </SCRIPT>
    </HEAD>
    <BODY>
    <%!
    private Vault vault = null;
    public void jspInit()
    try
    InitialContext ic = new InitialContext();
    Object objRef =
    ic.lookup("java:comp/env/ejb/webvault/TheVault");
    VaultHome home =
    (VaultHome)PortableRemoteObject.narrow(objRef, VaultHome.class);
    vault = home.create();
    catch (Exception ex)
    System.out.println("jspInit exception: " +
    ex.getMessage());
    String handleAction(String action)
    StringBuffer sb = new StringBuffer(action);
    try
    sb.append("\nVault.getIndex(): ");
    sb.append(vault.getIndex());
    catch (Exception ex)
    sb.append("\nException: ");
    sb.append(ex.getMessage());
    return sb.toString();
    %>
    <form>
    <INPUT TYPE=BUTTON OnClick="javascript:top.one()" VALUE="1">
    <INPUT TYPE=BUTTON OnClick="javascript:top.two()" VALUE="2">
    <INPUT TYPE=BUTTON OnClick="javascript:top.three()" VALUE="3">
    </form>
    <%
    String action = request.getParameter("Action");
    String js = handleAction(action);
    System.out.println(js);
    %>
    <%= js %>
    </BODY>
    </HTML>

    This is not an EJB problem as I thought, as I can duplicate it with a
    normal Java class called from JSP page; in fact its an IE special
    feature. It works fine under Netscape, and only shows the offending
    behaviour under IE (thank you again Micros**t). So its back to
    Netscape as standard for me!
    John

Maybe you are looking for