JavaBeans handled properly in session scope only

When implementing own ActionListeners and trying to retrieve data from
the modified JavaBean, i get a nullpointer exception if the javabean is defined not in session-scope. In my example below, the bean "UserManager" can be acessed, if it is defined as session bean. Since this is not necessary, i would prefer this bean to be in request scope.
public class UmaActionListener implements ActionListener {
     public void processAction(ActionEvent arg0)
          throws AbortProcessingException {
          String command = arg0.getActionCommand();
FacesContext context = FacesContext.getCurrentInstance();
if (command.equals("change")) {
UserDataBean bean =
( UserDataBean)Util.getValueBinding("UserManager").getValue(          context);
System.out.println("CHANGE="+bean.getEmail());

The ActionListener code you quote should work fine if "UserManager" actually exists as a request attribute when the event handler is called. But you will have had to put the UserManager there already -- nothing in JavaServer Faces will do that automatically.
Craig McClanahan

Similar Messages

  • Any session scope form handler out of the box in atg commerce

    Is there any session scope form handler out of the box in atg commerce. Let me know if anyone is aware of such form handler.
    Thanks,
    Santosh

    Search based formhandlers are some that come to my mind
    CategorySearch (/atg/commerce/catalog/CategorySearch (DCS))
    CatalogSearch(/atg/commerce/catalog/CatalogSearch (DCS))
    ProductSearch(/atg/commerce/catalog/ProductSearch ((DCS))
    Incidentally i think all of them point to SearchFormHandler
    Few others i can this of are
    GiftListFormHandler
    CompareSkusFormHandler (deprecated i guess)
    CatalogSearchFormHandler (Extension of SearchFormHandler class)
    There could be many more , updates / additions will be nice
    adding
    AdvProductSearch
    ProductTextSearch
    Edited by: Sundar on Dec 4, 2012 3:42 AM

  • Session scope quary

    hi friends,
    i have a requrement to store FileItem(uploaded file using apache fileupload classes) objects in session scope using setAttrubute method.
    would it be reliable to store these objects in session scope, so that further i can retrieve it again without having any problem?
    is there any other solution?

    The HTTP session is visible within the context scope of an individual user. This means that the only time that an object wouldn�t be simultaneously accessed would be if the user opens a couple browser windows using the same encode session id in the URL�s and uses\submits them simultaneously.
    I guess that you could have the same distributed object EJB cache in session scope for two users but that should be handled for you by the EJB container.
    I suppose the WebSphere session management in the web container has an option to maintain a common session across applications based on the users authentication. I can�t see how this could be a good thing....
    You will want to cache objects in request scope when you don�t need to maintain state passed the request response lifecycle assuming that you are not using a heavy client caching system.
    Objects in session scope will persist until the session is invalidated or the browser session is terminated.

  • How to get a parameter from each request in a session scope BackingBean

    While calling my JSF page, I pass an id as parameter in the URL, and in the Backing bean I retrieve it from the request.
    On each request I need to get the id and populate the page accordingly.
    But I am forced to create my Backing Bean in session scope b'cos otherwise ValueChangeListener method does not work properly.
    So where and how do I get the id on each request?
    Pls. help

    What you can do is create it in the request scope like this:
    <managed-bean>
          <managed-bean-name>personBean</managed-bean-name>
          <managed-bean-class>
            com.PersonBean
          </managed-bean-class>
          <managed-bean-scope>request</managed-bean-scope>
           <managed-property>
                 <property-name>id</property-name>
                 <property-class>java.lang.Long</property-class>
              <value>#{param.id}</value>
          </managed-property>
    </managed-bean>And then in the page use a hidden field to set the id in case of a postback (validation error):
    <h:inputHidden id="id" value="#{personBean.id}"/>Does that help you?
    Thomas

  • Problem with beans in session scope

    Hello,
    I developped a website using JSP/Tomcat and I can't figure out how to fix this problem.
    I am using beans in session scope to know when a user is actualy logged in or not and to make some basic informations about him avaible to the pages. I then add those beans to an application scope bean that manages the users, letting me know how many are logged in, etc... I store the user beans in a Vector list.
    The problem is that the session beans never seem to be destroyed. I made a logout page which use <jsp:remove/> but all it does is to remove the bean from the scope and not actualy destroying it. I have to notify the application bean that the session is terminated so I manualy remove it from its vector list.
    But when a user just leave the site without using the logout option, it becomes a problem. Is there a way to actualy tell when a session bean is being destroyed ? I tried to check with my application bean if there are null beans in the list but it never happens, the user bean always stays in memory.
    Is there actualy a way for me to notify the application bean when the user quits the website without using the logout link ? Or is the whole design flawed ?
    Thanks in advance.
    Nicolas Jaccard

    I understand I could create a listener even with my current setup Correct, you configure listeners in web.xml and they are applicable to a whole web application irrespective of whether you use jsp or servlets or both. SessionListeners would fire when a session was created or when a session is about to be dropped.
    but I do not know how I could get a reference of the application bean in >question. Any hint ?From your earlier post, I understand that you add a UserBean to a session and then the UserBean to a vector stoed in application scope.
    Something like below,
    UserBean user = new UserBean();
    //set  bean in session scope.
    session.setAttribute("user", user);
    //add bean to a Vector stored in application scope.
    Vector v = (Vector)(getServletContext().getAttribute("userList"));
    v.add(user);If you have done it in the above fashion, you realize, dont you, that its the same object that's added to both the session and to the vector stored in application scope.
    So in your sessionDestroyed() method of your HttpSessionListener implementation,
    void sessionDestroyed(HttpSessionEvent event){
         //get a handle to the session
         HttpSession session = event.getSession();
          //get a handle to the user object
          UserBean user = (UserBean)session.getAttribute("user");
           //get a handle to the application object
          ServletContext ctx = session.getServletContext();
           //get a handle to the Vector storing the user objs in application scope
            Vector v = (Vector)ctx.getAttribute("userList");
           //now remove the object from the Vector passing in the reference to the object retrieved from the Session.
            v.removeElement(user);
    }That's it.
    Another approach would be to remove the User based on a unique identifier. Let's assume each User has a unique id (If your User has no such feature, you could still add one and set the user id to the session id that the user is associated with)
    void sessionDestroyed(HttpSessionEvent event){
         //get a handle to the session
         HttpSession session = event.getSession();
          //get a handle to the user object
          UserBean user = (UserBean)session.getAttribute("user");
           //get the unique id of the user object
           String id = user.getId();
           //get a handle to the application object
          ServletContext ctx = session.getServletContext();
           //get a handle to the Vector storing the user objs in application scope
            Vector v = (Vector)ctx.getAttribute("userList");
           //now iterate all user objects in the Vector
           for(Iterator itr = v.iterator(); itr.hasNext()) {
                   User user = (User)itr.next();               
                    if(user.getId().equals(id)) {
                           //if user's id is same as id of user retrieved from session
                           //remove the object
                           itr.remove();
    }Hope that helps,
    ram.

  • What's the best way for a web app to handle logins and sessions?

    I'm deploying in JBoss, using JSF. As is often the case, I keep User information in an entity bean. My question is, what's the best way to handle this bean?
    My inclination is to create a login page with a LoginBackingBean atached to it. When the user attempts to log in, it will see if there is a User entity bean that corresponds to the given name and password. If there is no User bean that matches, obviously we show an informative error screen.
    But what happens if there is a valid user?
    In the plain old Servlet world (without EJB / J2EE) I would just put the User object (it's an object, not an EJB) into the HttpSession, and I would create a Filter that would check for the presence of that User object, and I would map the filter to something like /members/*, and that would be it. I would use Hibernate to persist the User object, and there would also be a filter that creates a Hibernate session and stores it in the Request so that the User object would work and persist.
    How do I do this within the J2EE / EJB world?
    My first thought would be to just do the same thing. Install the User bean into the HttpSession, and create a filter and do all the same stuff. Is that the right way to do it? It would work pretty well with JSF because I could just access things in the normal JSF way: #{user.firstName} would find the "user" object in the HttpSession scope. So that's good.
    One question that comes up from that is if the user makes some change to the User object that is in the Session scope, will the EJB automatically do the right thing and make those changes persistent? Is there anything else I need to do?
    I'm new to the EJB world, but from what I can see so far, it seems like it's the best way to think about a web application.
    Thanks

    hi ,
    i think the best way is to create java beans ,in that bean call your EJB ,
    and check the validation over there.
    and make that bean scope to session.
    in each and everypage try to check the session ,if it is not valid then forward to your login page...
    otherwise continue to give access to him like guest
    Regards,
    AfTaB

  • PC Suite does not handle properly messages longer ...

    Phone: Nokia 6610i connected with infrared
    System Information from PC Suite:
    Operating system:
    Microsoft Windows XP
    Build 2600
    Service Pack 2
    Language: Italiano
    Language for non-Unicode programs: Italiano
    Locale: Italiano
    Input language: Italiano
    Nokia PC Suite:
    Version 6.82.22.0
    Language: English
    Connectivity Cable Drivers:
    Not installed
    PC Connectivity Solution:
    Version 6.43.9.0
    I have some messages longer than 160 characters and it seems that they are not handled properly:
    - The backup application stops copying messages when it finds the first long message.
    - When I browse the messages in Explorer (launched by clicking "Messages" in PC Suite) only sms up to 160 characters are shown. There are also some blank entries in place of long messages.
    I've noticed the same problem in the Italian version, I removed it and installed the English version before reporting the issue.
    Thanks

    Hi read my issue from a few days back from dave100. It seems we are having the same issue. I wroth to support but no one has got back to me. I bet they are clueless and have no idea why this is happening....Check out my attachment. Is yours the same?
    cheers.
    Dave
    Attachments:
    empty texts.txt ‏11 KB

  • Session-scope variable for JSP page used in a frame

    Hi,
    I don't know if there's a way to do this at the same time:
    (1)- assign session scope to a variable (in order to be able to retrieve recurrently the previous value each time the JSP is called);
    (2)- set its visibility in a way that it could be accessed only by the page that defines it. The JSP is used in a frameset along with an other JSP that can potentially define identical session-scoped variable (You understand why I want to keep them separate)
    session.setAttribute():
    seems not to be the thing I need
    pageContext.setAttribute():
    with SESSION_SCOPE, it behaves the same way as session.setAttribute(). with PAGE_SCOPE, condition (1) can't be satisfied.
    Does anybody have an idea ?
    Thanx in advance.

    I can see that you will not want to maintain two different files for every possible page on the site!
    It may be possible to do something like <frameset rows="*" cols="50%,*">
      <frame name="content1" src="file.jsp?frame=one" >
      <frame name="content2" src="file.jsp?frame=two" >
    </frameset>and then in the jsp<%
    String frame=request.getParameter("frame");
    session.setAttribute(frame+"AttributeName",attributeValue);
    %>This will set up two session attributes - "oneAttributeName" and "twoAttributeName". Depending on how many variables you have, this may prove just as difficult to maintain.
    You may end up having to simply pass url parameters between pages to maintain state within the individual frames, which is far from elegant also.
    I am interested in how you end up solving this one.

  • How to setup session scope in servlet?

    bean tag can be used in jsp to setup its scop, like
    <jsp:usebean id="abc" class="def" scope="session"/>
    but is it possible to setup session scope to divide two users in order not to use the same bean? becuase i encounter a problem that, when using bean in servlet, seemly A user would access the data that B user just store in; at first, i try to compare if session == null or session.isNew(), but finally find out that their session.getId() is difference, thus i suppose that if i am able to decide via users' session id to limit their access to the bean just as jsp:usebean does!
    is that right? or in what way is better?(i am now to rewrite my original code, it's a little bit complicate for some reasons, so i think, if possible, that via compare session id, that i do not know how, would be a better way!)
    thanks in advice,

    If each user has a separate session, then each one
    should get their own instance of the bean. Is it
    possible that that you store and retrieve a reference
    to the bean in a servlet instance variable? That
    would cause the problem you describe.do you mean by putting variable in situation like A) ; yes i did, but if i put bean in the body of doPost method, each time when bean are "new"ed, there may be error occurred, accounting for i hope to instantize with default value, but default constructor do nothing; thus if by only construct with default constructor, error would occurred and so a new constructor with parameters i put in the position you refferred to! would you like to tell me what's the right way for i am not so familiar with servlet.
    thanks in advice,
    A)
    public class MyClassName extends HttpServlet {
    BeanClass myBean = new BeanClass();
    ... doGet(...){}
    ... doPost(...){...}

  • Synchronizing session-scope objects?

              Hi,
              I have this problem, using Weblogic 5.1 SP8:
              In a JSP-file I use a java-object with the useBean-directive and
              session-scope.
              The problem occur when a user (for some strange reason) decides
              to double-click in his browser on a link pointing to this
              JSP-page.
              This makes the weblogic server start two separate request-threads to the same page
              in the same session. This will sometimes screw up tha data that the java-object holds
              since both threads at the same time uses the same object.
              The only solution that I have found is to put synchronized blocks in the JSP-file
              either synchronizing the java-object or the session-object.
              Does anyone have any similar problems or perhaps any opinions?
              regards/
              H Waller
              

              The problem we discussed (and fixed)was specifically in
              WLCS 3.2.
              If you are not using WLCS, you will not experience THAT problem.
              If you are using member servlet, member JSP variables or static
              variables, you will see a similar problem - don't.
              If it is data in the httpSession - you have to rethink your
              design.
              Mike
              "Ashutosh Khandelwal" <[email protected]> wrote:
              >
              >Hello Ture and Mike,
              >
              >I have been experiencing problems when a user decides to double-click
              >in the browser
              >pointing to a servlet. This makes the weblogic server start two seperate
              >request-thread
              >to the same page in the same session. This always screws up the data.
              >I am using
              >WLS 5.1 with SP8.
              >
              >According to your previous emails, this was only a problem with WLCS3.2,
              >which
              >uses PipelineSession. You have also indicated that this should not be
              >happening
              >with WLS 5.1 or 6.0 with SP8 or above.
              >
              >Well, I continue to have this problem with WLS5.1. Do you have any suggestions/opinion,
              >etc.
              >
              >regards,
              >
              >Ashu
              >
              >
              >
              >"Mike Reiche" <[email protected]> wrote:
              >>
              >>Thanks for the fast turn-around.
              >>
              >>- Mike
              >>
              >>Ture Hoefner <[email protected]> wrote:
              >>>Hello Mike,
              >>> As you know, a WLCS 3.2 (Commerce Server)
              >>>patch now exists for this problem. I thought
              >>>that I should post the details here to clear
              >>>up any confusion in the WebLogic user
              >>>community.
              >>> The problem that Mike experienced was that
              >>>the WLCS PipelineSession was keeping all
              >>>request-scoped attributes in a single bucket,
              >>>so concurrent requests from a single session
              >>>were experiencing naming collisions. Also,
              >>>one pipeline would empty the bucket when
              >>>finished, but other concurrent piplines may
              >>>have been using the bucket. This was not a
              >>>problem with WLS. It was a limitation of the
              >>>design of WLCS 3.2 PipelineSession, which is
              >>>not used in WLS 5.1 or 6.0.
              >>> Our engineering team has quickly responded:
              >>> they have designed and implemented a
              >>>PipelineSessionExtended that uses multiple buckets.
              >>> Each bucket is associated with a
              >>>request using a unique requestId.
              >>> A patch and details of the design fix and
              >>>use of the patch are available from support.
              >>>Please reference CR043462 when requesting the
              >>>patch.
              >>>
              >>>Mike Reiche wrote:
              >>>
              >>>> I don't mind that the HttpSession is shared,
              >>>my problem
              >>>> is that the PipelineSession is shared - because
              >>>that
              >>>> breaks <pipeline:getProperty > tags. When
              >>>I save a Pipeline
              >>>> propert as REQUEST_SCOPE, that's exactly what
              >>>I expect. But
              >>>> apparently, it's scope is beyond a request.
              >>>>
              >>>> What about a PageContext? That's not shared
              >>>between requests,
              >>>> is it? Maybe that's where REQUEST_SCOPE variables
              >>>should be
              >>>> stored.
              >>>>
              >>>> Mike
              >>>>
              >>>> Robert Patrick <[email protected]>
              >>>wrote:
              >>>> >Hmm...
              >>>> >
              >>>> >I always thought that it was browser specific
              >>>whether
              >>>> >the multiple browser windows
              >>>> >shared or did not share the same session
              >>>(and the Netscape
              >>>> >and IE do exactly the
              >>>> >opposite thing here). Regardless of the
              >>>multiple window
              >>>> >scenario, this can and will
              >>>> >happen if you have multiple frames in the
              >>>same window
              >>>> >making requests concurrently (or
              >>>> >possibly if you double-click on a link causing
              >>>the browser
              >>>> >to generate two requests to
              >>>> >WebLogic).
              >>>> >
              >>>> >Anyway, the crux of the matter is that your
              >>>servlets/JSPs
              >>>> >must be prepared to deal with
              >>>> >multiple requests from the same user accessing
              >>>the same
              >>>> >session. The servlet/JSP spec
              >>>> >doesn't, to my knowledge, address this issue.
              >>> You will
              >>>> >probably need to add
              >>>> >synchronization code somewhere, I would just
              >>>make sure
              >>>> >that you are synchronizing on an
              >>>> >object that is only used by one user (e.g.,
              >>>session) and
              >>>> >keep the synchronization
              >>>> >blocks as short as possible...
              >>>> >
              >>>> >Hope this helps,
              >>>> >Robert
              >>>> >
              >>>> >Michael Reiche wrote:
              >>>> >
              >>>> >> BEA says that's just your imagination....
              >>>> >>
              >>>> >> FR: nelson
              >>>> >>
              >>>> >> CASE_ID_NUM: 222714
              >>>> >> MESSAGE:
              >>>> >> Hi Michael,
              >>>> >>
              >>>> >> The Commerce Server is nothing more then
              >>>an application
              >>>> >riding
              >>>> >> on top of WebLogic Server.
              >>>> >> The HTTPSession is still being managed
              >>>by the WebLogic
              >>>> >Server,
              >>>> >> and not the Commerce Server.
              >>>> >> As I mentioned on my previous email, prior
              >>>to and including
              >>>> >SP6
              >>>> >> for WLS 5.1, the spawning of a child browser
              >>>window,
              >>>> >does create
              >>>> >> a shared HTTPSession, thus creating a shared
              >>>PipelineSession.
              >>>> >>
              >>>> >> If you have indeed upgraded to SP8 for
              >>>WLS 5.1, then
              >>>> >this should
              >>>> >> not be happening.
              >>>> >> Can you tell us exactly how you are spawning
              >>>the new
              >>>> >browser window,
              >>>> >> such that both requests are being sent
              >>>almost concurrently.
              >>>> >> Also, can you send us a copy of your "weblogic.log"
              >>>> >file from the
              >>>> >> Commerce Server as an attachment. If it
              >>>is large, please
              >>>> >zip it.
              >>>> >>
              >>>> >> Regards,
              >>>> >> Nelson Paiva
              >>>> >> WLCS DRE
              >>>> >>
              >>>> >> **********
              >>>> >> If you are replying to this email, please
              >>>DO NOT modify
              >>>> >the subject
              >>>> >> of
              >>>> >> this email in order to ensure that your
              >>>reply is processed
              >>>> >automatically.
              >>>> >>
              >>>> >> You can now "AskBEA" Customer Support questions
              >>>on the
              >>>> >web and
              >>>> >> get
              >>>> >> immediate responses. "AskBEA" is available
              >>>on http://www.bea.com/support/index.html
              >>>> >> **********
              >>>> >>
              >>>> >> "H Waller" <[email protected]>
              >>>wrote:
              >>>> >> >
              >>>> >> >Hi,
              >>>> >> >
              >>>> >> >I have this problem, using Weblogic 5.1
              >>>SP8:
              >>>> >> >
              >>>> >> >In a JSP-file I use a java-object with
              >>>the useBean-directive
              >>>> >> >and
              >>>> >> >session-scope.
              >>>> >> >The problem occur when a user (for some
              >>>strange reason)
              >>>> >> >decides
              >>>> >> >to double-click in his browser on a link
              >>>pointing to
              >>>> >this
              >>>> >> >
              >>>> >> >JSP-page.
              >>>> >> >This makes the weblogic server start two
              >>>separate request-threads
              >>>> >> >to the same page
              >>>> >> >in the same session. This will sometimes
              >>>screw up tha
              >>>> >> >data that the java-object holds
              >>>> >> >since both threads at the same time uses
              >>>the same object.
              >>>> >> >
              >>>> >> >The only solution that I have found is
              >>>to put synchronized
              >>>> >> >blocks in the JSP-file
              >>>> >> >either synchronizing the java-object or
              >>>the session-object.
              >>>> >> >
              >>>> >> >Does anyone have any similar problems
              >>>or perhaps any
              >>>> >opinions?
              >>>> >> >
              >>>> >> >regards/
              >>>> >> >H Waller
              >>>> >
              >>>
              >>>--
              >>>Ture Hoefner
              >>>BEA Systems, Inc.
              >>>2590 Pearl St.
              >>>Suite 110
              >>>Boulder, CO 80302
              >>>www.bea.com
              >>>
              >>>
              >>
              >
              

  • Session scope for component tree subtree

    I'm very new to JSF. Here is what I'm trying to do: I created a custom component, renderer, and tag. This custom action will always have children that are no custom, but whose rendering I must control (via encodeChildren, etc).
    The problem I have is that the CSS style of these components will change after they are rendered (DHTML & AJAX). Some are hidden, color changes, size change, etc. When I go to another page with the same custom action included, of course it just renders a new version with all of the changes lost.
    Now if this was a simple custom action with no children, I'd just create a managed bean with a value binding and there would be no problem. But what I am trying to do is save the ENTIRE subtree, ie. save the state of the custom component and all of its children also.
    Now the messy way to do this would be to take my component, make it a managed bean, then include a value binding every time I use that custom action. The custom renderer would look to the bean for how to render the children, etc. The problem I have with this approach is that I basically have to include attributes in my component (used as a managed bean) that redundantly describe the children.
    For example, my component:
    class UISearch extends UIComponentBase {
    private boolean showChild1;
    private boolean child1Color;
    etc..
    OR a better option, to have:
    private UIComponent child1;
    public setShowChild1() {
    child1.render = true;
    ....etc....
    The problem I have with the above aproach is that every time a page is requested, the UIViewRoot tree will be build, a new Child1 will be instantiated, and then during the rendering of UISearch's encodeChildren I'll have to pretty much copy over attributes..
    I wish there was a way that I could have a "managed component subtree" where UISearch and all of its children are instantiated once, held through session scope, and every time they are rendered, regardless of page, the existing, managed version is used.
    This sounds so obvious, and I am almost positive there is a way to do this, I just don't know how.
    Thank you!!!!!
    PS:
    I think I am on the wrong track. Basically all I want to do is have the UISearch and its children load the same normal way each time that they do now. I don't even care if the component tree is re-created, re-rendered, etc. But after this custom action is rendered, I call an AJAX loadConfig() type method that will return all of the style, innerHTML, src, etc. changes that must be updated.
    So my question really is.. what is the best practice for storing and retriving this information? I'm using DWR, and I'd like the loadConfig() to return an object with all the config stuff nicely organized.. so if the returned object is "search" and I need to load the 'display' CSS style for some child, i can do:
    child.style.display = search.history.clearHistoryLink.style.display;
    Who knows. Any and all ideas are welcome!
    Message was edited by:
    rrc3243

    I found example (bookstore) where I got answer about using backing bean in session scope.
    <!-- Backing Bean for bookshowcart.jsp -->
    <managed-bean>
    <managed-bean-name>showcart</managed-bean-name>
    <managed-bean-class>backing.ShowCartBean</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <!-- Managed Bean -->
    <managed-bean>
    <description>
    Create a shopping cart in session scope the first
    time it is referenced.
    </description>
    <managed-bean-name>cart</managed-bean-name>
    <managed-bean-class>cart.ShoppingCart</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    ShoppingCart class don't have data properties like lastName or orderId
    Class have only somethings like this:
    protected BookDetails book() {
    BookDetails book =
    (BookDetails) context()
    .getExternalContext()
    .getRequestMap()
    .get("book");
    return (book);
    * <p>Return the <code>ShoppingCart</code> instance from the
    * user session.</p>
    protected ShoppingCart cart() {
    FacesContext context = context();
    ValueBinding vb =
    context.getApplication()
    .createValueBinding("#{cart}");
    return ((ShoppingCart) vb.getValue(context));
    * <p>Remove the item from the shopping cart.</p>
    public String remove() {
    BookDetails book = (BookDetails) item()
    .getItem();
    cart()
    .remove(book.getBookId());
    message(null, "ConfirmRemove", new Object[] { book.getTitle() });
    return (null);
    rule:
    Don't use backing bean with data properties in session scope!

  • Seting a JSp variable to session scope in JSp page itself

    Hi,
    I have code like this
    <HTML>
         <HEAD>
              <TITLE>Change Password</TITLE>
              <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet/vclinical.css" TITLE="Style">
    </HEAD>
    <BODY>
    <form name="form">
    <select name="ss" onChange="this.form.qq.value=options[selectedIndex].value;getit()">
    <option value=1>ss1</option>
    <option value=2>ss2</option>
    </select>
    <input type="text" name="qq" value="">
    <%
    String asd=request.getParameter("qq");
    session.setAttribute("Stored", asd);
    System.out.println("value is"+asd);
    %>
    </form>
    </BODY>
    </HTML>
    here i want to set value of a JSP variable qq to session scope and here i am not invoking any servlet i want value of qq in next JSP page i am not submitting the page so how i can handle this. this code does not work so please tell me how to do this i am using struts frame work

    if you are using the struts framework, then you can make an ActionForm with getters and setters for the stuff that you are writing in the JSP i mean the radio buttons and text boxes etc
    from that action form you can get the values any time any where
    you just need to enter some thing like below in the struts-config.xml file
    <form-bean name="the action form name" type="package name.Actionform name" />
    <action path="/controller " type="package name.controller name" name="Action form name" scope="session">
    you can either put the action form in request scope or session scope

  • Must command link parameter variable SESSION Scope??

    I add a EJB Session Bean Method to my page which returns an array:
    public Province[] getProvinces();
    When you place the Session Bean to the page, it automatically creates a REQUEST SCOPE VARIABLE called "provinceRemoteGetProvincesResultBean" in the type of Province array. And it automatically creates a Data Table to display the results.
    Up to this point every thing's cool!! I can call the method properly, get the results and display without any problem.
    However when I try to create a COMMAND LINK to one of the columns of the TABLE (e.g. Province has a NAME column) I have a problem:
    <h:commandLink styleClass="commandLink" id="lnkName" action="#{pc_ProvinceManagement.doLnkNameAction}">
    <h:outputText id="otxName" value="#{varprovinceRemoteGetProvincesResultBean.name}" styleClass="outputText">
    </h:outputText>
    <f:param name="provinceId" value="#varprovinceRemoteGetProvincesResultBean.id}"></f:param>
    </h:commandLink>
    The problem is that this "provinceRemoteGetProvincesResultBean" is REQUEST scope and Command Link does not work with REQUEST Scope variables!!!
    I had similar examples before, when I used the command link with a REQUEST SCOPE variable, it didn't work. When I use it with a SESSION Scope variable it works.
    In this particular case, I cannot make the Province[] a SESSION SCOPE variable, because it's not a class!!! Therefore I need to create a new class containing a Province[] and make that class a SESSION SCOPE variable, which makes things quite complicated!!
    IS IT TRUE THAT COMMAND LINK PARAMETERS MUST BE SESSION SCOPE?????

    Line 4: <f:param name="provinceId" value="#varprovinceRemoteGetProvincesResultBean.id}"></f:param>
    value="#varpro... >>> value="#{varpro...                                                                                                                                                                                                                                                                                       

  • Jsp:useBean : Missing value of String classed bean with 'session' scope

    Hi!
    I'd like to ask some help.
    I have these two JSP pages:
    1.jsp<jsp:useBean id="str" class="java.lang.String" scope="session"/>
    <html>
    <body>
    <% str="hello"; %>
    <a href="2.jsp">click</a>
    </body>
    </html>
    2.jsp<jsp:useBean id="str" class="java.lang.String" scope="session"/>
    <html>
    <body>
    <%=str%>
    </body>
    </html>When I open 1.jsp in my browser, then click on the link, the result is "nothing" (empty string). Why does the bean lose its value on the way?
    I use a Tomcat 5.5.9 server.
    Any help will be highly appreciated.

    You have to think of several scopes when working with JSP. The first is the local scope: the method _jspService() where all the work of the JSP is done.  This acts as a normal method and is where all the sciptlet code goes.
    When you use jsp:useBean you are creating two references to a new String object. One in the local scope accessible through <%= str %> and the other in the session scope.
    When you do <% str = "hello"; %> you are changing the local str variable to reference the String "hello" (this is equivalant to doing <% str = new String("hello"); %>). Only the local reference is changed, not the second reference in session.
    If you want the change to take affect, then you will have to store the new value in session with the same name:
    <% session.setAttribute("str", str); %>

  • Stop App snooping through Session scope

    Right, haven't had to think about this too much before as I've always been working on projects on our own servers, but I'm now working on a project which will be hosted on a shared server. Irritatingly this brings me back to investigating Application scope snooping, and trying to find a way around it.
    And no don't even bother saying about a Multiserver install, I know that's for an ideal world but it's not the case here.
    Generally, I'd store my database connection details in the App scope, but obviously they can be read by other users on the box. I could wrap it up in a class, but even that can be executed by another app.
    I did, however, have a thought - what they *cannot* do is read my actual Application.cfc file. So how about I do something like this:
    <onAppStart>
      <cfset variables.secretkey =  '94yhf934h9p3v' />
      <cfset application.database.secretpassword = encrypt('mypassword', variables.secretkey , 'DESEDE') />
    </onAppStart>
    That way, the password is in the app scope (ie one place) but encrypted if anyone tries to look at it. I then do:
    <onSessionStart>
      <cfset session.database.secretpassword = decrypt(application.database.secretpassword , variables.secretkey, 'DESEDE') />
    </onSessionStart>
    Then in my code just reference session.database.secretpassword rather than the application-level version. That way nothing is visible in the Application scope, as it's all in the Session scope which other users cannot traverse. I know memory-wise it's not as efficient, but if it's the difference between giving away my database credentials and not, then I'm not overly fussed.
    Any issues anyone can see with that? Anything obvious I've missed? Any ways of improving it?
    Damn, I am ALL OVER these forums today.
    Cheers people
    O.

    What I mean is why an ISP would offer shared hosting instead of hosted VPSes.
    Well, working for an ISP, let me tell you
    Maintainability and resource. One standalone machine with 4GB of RAM and a quad-core CPU can happily run 500 CF websites as a shared server setup. There's simply no way that machine could run 500 VPS servers, all with their individual memory, CPU and disk overheads from both CF and the OS.
    You also would need to do 500 CF installations. Yes, you can deploy from archives or whatever but it's still a significant time and effort. Once done, you have 500 different CF installations you have to patch when Adobe release a hotfix or a new version. You have 500 lots of Windows Updates to do. 500 backups to configure to 500 iSCSI drives.
    And all for £50 a year per customer? Not a chance. That's the very nature of shared hosting; it's quite incredible value when you consider what (can) be included. I know many hosts don't, but we run ColdFusion Enterprise with sandbox security on SAS-based 64-bit servers, and all for £50 a year upwards. When you look into the costs of doing it yourself, it's a simple no-brainer.
    Incidentally for our own benefit we are now splitting machines to an extent - each physical server now runs VMware ESXi, onto which we install four or five virtual machines, each running Windows and ColdFusion. So to a degree we're splitting them up, but that's more for our own benefit - if a customer brings down a server, it affects only a quarter of the customers it would have. If we need to reboot a box for updates, the same. Also virtual machines are far quicker to reboot, another benefit for us.
    But as for running a VPS per customer on shared hosting - forget it. Never going to happen

Maybe you are looking for

  • Random shutoff no error message

    Hello, I have a 12 month old Toshiba Satellite L50-A013 (Australian) with Windows 8.1 installed. It has started to randomly shut off without warning or any error messages upon restart. It will function for about 30mins before shutting off.  It occurs

  • Why is QuickTime suddenly "not available" in CS3?

    While trying to embed a video into a document, I recieve an error message saying QuickTime isn't available. I've uninstalled and reinstalled QuickTime, which now works -- it will run video independently of InDesign. But when I try to place a video or

  • Stop Auto Play in Aggregator project (CP5)

    I've got a collection of software demos that I thought would be useful to bring together in an Aggregator project. Having done this, when I launch the project, the movies in my TOC automatically run, one after the other. I set my individual projects

  • Replacement set top boxes

    Hi,I transferred to Telstra a couple of years ago and have an old set top box and a foxtel IQ box. The old box is in the spare room and began failing about a year ago, but as I could find no easy way of getting a replacement I didn't bother. It has n

  • Dealing  of address change of org. units

    Here I am putting my question again. If we define the org. units like Plant,Sales org. ,Company code etc. and then change their  address,the address changes in the previous documents also. Are there any settings through which we can let the old addre