How creating a session in a bean...

Hi guys,
i've developing a jsf application. I'm new of jsf and java,so please help me.
I've a login page,i want user inserts his data and click a button that does authentication.
When authentication is performed i need to create in my authenticateMethod a session in which storing user data.
How can i do it?
this is my authenticateMethod
i skip authentication code...
User user=new User();
                                        user.setLogin(loginName);
                                        user.setTeamname(teamName);
                                        user.setLoggedIn(true);
now i have to store user in a session.
Can you help with easy code?
Later i set a timeout in web.xml.
How can i check if another user tries to log in with same data while my user is navigating?
That is how can i check if there is a user with same username and teamname yet logged?
Please help me with easy code,thanks very much.
Excuse my inexperience and my poor english

Session session = (Session) FacesContext.getCurrentInstance().
                                           getExternalContext().getSession(true);The documentation is here http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/index.html
matfud

Similar Messages

  • Creating a Session & Entity bean in Weblogic

    Hii javaities
    I am new 2 EJB , and i want 2 create a apllication using EJB.
    I want 2 create a session , and entity bean in WEblogic.
    Can anybody help me i this
    Or if u have some good links , plz pass it 2 me.
    Thanking in anticipation

    http://java.sun.com/blueprints/corej2eepatterns/Patterns/SessionFacade.html
    http://www.oracle.com/technology/sample_code/tech/java/j2ee/designpattern/businesstier/sessionfacade/readme.html
    google search for more.

  • How to create a session cookie on demand

    Hi,
    I search the web but couldn't find anything related to creating session cookies on demand. I want to create a session cookie storing encrypted user tokens when there is none, for example, when the first page is called.
    The encryption part is OK, but I want how can I intercept every call to a set of pages and create the session cookie if it doesn't exist.
    I'm using ADF, of course, and Weblogic.
    Anyone can provide some examples or source code?
    Thanks.

    Cookies are accessible via the http request and response, there you can add new cookies and or change existing ones.
            ExternalContext ectx = FacesContext.getCurrentInstance().getExternalContext();
            HttpServletResponse response = (HttpServletResponse) ectx.getResponse();
            // get existing cookies
            Cookies [] cookies =((HttpServletRequest)ectx.getRequest()).getCookies();
            // create and set a new one
            Cookie cookie = new Cookie( "key", "value" );
            response.addCookie( cookie );This code should work in a bean. After setting the cookie you need to implement a servlet filter or a page phase listener where you check the requested url and then check for your cookie.
    Timo

  • How many ejbCreate() can be in Session and Entity Bean???

    Hi,
    How many ejbCreate() method can be in a Session and Entity
    Bean???
    How many can be in Stateless and Stateful SessionBean???
    How many can be in CMP and BMP SessionBean???
    Thanks,
    JavaCrazyLover

    How many ejbCreate() method can be in a Session
    ion and Entity
    Bean???For Stateful Session Beans and Entity Beans, as many as you'd like.
    Stateless Session beans can only have one, since their ejbCreate methods can not take any parameters.
    >
    >
    How many can be in CMP and BMP SessionBean???If you mean CMT/BMT(Container-Managed transactions / Bean-Managed Transactions), then
    the answer is the same. The create method requirements are independent of the transactional nature of the bean.
    If you really mean CMP/BMP(Container-Managed Persistence / Bean-Managed Persistence) , it doesn't apply to session beans, only entity beans. However, even for entity beans, CMP vs. BMP has no bearing on the rules regarding # of create methods.
    --ken
    >
    >
    Thanks,
    JavaCrazyLover

  • How do I create a session with the datasource set in code not sessions.xml

    I want to create a session where I specify the J2EE datasource name dynamically in code. Normally, I would hard-code a J2EE datasource name in sessions.xml e.g.
    <login>
    <datasource>jdbc/MyApplicationDS</datasource>
    <platform-class>oracle.toplink.platform.database.oracle.Oracle10Platform</platform-class>
    <uses-external-connection-pool>true</uses-external-connection-pool>
    <uses-external-transaction-controller>true</uses-external-transaction-controller>
    </login>
    However, we don't want to use a hard-coded string "jdbc/MyApplicationDS". We want to be able to set this at runtime.
    I found this in the App Developer's Guide:
    Configuring an External Connection Pool in Java
    To configure the use of an external connection pool in Java:
    1. Configure the DataSource on the server.
    2. Configure the Login to specify a DataSource and the use of an external connection pool:
    login.setConnector(
    new JNDIConnector(new InitialContext(), "jdbc/MyApplicationDS"));
    login.setUsesExternalConnectionPooling(true);
    and this:
    Configuring Sessions with the sessions.xml File
    OracleAS TopLink provides two ways to preconfigure your sessions: you can export and compile Java source code from the OracleAS TopLink Mapping Workbench, or use the OracleAS TopLink Sessions Editor to build a session configuration file, the sessions.xml file.
    It seems like I should export and compile Java code that calls login.setConnector(), but I can't find out any information on how to do this. I looked at the MW user guide and I didn't see anything on this.
    I also found this by searching this discussion forum:
    To create a server session completely from code given a project you can use,
    project.getLogin().setConnector(new JNDIConnector(new InitialContext(), "your-datasource-url"));
    project.getLogin().setUserName("");
    project.getLogin().setPassword("");
    Server server = project.createServerSession();
    server.login();
    However, I don't know how to get the project.
    Thanks,
    Vicki

    If you are using a sessions.xml file, you can get your project from your session. Ensure that when you access your session from the SessionManager, that you do not have it login.
    Session session = SessionManager.getManager().getSession("my-session", false);
    session.getProject().setConnector(...);
    session.login();
    If not using a sessions.xml, you can either read your Project from the XMLProjectReader, or instantiate your Project class directly.

  • How do I create a session?

    In order to use methods like getValidSessions() in the Session class of the SessionAPI for iPlanet Portal Server, I need a Session object. There is no obvious way to construct one based on the javadocs. I can get one from a SessionID object, but in order to create a SessionID object, I need a HTTP request or an encrypted string, i.e. SessionID( String sid ). How can I create a Session object, or how can I create a SessionID object (which will allow me to get a Session object)? Any help is much appreciated. NOTE: I'm building a plain Java utility to use the Portal Server API to retrieve session and profile information, and I'm not implementing it as a servlet.

    From com.iplanet.portalserver.providers.ProviderAdapater use the getSession() method whish returns com.iplanet.portalserver.session.Session object
    Then from Session class use the method getValidSessions()method

  • App No Longer Works After Creating EJB Session Bean

    I am using EJB3.0 and using JDEV 11g, PS1. I have used EJB to create my entities from tables and then i created my ejb diagram. After doing that my application (i have a jspx page) that runs fine. Once I create my session bean, I am no longer able to run my application. After creating my session bean I get the following error when I run the application (i.e. not at build/compile time).
    <Feb 12, 2010 3:28:57 PM PST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID '1266017332257' for task '5'. Error is: 'java.lang.ClassNotFoundException: javax.faces.webapp.ConverterELTag'
    java.lang.ClassNotFoundException: javax.faces.webapp.ConverterELTag
    If i delete the sessionejb.java, ejbbean.java, and the ejblocal.java files, I am able to run my application again. Am I missing something or is this a bug?
    Thanks.

    Did you solved the problemn? I'm getting this, when I try run my App doesn't work, but if I deploy to WLS Integrated and go to URL it's work...

  • How to Create a Session variable in JSP?

    How to create a session variable and add attributes to it?
    For example i want to create a session variable called "name" and add value "user" to it? if i try to do it with setAttribute(), it is giving error as both is of type string? how to do it? kindly help me

    This is variable what is working in my aplication
    String variable;
    if(user == null){
                   user=new String("");
         }//if you don'y do this you will have null pointer exception
    session.setAttribute("user",user);//put value
              String name=(String)session.getAttribu("user");      //get value;
    I hope this will help

  • How to create a session variable in Apex?

    Hello colleagues,
    Is there someone do know how to create a session variable in Apex?
    How to get them?
    Thanks
    Best Regards

    Hello,
    What do you mean by 'session variable'? You mean something that stores the value int he users session state?
    I really recommend reading the 2-Day Developer guide documentation, there is a complete section on session state -
    http://download.oracle.com/docs/cd/E10513_01/doc/appdev.310/e10499/concept.htm#CIHCFHBD
    Hope this helps,
    John
    Blog: http://jes.blogs.shellprompt.net
    Work: http://www.apex-evangelists.com
    Author of Pro Application Express: http://tinyurl.com/3gu7cd

  • How to create a session by AppsLocalLogin.jsp

    first, in auth.jsp we check fnd_global.user_name against "ANONYMOUS" to see whether user is logged on.
    if not, we invoke AppsLocalLogin.jsp to create a session.
    http://server:port/OA_HTML/AppsLocalLogin.jsp?requestUrl=report.jsp%3Fparam1%3Dyyy
    the login page shows, page re-directed to report.jsp.
    however fnd_global.user_name doesn't work. it still returns "ANONYMOUS".
    if user logged on OA normally, then the whole thing worked. it seems fnd_global.user_name doesn't like the way we login.
    how should we invoke AppsLocalLogin.jsp so it'll create a proper session?
    part of report.jsp:
    WebAppsContext ctx =WebRequestUtil.validateContext(request, response);
    conn = ctx.getJDBCConnection();
    sql = "select fnd_global.user_name from dual";
    (we tried to invoke RF.jsp instead.
    doesn't work because we don't know how to pass the param1 to report.jsp thru RF.jsp)

    This is variable what is working in my aplication
    String variable;
    if(user == null){
                   user=new String("");
         }//if you don'y do this you will have null pointer exception
    session.setAttribute("user",user);//put value
              String name=(String)session.getAttribu("user");      //get value;
    I hope this will help

  • How to create another session for a help page ?

    Hello
    I am trying to create help system for an application, which would be similar to apex's own help system. The main thing is that the help page/application/procedure would run independently of the calling application, and therefore it needs to create another session, I suppose ? How do you implement that ? I have also tried to find description of the package wwv_flow_help, but haven't found anywhere. Is it useful here ?
    Thanks for any comments

    If the link is from a page in your application then that's exactly what you want to do using javasScript to open a new window but keeping the same session ID in the request. In this way, when the new request is received by the Application Express engine, it will have the session cookie that goes with the specified session ID.
    Scott
    P.S. You can help us by telling us your first name and putting it into your handle and/or profile.

  • Exception creating stateless session bean

    hello, can some one tell what is the cause and the solution of the folowing exception :
    EJB5070 Exception creating stateless session bean : [{0}]
    com.sun.enterprise.InjectionException: Exception attempting to inject Env-Prop: ejb3.INplateformFacade/timerService@Field-Injectable Resource. Class name = ejb3.INplateformFacade Field name=[email protected]@ejb3.INplateformFacade/timerService@@ into class ejb3.INplateformFacade
    at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:387)
    at com.sun.enterprise.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:206)
    at com.sun.enterprise.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:127)
    at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:533)
    at com.sun.ejb.containers.StatelessSessionContainer.access$100(StatelessSessionContainer.java:111)
    at com.sun.ejb.containers.StatelessSessionContainer$SessionContextFactory.create(StatelessSessionContainer.java:772)
    at com.sun.ejb.containers.util.pool.NonBlockingPool.getObject(NonBlockingPool.java:199)
    at com.sun.ejb.containers.StatelessSessionContainer._getContext(StatelessSessionContainer.java:486)
    at com.sun.ejb.containers.BaseContainer.getContext(BaseContainer.java:1675)
    at com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:1229)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:195)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:127)
    at $Proxy63.tachePlanifier(Unknown Source)
    thanx on advance

    i dont think so it is a typo in the name.
    here is my source code :
    @Stateless
    public class INplateformFacade implements INplateformFacadeLocal {
        @PersistenceContext
        private EntityManager em;
        private Date datePrevis;
        @Resource
        TimerService timerService;
        @Timeout
        public void traitementPlanifier(Timer timer) throws NamingException {
            listerLeReprtoir(ChercherReprtoir());
        public void tachePlanifier(Date datePrevis) {
            this.datePrevis = datePrevis;
            timerService.createTimer(datePrevis, null);
        }

  • HOW CAN I KNOW THE FUNCTION CODE OF CREATE NEW SESSION

    <b>HOW</b> CAN I KNOW THE FUNCTION CODE OF CREATE NEW SESSION?
    THANKS...

    Hi
    Please put a "/n" (to open a new session after killing the current session)
    or "/o" (to open a new session without killing the current session)
    or "/i" (to end the current session) before the below T Codes as per your requirement...
    Try thistoo <b>O0</b>
    <u><b>demo-like programs</b></u>
    RSIMC000
    RSIMC001
    RSIMC002
    RSIMC003
    RSIMCTRX
    RSIMCTST
    Reward all helpfull answers
    Regards
    Pavan

  • Creating a session bean automatically on deployment

    Hi,
    I want to create a session bean automatically on deployment of my application to the container. Is this possible?
    Thanks!

    Create a servlet as a Ejb client & specify the client servlet
    in the <load-on-startup> element of the web.xml deployment descriptor.

  • How invalidate a session managed bean

    I have a faces-config. xml file with the following content:
    <managed-bean>
    <managed-bean-name>pc_mybean</managed-bean-name>
    <managed-bean-class>mybean</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    For some reasons I needed to put it as session.
    Now I would like to know if there is a way to invalidate the session bean. Does someone know? How can I access to the bean with my java code?
    Thanks a lot.
    Didi

    the method to invalidate the bean:
         public static void resetManagedBean(String beanName) {
              getValueBinding(getJsfEl(beanName)).setValue(FacesContext.getCurrentInstance(), null);
         private static ValueBinding getValueBinding(String el) {
              return getApplication().createValueBinding(el);
         public static String getJsfEl(String value) {
              return "#{" + value + "}";
         }

Maybe you are looking for

  • How can I triple boot with OSX, Windows XP, and Windows 7 RC?

    Here's the short story: I have OS X 10.5 and Windows XP on an internal drive. My goal is to install the Windows 7 RC on a bootable external drive connected through eSATA Currently: I used Winclone to copy my XP partition (with a different-looking des

  • Snapshot too old error occured, kindly need solution for it...

    Dar friends I got snapshot too old error on most used database Kindly give me the solution.... my solution was Alter rollback segment <rollback segmnt name> datafile '<path>/filename.dbf' resize <no>k; or alter rollback segment <rollback segmnt name>

  • Some question about control file

    Hello, ALTER DATABASE BACKUP CONTROLFILE TO TRACE - in my case I have three control files. The above command will generate the SQL command for regeneration of all three control files? - is there any way to find in which trace file the SQL script will

  • High CPU and Delay when applying metadata

    Hi All: I have an issue where my CPU hits 60% when applying keywords. This can be when I apply it to one image or to 100s. Obviously, when I have more pictures selected or more keywords, there is a much larger delay. Ideas from anyone? Thanks

  • Auditing tables - What are the best possible ways of doing it?

    Hello Everyone, DB version: 10g. Brief description of the problem: Right, now I am working on an application which has a java frontend and oracle backend. We have no access to the java code at all. So, it is a complete blackbox. . Just wondering, if