How to Instantiate a bean inside a LoginServlet before redirecting toanothe

Hi there
I am writing a Login Servlet where i am validating a user.
If he is successful i am redirecting to members page say main.jsp
on links to main.jsp page i want to use beans like addressbook and userprofile on other jsp pages like addressbook.jsp and userprofile.jsp so that user can add or modify them as per his requirement
i have access to the database tables coreesponding to these these beans in the login servlet itself.
My question is How to do this as well as how to check for sessions across multiple pages and remember the logged in user and his bean instances which i want shared across multiple pages
Its urgent
Thanking u in advance
Mumtaz
India

Hi There
Could u please tell if i can put more than one beans inside the session object and then use it on all pages
Also will my appln be safe for more than one user
because i am getting all the details of that specific user in the LoginServlet
Help appreciated

Similar Messages

  • Instantiate a bean from within a Servlet

    I am attempting to instantiate a bean from within a Servlet. Basically, I would like to set my bean properties from within a central controlling servlet, then call a worker class to take care of my database insert. The worker class would get its values from the bean.
    Does this sound reasonable? I'm sure this is quite possible and very easy to pull off, however I can't seem to find a single example. An example would be greatly appreciated.

    Hi,
    I have read what you have done.
    Now in the servlet add something like
    HttpSession ses=request.getSession(true);</stro
    ses.addAttribute("user","your Bean name");*
    in the JSP get this atribute by
    session.getAttribute("user");+
    Anyway, how have you configured your server? I am using a Bean Class and trying to instantiate in a sevlet. An exception is occuring.
    import mypack.User; //it is nicely imported*
    //in the doPOST() method
    User user=new User();+ //trying to instantiate
    it is giving an Exception. Kindly help.

  • TEI class- want to instantiate a Bean into the page

    I have a TEI class which I am using to add an object to the page.
              I am able to address this object by using (psuedo code below)
              <%= object.getName() %>
              however, if I try to call the object with a usebean tag, like
              <jsp:getProperty name="object" property="Name"/>
              I get an error:
              /myfile.jsp(40): object is not defined as bean
              probably occurred due to an error in /myfile.jsp line 40:
              <jsp:getProperty name="object" property="Name"/>
              any ideas on how to instantiate an object into the page so that it is a
              bean?
              right now I am using the code from the API_taglib.html document:
              public VariableInfo[] getVariableInfo(TagData data) {
              return new VariableInfo[] {
              new VariableInfo("object",
              "fully.qualified.classfilename",
              true,
              VariableInfo.NESTED),
              

    Josh, I think you have to use "useBean". i.e. <jsp:useBean id="object"
              class="java.lang.Object" scope="page | request | session | application">
              before you can reference.
              -E
              Josh Lannin wrote:
              > I have a TEI class which I am using to add an object to the page.
              > I am able to address this object by using (psuedo code below)
              >
              > <%= object.getName() %>
              >
              > however, if I try to call the object with a usebean tag, like
              >
              > <jsp:getProperty name="object" property="Name"/>
              > I get an error:
              >
              > /myfile.jsp(40): object is not defined as bean
              > probably occurred due to an error in /myfile.jsp line 40:
              > <jsp:getProperty name="object" property="Name"/>
              >
              > any ideas on how to instantiate an object into the page so that it is a
              > bean?
              >
              > right now I am using the code from the API_taglib.html document:
              >
              > public VariableInfo[] getVariableInfo(TagData data) {
              > return new VariableInfo[] {
              > new VariableInfo("object",
              > "fully.qualified.classfilename",
              > true,
              > VariableInfo.NESTED),
              > };
              > }
              

  • Can I include a bean inside a customization project?

    Hi,
    I am customizing out-of-the-box Profile (.jsff) pages. I'll have to create a bean which will get binary data from Oracle. I have a project to customize the Profile pages. Can I include the bean inside the project? Or, should I create a separate project, and have the pages referenced to the bean class. How should I go for that?
    Many Thanks

    Hi,
    For now, you can change any attributes on user's profile page like department and etc. What's about if I want to create a dynamic drop-down department list for a user to pick? The department list will be generated from a database source. In jdeveloper, you can have various roles. I'm switching back and forth between 'default' and 'customization' roles. In the default role, I'm going to create a javabean to create the dynamic department list. In customization role, I customize the 'look and feel' of the profile page. This is kind of pain in the neck. Am I going to a wrong direction? Is there anyway of getting the work done without switching.
    Secondly, on the profile page, I use EL to reference an attribute in a javabean. But, when I load the page, it errors out.
    <Jan 24, 2012 3:16:22 PM EST> <Warning> <oracle.adf.view.rich.component.fragment.UIXRegion> <ADF_FACES-00009> <Error processing viewId: /edit-basic/view1 URI: /oracle/webcenter/peopleconnections/profile/view/jsf/regions/ootbedit/editbasic.jsff actual-URI: /oracle/webcenter/peopleconnections/profile/view/jsf/regions/ootbedit/editbasic.jsff.
    javax.el.PropertyNotFoundException: Target Unreachable, identifier 'PersonBean' resolved to null+
    at com.sun.el.parser.AstValue.getTarget(Unknown Source)
    at com.sun.el.parser.AstValue.isReadOnly(Unknown Source)
    at com.sun.el.ValueExpressionImpl.isReadOnly(Unknown Source)
    at oracle.adfinternal.view.faces.renderkit.rich.EditableValueRenderer._getUncachedReadOnly(EditableValueRenderer.java:486)
    at oracle.adfinternal.view.faces.renderkit.rich.EditableValueRenderer.cacheReadOnly(EditableValueRenderer.java:416)
    Any help would be appreciated. Thanks.
    Edited by: 891549 on Jan 26, 2012 9:45 PM

  • How to refactor managed bean

    Disclaimer: I am very new to ADF.
    I have a fragment that uses a pageFlow scoped managed bean. Everything works fine but now I have to extract a piece of that fragment and use it into another fragment. I would like to extract all parts related to that fragment into a specific managed bean and then use that managed bean into the "parent" managed bean. To clarify what I want to do:
    Current:
    public class BigManagedBean {
    private String classMemberSpecificToA;
    private String classMemberSpecificToB;
    Refactored:
    public class BigManagedBean {
    private SpecificToAManagedBean aBean;
    private SpecificToBManagedBean bBean;
    public SpecificToAManagedBean {
    private String classMemberSpecificToA;
    public SpecificToBManagedBean {
    private String classMemberSpecificToB;
    Q: How to instantiate aBean and bBean? What is the best practice for doing that?
    ADF 11.1.1.6

    Three ways:
    1) instantiate the variable with the bean
    public class BigManagedBean {
    private SpecificToAManagedBean aBean = new SpecificToAManagedBean ();
    private SpecificToBManagedBean bBean = new SpecificToBManagedBean ();
    2) in the constructor of the big bean
    public class BigManagedBean {
    private SpecificToAManagedBean aBean;
    private SpecificToBManagedBean bBean;
      public BigManagedBean()
        aBean = new SpecificToAManagedBean ();
        bBean = new SpecificToBManagedBean ();
    3) in the getter of aBean
    public class BigManagedBean {
    private SpecificToAManagedBean aBean = null;
    private SpecificToBManagedBean bBean = null;
      public SpecificToAManagedBean getABean()
        if (aBean == null)
             aBean = new SpecificToAManagedBean ();
        return aBean;
    Timo

  • How to call a bean from a form?

    hi all
    i want to write a simple bean that checks the login information (userId ad Password) passed to it by a form in my jsp file.
    so i think i have to call the setUser() and setPassword() methods of my bean in a single action... how to do it?
    I also thought i can do it by calling a JavaScript, by I dont know how....
    then, once i get the boolean value (logged) returned from my bean, i can (through jsp) redirect the logged user to another page, or send a message to the non-logged user.
    is it a good solution or should I do it with a servlet?
    thanx for your answers
    sandro

    u can do it using a servlet or JSP itself. Check the sample code below to see how u can validate using values from form
    <%
    String username=request.getString("frmUser");
    String password=request.getString("frmPassword");
    urBean userBean = new urBean(); //Creating instance of ur bean class.
    userBean.setUserName(username); //Setting username
    userBean.setPassword(password); //Setting password
    boolean flag = userBean.validate(); //This functions validates against a database.
    if(flag) {
    response.sendRedirect("loggedin.jsp"); //redirects to page on successfull login
    }else{
    response.sendRedirect("error.jsp"); //redirects to error page.
    %>
    Hope this helps
    Biju

  • How do you create beans using NetBeans 5.5?

    I am referring to http://java.sun.com/docs/books/tutorial/javabeans/nb/index.html and I'm sorry but I can't follow any of this!
    I have NetBeans IDE 5.5 and I am trying to learn how to write beans using NetBeans, and the lessons involve things I can't find or understand, for example:
    re: http://java.sun.com/docs/books/tutorial/javabeans/writingbean/index.html
    <blockquote>
    Load the JAR file. Use the NetBeans IDE GUI Builder to load the jar file as follows:
    1. Start NetBeans.
    2. From the File menu select "New Project" to create a new application for your bean. You can use "Open Project" to add your bean to an existing application.
    3. Create a new application using the New Project Wizard.
    4. Select a newly created project in the List of Projects, expand the Source Packages node, and select the Default Package element.
    5. Click the right mouse button and select New|JFrameForm from the pop-up menu.
    6. Select the newly created Form node in the Project Tree. A blank form opens in the GUI Builder view of an Editor tab.
    7. Open the Palette Manager for Swing/AWT components by selecting Palette Manager in the Tools menu.
    8. In the Palette Manager window select the beans components in the Palette tree and press the "Add from JAR" button.
    9. Specify a location for your SimpleBean JAR file and follow the Add from JAR Wizard instructions.
    10. Select the Palette and Properties options from the Windows menu.
    11. Expand the beans group in the Palette window. The SimpleBean object appears. Drag the SimpleBean object to the GUI Builder panel.
    </blockquote>
    Sorry, you lost me literally after "Start NetBeans", the rest is Hungarian. I can't find "New Project Wizard"; I can't find "List of Projects", I can't find anything they are talking about nor do I know if any of this is relevant toward my learning how to write beans.
    Re: http://java.sun.com/docs/books/tutorial/javabeans/properties/properties.html
    "Inspecting Properties" seems impossible to do because the Inspector Window only shows a closed folder and nothing else ever. I can't figure out this part of the tutorial either.
    Can someone please explain this 3rd-grade-level to me: How to create a bean using NetBeans?
    Thanx
    Phil

    Phil,
    Before you embark on another very frustrating advanture using NetBeans, please go t hrough the NetBeans tutorial. The "New Project Wizard" is just select from the menu options -- "New Project". The "Hungarian" as you put it will not get better until you spend some time learning NetBeans. Learning something new, like beans, is frustrating enough, but to try to do it and use a tool that is not familiar may be beyond many individuals frustration level.
    Les

  • How to register one MBean inside another MBean

    Hi All,
    When i try to register one MBean(DynMBean1) inside another(DynMBean2) by passing object name of this MBean as attribute to the other MBean,iam getting the following error:
    Following shows the adapter interface
    List of MBean attributes:
    Name Type Access Value
    DynBean2 java.lang.ObjectName RW Type Not Supported: [                                                      [DynBean2:bean=sample]
    name java.lang.String RW
    if the above code works properly,in the ''value' column there should be ''view' button and only [DynBean2:bean=sample]' should be present in the value column.Also,if we click on Can any predict what the problem is......?
    Regards
    Ravi
    Mail Me:[email protected]

    I don't understand what you mean by register a bean inside another bean.

  • How to call a bean method from javascript event

    Hi,
    I could not find material on how to call a bean method from javascript, any help would be appreciated.
    Ralph

    Hi,
    Basically, I would like to call a method that I have written in the page java bean, or in the session bean, or application bean, or an external bean, from the javascript events (mouseover, on click, etc...) of a ui jsf component. I.e., I would like to take an action when a user clicks in a column in a datatable.
    Cheers,
    Ralph

  • How to create a Custom UIView and How to instantiate that ?

    How to create a Custom UIView and How to instantiate that ?
    In Flash, all we need to do is create a MovieClip and assign it a class name in the library.
    Instantiation is a simple matter of:
    var newclass:CustomClass = new CustomClass({initialization_data:1652});
    addChild(newclass);
    At this current point in time, my understanding of creating custom UIView in xcode is limited to the understanding that you have to:
    1: Forward declare the class in the header.
    2:
    ]newclass *CustomClass in @interface's {}
    and THEN
    @property (nonatomic, retain) newclass *CustomClass;
    in the header file also.
    3: Nib initialization in the implementation file in viewDidLoad and do "addSubview".
    ==============================
    Based on my limited understanding at this point, I find the need to
    @property (nonatomic, retain) newclass *CustomClass;
    at the header somewhat limiting...as it denotes you must know how many instance you will create in the application before hand.
    I believe I am wrong here, hence, my question is, how do I add custom UIViews with initialization codes in real time ?

    hi,
    one workaround i could think of is using the CM views to search for content that belongs to a category and display it in a custom way.
    http://www.oracle.com/technology/products/ias/portal/html/plsqldoc/pldoc904/wwsbr_api_view.html
    this only allows you to search for the meta-data available in the CM views but not the content of an item that is available when doing a search.
    in the next major portal release we will have a publich search API that can be used for these type of requirements. you can execute your search and format the results in the way you want.
    regards,
    christian

  • How to populate Java Beans List from the DB ?

    Hi,
    I have three tables called State,District and College.
    Assume, State table has fields statid,statename,statedescr
    District table has fields districtId,districtname,districtdescr and stateid
    College table has fields collegeid,collegename,collegedescr and districtid
    and all ids for the respective tables are primary keys .. and District and College tables have foriegn keys as expected...
    I want to send the whole information to the front end... I had designed three beans StateBean,DistrictBean and CollegeBean.. where all the three beans will have the related fiields and respective getter and setter methods like below
    StateBean -- stateid,stateName,stateDesc and DistrictBeanList
    DistrictBean -- districtid,districtName,districtDesc and CollegeBeanList
    CollegeBean -- collegeid,collegeName,collegeDesc
    I would like to have the JDBC code (any driver,any DB) so that I need to build one StateBeanList (collection of all the statebeans information) ... (like how to write the query to get the whole information from the DB and populate the same into one list..(Query or queries + resultset operation)
    I hope you understand my problem ...
    Please let me know if I have to be more clear...
    Thanks in Advance,
    Vidhya...

    Thanks Sachin,
    Atleast you understand something of my requirement..
    But Actually I want the logic like
    if the query is like
    select * from State
    while(rs.next) {
    StateBean object = new StateBean(); // StateBean
    object.yourcorrespondingsetter(rs.getString(1));
    object.yourcorrespondingsetter(rs.getString(2));
    object.yourcorrespondingsetter(rs.getString(3));
    object.setDistrictBeanList(districtbeanlistalreadypopulated); // how to populate the list of districtBeans list before ....
    listobject.add(object ); // object internally has to have districtBean list, so the district bean list has to be loaded with all the distrct Beans in which every DistrictBean will be loaded with list of CollegeBeans ... Which district belongs to which state and which college belongs which district is all there in the table information ...
    Now I want the query or queries to do that .... Can someone help me ?
    Please let me know if I have to be more clear...
    }

  • How to debug a bean in JSP page with JBX???

    How to debug a bean in JSP page with JBX???
    i have a bean within a JSP page. i wanna find out how do they varibles work and changes of them values.
    are there some ways or tools to get the situations of them in visual way? just like when i debug VB program,i can get the situations in immediately window.

    help me !!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • How to call the bean in jspdyn component?

    Hi,
    i created  jspdyn component in that bean and bussiness logic class in NWDS.i created a method() in that businesslogic class.i called that method in bean class.i created both in same package,there is no error occur while creating the object of that class.but the bean class not recognize the business class method which i created. What is the cause? and also tell me how to call the bean in jsppage also.and also give me textfields,button and syntax of event handling in HTMLB,iam new to this area.so,give me one example step by step.

    Hi,
         Please check on these links for a good start.
    Java development methodologies (Part II)
    Bean usage in JSPDynPage
    jspDynPage portalapp.xml
    Regards,
    Harini S
    Please avoid giving personal mail id(s). That may prevent others from getting the same information when needed.

  • How do i delete cookies inside my program????

    I have a login page. I want to check whether cookies are available, if any for this user or not? And if available i want to delete previous one's. How do I do this inside my program???? Can any body help me on this issue??????? pls.
    Thanks $ Regards
    Shashi

    Search javax.servlet.http.Cookie API for that.
    You can search cookies with getCookies method in the HttpServletRequest
    You delete your cookie setting it a max age value of 0
    setMaxAge(0)

  • How to use Java Beans In JSTL?

    Hi
    I want to know how to use Java bean in JSTL
    please explain this with giving any one example.
    Thanks-
    Swapneel

    A bean is obtain by <jsp:useBean> tag nd once bean is obtained we can get its property by using getProperty tag.

Maybe you are looking for