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.

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.

  • Switching between Design and JSP tabs add code?

    I am new to SJSC and I am taking the time to go through all of the little odds & ends of the IDE.
    I was looking at:
    http://blogs.sun.com/roller/page/tor?entry=computing_html_on_the_fly
    And I decided to try this.
    When I add the following in the JSP tab:
    <h:outputText binding="#{Page1.tableHtml}" id="outputText1"/>Save.
    Then click on the Design tab, then go back to the JSP tab, I now have:
    <h:outputText binding="#{Page1.tableHtml}" id="outputText1"/>
    <h:outputText binding="#{Page1.outputText1}" id="outputText1"/>It's late here, but this doesn't make any sense, why would switching between Design and JSP tabs add code?
    Thanks,
    --Todd                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Girish: I followed these steps:
    1.) Downloaded:
    Sun Java Studio Creator 2, Multilanguage creator-2-windows-ml.exe 254.23 MB
    2.) When I started the install, I received the message:
    Welcome to Sun Java(TM) Studio Creator 2! You are installing: Sun Java Studio Creator 2 development environment Sun Java System Application Server Platform Edition 8.1 2005Q1 Update Release 2 Bundled database
    3.) Installed version:
    Product Version: Java Studio Creator 2 (Build 060120)
    IDE Versioning: IDE/1 spec=5.9.1.1 impl=060120
    Also, Under, the Palette window: Standard component list, there is a component labeled Output Text.
    When placed on a jsp, the following code is produced:
    <h:outputText binding="#{Page1.outputText1}" id="outputText1" style="position: absolute; left: 24px; top: 48px"/>Thanks,
    --Todd                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Differences between @EJB and @Resouce?

    Hi,
    I am confused about the differences between @EJB and @Resource?
    1.
    Can Session Beans be injected for both?
    If so what are the pro's / con's?
    2.
    Are the any difference between the type of components that cna be registered for one but not the other?
    3.
    Are they both equally usable with the ENC?
    Many thanks.

    @EJBs are 'special' resources. For example, @EJB (for a stateful session bean) results in
    1. Creation of the Stateful Session Bean,
    2. Other dependencies are injected into this newly created bean,
    3. If the bean has a @PostConstruct bean then that method is invoked (after invoking applicable interceptors)
    Hope this helps

  • Can objects be passed between Applets and JSP?

    Can objects be passed between Applets and JSP? If so how? Thanks in advance.
    Scott

    see if this helps,
    http://forum.java.sun.com/thread.jsp?forum=54&thread=136847

  • Relation between EJB and CORBA

    Hi,
    I'm confused as to the relation between EJB and CORBA. Some books I've read say that CORBA is used to implement the underlying RMI protocol in EJB while others say it is an alternative to EJB.
    Could someone please clarify.
    Thanks

    Could you pleae restate your question.
    I'm assuming you want to bind a Corba object to a
    CosNaming service from within a j2ee component. JNDI
    supports this case fully via their CosNaming service provider
    (see http://java.sun.com/products/jndi/serviceproviders.html) JNDI is part of J2SE, so it's fully available to any J2EE component.
    Amlan on behalf of Kenneth Saks

  • Juggle between jstl and jsp!

    I have a list of items and whose size is obtained by jstl as follows:
    <c:set var="num" value="${fn:length(form.namesList)}"/>I have to find the number of blocks using jsp and I am trying as follows which is giving jspException.
    <%int numCols = (int)Math.ceil( num / 10.0);%>Can anyone tell me the problem over here?
    I need to use numCols to display my results using jstl as follows:
    <c:forEach var="y" begin="${1}" end="${numCols }">
    </c:forEach>Can juggle between jstl and jsp like this?

    This depends on the version of JSP you are using:
    If you are using JSP 2.0 (like Tomcat 5), make sure you have downloaded and installed JSTL 1.1 and set the web.xml up to use the Servlet 2.4 specs. Then the code you wrote should work.
    If you are using JSP 1.x (like Tomcat 4 and below), make sure you have JSTL 1.0. Then you can only use EL (the Expression Language used to translate ${...} expressions) inside JSTL.
    If you want to use EL inside your custome tags, look through the Apache Jakarta sight. Somewhere they have an ELExpression translator (a couple of classes actually - whose full names I forget). These classes will let you take the ${...} expressions in as strings, pass them through the translators and get the correct objects back out.
    Or you could go a simpler root:
    <mob:whatever object="test" name="newname" />
    then in your custom tag:
      MyType test = (MyType)pageContext.findAttribute(object);
      test.setName(name);

  • 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

  • Difference between facelets and jsp xml in Document Type

    I want difference between facelets and jsp in Document Type in JDeveloper 11gR2 (11.1.2)
    Thanks
    Edited by: Amr Ahmed on Jun 8, 2011 7:46 AM

    Let's see.
    Facelets creates a facelets page
    JSP creates a JSP page
    {noformat}:){noformat}
    Facelets is the "official" view language for JSF 2.0
    http://www.realdevelopers.com/blog/development/facelets-vs-jsp should give you some more insight as well.
    John

  • Propagation of security between appplications and servers

    It appears that WebLogic propagates security between applications and
    domains using a cookie. So as long as all applications use the same
    cookie id (JSESSIONID) then a single sign-on is enabled between
    applications.
    Is it correct this would apply to propagation between portal and
    non-portal applications in the same clustered environment?
    In a different vein, is there a way of propagating security
    information between different servers or different clusters?
    Say, for example, server1 (or cluster1) allows a user to sign-in and
    presents a page with a link to server2 (or cluster2). We would like to
    be able to propagate transparently the security information gathered
    at the sign-in on server1 to the application on server2.
    I'm assuming the cookie placed in the browser from server1 would not
    be passed to server2. Is there a way, programmatically or otherwise,
    to enable this to occur in a secure way?

    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.

  • Where do I put classes shared between EJBs and WAR

    I have written some ValueObject classes stored in their own jar, they are used by a number of ejbs and and a Web application WAR. I have packaged the thing up as a single EAR but neither the EJBs or the jsps can see these classes.
    How do I share these classes at each end. is their a general deployment descriptor solution or is it application server specific.
    I am deploying to IBM Websphere 6

    verify .classpath file under your web folder for both options
    Sorry, what do you mean is their a classpath value in the xml descriptors. I put my ValueObject into a jar within the WEB-INF\lib of the WAR but these arent seen by the EJBs which are within the EAR but not the WAR. Im not aware that there is a seperate WEB-INF directory for the EAR.
    Structure as follows
    app.ear
            testejb.jar
            META-INF
            testweb.war
                   test.jsp
                   META-INF
                   WEB_INF
                         classes
                              testui.class
                         lib
                             valueobjects.jar

  • 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.

  • Common JAR file between EJB and WAR inside an EAR

    Hi,
    I'm trying to deploy an EAR application outside the development environment and I have the following problem.
    My EAR has the following structure :
    application.ear
    |-- ejbs.jar
    |-- web.war
    Inside the WAR, in /WEB-INF/lib/, I have a set of JAR files that are used by the Web app and also, of course, by the EJB.
    During the deployment step, EJB module cannot be deployed because it miss some classes into the classpath.
    I think it is a common problem in J2EE development, so does someone has a solution for this problem ?
    Please note I'm using Macromedia JRun 4 SP1 on Windows XP.
    Regards,
    Damien.

    Ok,
    I have found a solution that seems elegant to me. I'm going to try and explain...
    My appli.jar EJB module and my appli.war Web module are using both two JAR, let's say common.jar and util.jar.
    The way to share those JAR between the two modules is to have the following structure for the EAR :
    appli.ear
      |-- appli.jar
      |-- appli.war
      |-- common.jar
      |-- util.jar
      |-- META-INF
           |-- application.xml
           |-- manifest.mfIn this structure :
    * the common.jar and the util.jar are not part of the WAR (/web-inf/lib)
    * the manifest.mf file has the following content :
    Manifest-Version: 1.0
    Created-By: My Application
    Class-Path: common.jar util.jarPlease note that space is used as separator for the classpath entry to allow independancy from OS.
    And you know what ? It works ! Well, on Macromedia JRun 4.0 SP1 and on Windows XP but I hope it works on other platforms.
    I hope it will help a lot of people because I spent a lot of time before to find a solution !
    Regards,
    Damien.

  • What is different between strut and jsp+servlet+javabean?

    welcome

    Struts is a package that sits on top of the usual webapp stuff and organises and makes regular a lot of the stuff you wind up doing in servlets without it.
    It handles stuff like the objects you usually wind up using to pass data between JSPs and forms and servlets.
    It implements transaction stearing rules.

  • 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.

Maybe you are looking for

  • My box to send my ipod in expired how do i get a new one?

    I requested a repair and they sent me a box but the people never came back after we missed them the first time, now the box is expired please help, my warrenty is almost up and i have to send it in really soon!!

  • How to View User Report

    I had created a query and created the report by clicking create report button. But i am not aware how to view the report. I am unable to find appropriate menu item to view the user report. Kindly Help me. Farhan

  • Mp4 needing to be converted to flash for viewing

    Hi I have premier elements and I was hoping to be able to convert existing mp4 files to flash to use on a website.  I don't see how I can do that... any suggestions? Thanks. Debi

  • A problem with applications

    Hello. I have a problem. I have bought an iPad 3rd generation and my added applications do not work. Could anyone help me with that? Thank you.

  • What is procedure to post payment without reference

    Hi, I need to be able to post a negative payment in SAP without any reference to the original payment. I was wondering what the best procedure is for this? Thanks.