Cannot save beans in a session OR use the same beans in multiple pages

Hi all I use these code to my jsp file to create a session and store a bean.
Unfortunately, the session cannot store the beans so that I can use them in the next page.What did I omit? Regardless the session scope, can I use request scope beans and with jsp:forward use them in multiple page? (I have tried it but it doesn't work).
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page session="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%
String nextPage = request.getParameter("np");
if(nextPage.equalsIgnoreCase("checkDate")){
%>
  <jsp:useBean id="checkDate" scope="request" class="essex.kkarad.beans.checkDateBean" />
  <jsp:setProperty name="checkDate" property="*"/>
<%
    checkDate.validate();
%>
<jsp:forward page="Availability.jsp"></jsp:forward>
<%
} else if(nextPage.equalsIgnoreCase("checkRooms")) {
%>
<jsp:useBean id="checkRooms" scope="request" class="essex.kkarad.beans.checkRoomsBean" />
<jsp:setProperty name="checkRooms" property="*"/>
<%
   if(!checkRooms.validate()){
%>
<jsp:forward page="Availability.jsp"></jsp:forward>
<%
%>
<%
%>

You should also be encoding the URL so that you don't have to worry about loosing the session if the user has cookies turned off:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page session="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%
  String nextPage = request.getParameter("np");
  String availabilityPage = response.encodeURL("Availability.jsp");
  if(nextPage.equalsIgnoreCase("checkDate")){
%>
  <jsp:useBean id="checkDate" scope="session" class="essex.kkarad.beans.checkDateBean" />
  <jsp:setProperty name="checkDate" property="*"/>
<%
    checkDate.validate();
%>
<jsp:forward page="<%=availabilityPage%>"></jsp:forward>
<%
  } else if(nextPage.equalsIgnoreCase("checkRooms")) {
%>
<jsp:useBean id="checkRooms" scope="session" class="essex.kkarad.beans.checkRoomsBean" />
<jsp:setProperty name="checkRooms" property="*"/>
<%
   if(!checkRooms.validate()){
%>
<jsp:forward page="<%=availabilityPage%>"></jsp:forward>
<%
%>
<%
%>

Similar Messages

  • How to use the same bean from Jsp and Servlet

    I want to use the same bean instance from both the servlet and jsp.
    for eg. if a create a bean using the jsp:useBean in servlet and if a modify some values, that values should be reflected while i access the same bean from the servlet. But instead of that the servlet is creating a new instance of the bean.
    is it possible?
    Thanks in advance

    Hi,
    When you call jsp:useBean you inform a scope (session, request, page...)
    This means the bean instance will be stored in that scope.
    So, if the informed scope is session, then, in the servlet you could get the bean instance back from the session, this way:
    HttpSession session = request.getSession();
    Bean b = (Bean) session.getAttribute("bean_id");
    Regards,
    Filipe Fedalto

  • Can i use the same advertisement to multiple collections?

    Can i use the same advertisement to multiple collections?
    Advertisment A1 currently linked to collection C1.
    Can i use the same advertisement A1 to a collection C2? Because my collection C1 is query based and the C2 would be a static one.
    If i use the same A1 advert, will it affect the earlier linked C1 collection i any ways?
    System Security analyst at CapG

    Well, in 2007 you actually kind of can. You can used linked collections to make C2 a linked sub-collection under C1 and ensure that the advert applies to sub-collections.
    Jason | http://blog.configmgrftw.com | @jasonsandys

  • Using the same library with multiple computers over a network Use Aperture

    Hi Everyone. I am researching some cataloguing/editing programs to recommend one to my boss, and I was wondering if it was possible to use the same library between multiple computers on a network. Does anyone know if this is possible? This may be what makes or breaks the decision on whether or not to go with Aperture as we need a program that can access a large database of photos on multiple computers.
    Thank you.

    Welcome to the forum.
    You can do it, but...
    It's not supported by Apple.
    Performance won't be great unless you're running a really fast network.
    If more than one person tries to access the Library at one time you're likely to end up with a corrupted database, and there's no code in Aperture to limit access to one person at a time.
    The Library must be stored on an HFS+ volume - don't even try putting it on a FAT32-formatted drive.
    If you want 'proper' multi-concurrent-user network-enabled cataloguing software you're looking into a whole different level of investment than the low price of Aperture - think more in terms of thousands or even tens of thousands of dollars.
    Ian

  • How can I have use the same div ID multiple times on the same page?

    Okay so a problem I encounter a lot is that often times I want to use the same div ID several times on the same page. An example of this is when I'm creating table like designs.
    Let's say for instance I create a div ID called 'product-container'. I want to use 'product-container' multiple times on the same page but if I do this it is improper XHTML and will throw errors in any XHTML validator (you are only allowed to use a div ID once on any XHTML page in order for it to be standards compliant).
    Now the first option is that I could define 'product-container' in my CSS style sheet multiple times by doing something like this...
    #product-container {
         width: 300px;
    #product-container-2 {
         width: 300px;
    #product-container-3 {
         width: 300px;
    #product-container-4 {
         width: 300px;
    What you will see there however is that it seems pointless to define the same ID numerous times over (just adding a number on the end) when each ID is the exact same thing and has the exact same attributes.
    Now what I have noticed is that there are some sites out there who manage to have the same ID appear several times in the code but add a number to it just like above. The difference is that they only have one definition for 'product-cointainer' in their CSS document but in their actual XHTML code they have IDs for 'product-container' but with numbers on the end like 2,3,4,5, etc. It's almost as if JavaScript or some other code is automatically appending a number on the end of the ID so the validator won't consider the markup to be invalid, but yet it knows that it's using the same 'product-container' style that is contained in the CSS style sheet.
    I hope I explained this correctly. I'm just hoping to find a way that I can put the same div ID on a page multiple times without having to define it over and over again in my CSS.
    Any help is much appreciated!

    Because it seems like by using a class you can't make this position as 
    well as you can by using an ID. Am I wrong?
    An ID name can be used only one time per page.  A class name can be used multiple times per page.
    .product {
    width: 300px;
    text-align:left;
    color: #FF0000
    border: 2px solid #666;
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    www.alt-web.com/
    www.twitter.com/altweb
    www.alt-web.blogspot.com

  • Is it safe to use the same passphrase for multiple disks?

    I have a very elaborate passphrase using letters, digits and punctuation marks that I'm fairly confident nobody will ever be able to crack even if they have the seed and hash and a couple of million GPU's to throw at it.
    However, from a cryptography course I know that if two "messages" have been encrypted using the same "pad", you will be able to extract information by or-ing the messages, for example.
    Now I'm sure that the encryption scheme in OS X is much more sophisticated, but just to be sure:
    If I encrypt two disks using the same passphrase, and somebody steals both disks, would that make it easier for them to crack it? Is there some way they could exploit the fact that the passphrases are the same? Could they find data by combining the data on the two disks?
    I assume it's not possible, but just checking.

    Short answer: don't worry.  AES-256 is currently a secure scheme.
    Long answer: If your reference to a "pad" is to the reuse of a so-called one-time pad scheme, that's a very different cryptographic system than what's typically used now, and the attacks against a reused one-time pad are different sorts of cryptographic attacks.
    If you're using a one-time pad for a whole disk, you either need a ginormous one-time pad that's itself as big as the disk, or you'll get data that's repeated; a typical disk has great wads of zeros and ranges of blocks of zeros, after all.
    In modern systems, it's quite common for the same private key to be used for thousands and even millions of messages, when asymmetric encryption is used.
    Now I don't know which encryption algorithm is currently being used to encrypt DMGs, but I'd suspect it's still AES-grade encryption.
    AES works very hard at making the results of the encryption process as close to random as it can manage, which reduces the exposure to frequency-based attacks.  (This is also why effectively-encrypted data can't be compressed; there should be no repeats.)  This randomness is part of the basis for the attacks against the one-time pad; that the output of the pad - the encrypted data - if the one-time pad is re-used - isn't really random.  Particularly if you know (or can guess) some of the cleartext, too.  Or those big blocks of zeros.
    Now the other central discussion here is around how much somebody would pay to decrypt your data.  Because if your data is worth enough to the attacker, then there can potentially be other ways to attempt to gain access, even if AES itself isn't breached. 
    If you're storing some very valuable data (worthy of attacks), then receiving guidance from some yutz like me in an Apple forum probably isn't in your best interest.  But if you're not storing miltary-grade, or financial secrets, or identifying medical data, or credit card data, then AES-256 will do nicely.  And even if you are, AES-256 might be enough.  But check with the crypto and legal folks for details, or with your site security officer.
    And as was correctly noted in an earlier reply, if a password is used once, and once known, an attacker will try it against other systems and servers.  This being another common form of re-use.
    If you're interested here, then get one or two of Bruce Schneier's books on crypto.  If you don't already have them.

  • How do use the same crop for multiple images.

    I have a number of images that I want to use the same crop on. Instead of go through the whole slow process for each image is there a way to use the same crop for all of the images?
    And in iPhoto there was a way to copy the adjustment settings to multiple images, I can't see how to do that in aperture.

    Use the "Lift&Stamp" tool:
    Crop one image.
    Lift the crop using the "Lift" tool.
    Select the other images.
    Stamp the crop adjustment to all of them.
    But caution: By default "Lift" will copy all Metadata tags and all adjustments, but the gps data. If you only want to transfer the cropping rectangle, deselect all lifted items but the crop adjustment before stamping.
    Regards
    Léonie

  • Did being able to use the same data in multiple apps get added?

    In the new iOS 4.2, did Apple include the ability to use the same data, eg PDF files in multiple apps? I have several hundred PDF files that I want to use in three different apps.
    Or is it still the same, that you have to load up (and use valuable space) the same data again and again for EACH individual app?
    Thanks

    I don't know but think it would mean the PDFs must be stored somewhere on the device itself (like on a computer). Then also the apps must be designed to use the files from there. So a change in the iOS wouldn't be all that's needed.

  • Using the same account for multiple Macs?

    I have two Macs at home that I download apps to with my personal account and I also have an iMac and MBP from work that I want to start downloading apps to. Should I use my existing personal account or should I create a new account? Does it make a difference if I download 4 copies of the same free app to 4 different macs?
    Thanks.

    Does it make a difference if I download 4 copies of the same free app to 4 different macs?
    No as long as you use the same Apple ID they were purchased wtih.
    How to re download apps from the Mac App Store:
    Open the App Store. From the menu bar click Store > Sign In
    Click Purchases from the top of the App Store window.
    Select which apps you want to re download. Then right or control click where you see Installed  then click Install.
    If you create another account, it's sure to cause confusion.
    You may want to backup your purchases >  Mac App Store: Backing up your app purchases

  • BC4J View not Thread safe, user sessions are using the same view instance

    Hi There,
    We are using BC4J that came with JDeveloper 10.1.2.0.0 with Oracle 10G 10.1.2.0.0.
    I have an BC4J account search view (BC4J AccountSearchView) that users can call to search for an account. So this view could be used by numerous users and pieces of code at the same time. Now my understanding is that each user gets their own instance of the view so changing the view's query should not be an issue (since the view definition is not changing). Under a light load the account search view looks like everyone get there own instance of the view and there expected account search results. But under a heavy user load when we have User A and User B the search query that was for User A will be used by User B. So the user results for one user will get the other users results.
    I do not understand if the view definition is been changed by the other user and is impacting all view instances. How can this occur if it is thread safe?
    I have enclosed the core code for this search.
    If you can help that would be much appreciated, thanks in advance,
    Nigel
    accountSearchView.setQuery(baseSelectQuery+generateWhereClause());
    logger.debug("SearchAccounts Query: "+accountSearchView.getQuery());
    System.out.println("SearchAccounts SQL: "+accountSearchView.getQuery());
    accountSearchView.setPassivationEnabled(false);
    accountSearchView.setForwardOnly(true);
    accountSearchView.executeQuery();
    get attributes for each row result and place in new Java bean objects and return to user.

    Nigel, we've only certified JDeveloper 10.1.2 against the Struts 1.1 with which it ships.
    If there have been any changes in Struts 1.2 to the Struts Request Processor, then this could easily have an impact on the BC4JRequestProcessor's correct functioning, depending on what the changes were.
    My quick look into the issue tells me that the ActionServlet init parameter named mapping in web.xml that we use for the 9.0.3-style BC4J/Struts integration is getting ignored by Struts 1.2. This parameter is used by Struts 1.1 to globally configure a custom ActionMapping subclass which can support additional properties. My quick test shows me that Struts 1.2 is ignoring this setting and so the oracle.jbo.html.struts11.BC4JActionMapping subclass of Struts's default ActionMapping is not getting used correctly as it does in Struts 1.1. This leads to errors when Struts tries to configure its actions in struts-config.xml since the Apache digester tries to set properties on the ActionMapping instance that don't exist (since the BC4JActionMapping has these properties, and it's not being used).
      <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
        <init-param>
          <param-name>mapping</param-name>
          <param-value>oracle.jbo.html.struts11.BC4JActionMapping</param-value>
        </init-param>
      </servlet>This is my quick analysis of what's not out-of-the-box compatible. I don't know enough about the changes in Struts 1.2 to know why this Struts 1.1 feature broke in Struts 1.2, or what the Struts 1.2 way to accomplish the same thing is.
    I'd encourage you to use Worldwide Support's Metalink site and open a TAR for any time-critical issues you need assistance in resolving. Many of us are constantly traveling and only able to sporadically chime in with tips in the forum as our time permits.
    The source of the BC4JRequestProcessor ships with the produce in the ./BC4J/src directory inside the bc4jstrutssrc.zip file.

  • Can I use the same class as a page backing bean and a lifecycle listener

    Hi everyone
    I have code in a backing bean that executes as a value change listener. What I want to do is have this code execute on first page load. So what I am asking is:
    if I implement the PagePhaseListener interface on the backing bean class, will I be able to access the #{bindings} object during the beforePhase() and afterPhase() methods.
    Thanks in advance
    Thanassis

    Hi,
    yes, and it is documented here
    http://download-uk.oracle.com/docs/html/B25947_01/bcdcpal005.htm#sthref831
    Frank

  • How to use the same script for multiple buttons

    Hi,
    I've only just started using flash so any help would be great!
    I'm creating a blockbusters type game, I have a grid of 20 buttons and I need  them (individually) to turn blue on click and red on double click. I've managed to do it with the first one using this code;
    var clicked:Boolean = false;
    bn1.addEventListener(MouseEvent.CLICK, bn1click);
    function bn1click(event:MouseEvent):void {
        clicked = true;
        var newColorTransform:ColorTransform = bn1.transform.colorTransform;
        if(clicked){
        newColorTransform.color = 0x064258;
        bn1.transform.colorTransform = newColorTransform;
    bn1.doubleClickEnabled = true;
    var doubleclicked:Boolean = false;
    bn1.addEventListener(MouseEvent.DOUBLE_CLICK, bn1dclick);
    function bn1dclick(event:MouseEvent):void {
        doubleclicked = true;
        var newColorTransform:ColorTransform = bn1.transform.colorTransform;
        if(clicked){
        newColorTransform.color = 0xac1e23;
        bn1.transform.colorTransform = newColorTransform;
    Now I'm having trouble getting the same to work for the rest of the buttons, they are each named bn2, bn3 etc. They need to work individually and remain blue/red once clicked. I've tried listing them as addEventListener commands but not having a great deal of success!
    Any help would be greatly appreciated, thanks!
    Tomo

    One way to do this is to use arrays to keep track of the buttons and their properties.
    var buttonList:Array = new Array(bn1,bn2,bn3);
    var clickedList:Array = new Array();
    var doubleClickedList:Array = new Array();
    //then use a for loop to assign the functions and properties for each button:
    var thisMany:int = buttonList.length; // this will give you the number of items in the buttonList array
    for(var i:int = 0; i<thisMany; i++) {
         buttonList[i].addEventListener(MouseEvent.CLICK,btnClick); // assign the click function to each button
         buttonList[i].addEventListener(MouseEvent.DOUBLE_CLICK,btnDClick); // assign the double click function
         clickedList.push(false);  // add a false value for each button to this array
         doubleClickedList.push(false);
               buttonList[i].doubleClickEnabled = true; // set the double click property for each button
    function btnClick(event:MouseEvent):void {
              var thisButton:int = buttonList.indexOf(event.target);  // figure out which button was clicked as an item in the array
              clickedList[thisButton] = true;  // change the value in the array
               var newColorTransform:ColorTransform = buttonList[thisButton].transform.colorTransform;
        if(clickedList[thisButton]){
        newColorTransform.color = 0x064258;
        buttonList[thisButton].transform.colorTransform = newColorTransform;
    function btnDClick(event:MouseEvent):void {
              var thisButton:int = buttonList.indexOf(event.target);
              doubleClickedList[thisButton] = true;
        var newColorTransform:ColorTransform = buttonList[thisButton].transform.colorTransform;
        if(doubleClickedList[thisButton]){
        newColorTransform.color = 0xac1e23;
        buttonList[thisButton].transform.colorTransform = newColorTransform;
    Now you can have any number of buttons, just add their instance names to the array at the top.

  • Using the same library for multiple iTunes IDs

    My wife and I have the same exact library. When she buys something, my computer/ipod/devices are authorized to use it. We both got new laptops and we wanted to refrain from adding too much on them. I have an iMac with the music library on it. I signed up for iTunes match so that I could have my library on my devices and our Apple TV. So the question is, how can I get the same library on her devices, without uploading this library to her laptop?
    Can I simply log out of iTunes on the iMac and then log in as her and sign up for iTunes Match under her ID and go through the process again and all is done?
    We'd like to maintain the separate IDs as she purchases apps on her own and then has a lot of podcast subscriptions that I don't. But again, just trying to get the shared library to her device.
    Any help would be appreciated.
    Thanks.

    No, there is no way to do this at this time, and if you make a mistake trying, you can screw yourself up and end up locking yourself out of Match.
    Apple makes a subtle and extremely annoying distinction between "authorization" and "association".  You need "authorization" to play content on a particular computer, and several users with different Apple IDs can authorize their content on a single computer.
    However, to do any of the following:
    -auto-download content
    -download previously purchased content
    -use Match!
    you must "associate" the computer to an Apple ID in addition to "authorizing" it. Only *a single AppleID* may be associated with a computer (not account, computer!) at a time, and this can only be changed once every 90 days. In other words, in this context, it treats the computer just like a mobile device. You can't run Match with more than one user, and Match also precludes anyone else from downloading previously purchased content.
    I recently learned about this the hard way when my son came home from college and used his Apple account to re-download a single TV show on my computer.  When I logged in later to try to use Match, a splash informed me I would have to wait *90 days* to switch back to my AppleID!  Luckily, I emailed the iTunes store and they were able to reset it.  I'm not sure if they have single incident forgiveness policy, if they were able to see exactly how much money I've put in their pockets over the  last couple years, or if they were simply smart enough to realize that *not* doing so could only lose them money in the future.
    Add to this the fact that you now "associate" (with a different definition) your AppleID with your *user account* to use cloud services, and you have three different and inconsistent ways your AppleID is used on a computer.
    Hopefully, Apple will clean all of this up at some point.

  • Can I use the "same" button multiple times for multiple galleries?

    OK so I am extremely untrained in CS4 and Actionscript. However I have managed to get along fairly well until I started to dynamically upload images as a gallery. This works great if I have one gallery, but for my site I have 9 galleries!!! I have a back and next button, but I want to be able to use those same buttons for all of the galleries so they look the same. I have split them up and renamed them, but I am clueless on how to script the buttons to work. Please help...and don't laugh at my poor scripting. This is what I have now because I do not know where to put the other button names without getting errors.
    stop();
    next_btn .addEventListener(MouseEvent.CLICK, nextImage);
    var imageNumber: Number=1;
    function checkNumber(): void{
        next_btn.visible=true;
        back_btn.visible=true;
        if(imageNumber==15){
            trace(imageNumber);
        next_btn.visible=false;
        if(imageNumber==1){
            trace(imageNumber);
        back_btn.visible=false;
    function nextImage(evtObj:MouseEvent):void {
        imageNumber++;
        mc_engagement.source= "photo/engagement/en0"+imageNumber+".jpg";
        mc_amish.source= "photo/amish/Amish"+imageNumber+".jpg";
        mc_chicago.source= "photo/chicago/ch"+imageNumber+".jpg";
        mc_landscapes.source= "photo/landscapes/land"+imageNumber+".jpg";
        mc_goodvsevil.source= "photo/goodvsevil/ge"+imageNumber+".png";
        mc_animals.source= "design/animals/an"+imageNumber+".png";
        mc_icons.source= "design/icons/icon0"+imageNumber+".png";
        mc_objects.source= "design/objects/pc"+imageNumber+".png";
        mc_typography.source= "design/typography/type"+imageNumber+".png";
        checkNumber();
    back_btn .addEventListener(MouseEvent.CLICK, backImage);
    function backImage(evtObj:MouseEvent):void {
        imageNumber--;
        mc_engagement.source= "photo/engagement/en0"+imageNumber+".jpg";
        mc_amish.source= "photo/amish/Amish"+imageNumber+".jpg";
        mc_chicago.source= "photo/chicago/ch"+imageNumber+".jpg";
        mc_landscapes.source= "photo/landscapes/land"+imageNumber+".jpg";
        mc_goodvsevil.source= "photo/goodvsevil/ge"+imageNumber+".png";
        mc_animals.source= "design/animals/an"+imageNumber+".png";
        mc_icons.source= "design/icons/icon0"+imageNumber+".png";
        mc_objects.source= "design/objects/pc"+imageNumber+".png";
        mc_typography.source= "design/typography/type"+imageNumber+".png";
        checkNumber();

    I'm still a novice with Flash myself, but I have two comments.
    First, at this point, won't your buttons control all galleries at the same time? Which means, if I go to image 5 in one gallery, then move to another gallery, I'll start at image 5, because the actions are all connected.
    Second, you can definitely use the same buttons for multiple galleries. It seems to me that as long as you've assigned the buttons an instance name, these actions should already work to control all the galleries (see the note above). I guess I would need to understand a bit more about how your project is built.

  • How do I use the same Apple ID on two or more devices?

    I try to set up an Apple ID on my iPad but I already have one set up for my iPhone which is associated with my email. It makes me use a different email address which I don't want to do

    You certainly can use the same ID for multiple devices. In fact, if you do then you can share the apps and content between devices. I have an iPad and iPod and use the same Apple ID for them both.
    If I were using different ID's for each  device then I'd need to buy two copies of some apps, which would just be no fun at all.

Maybe you are looking for

  • Error 1 occurred when tried to install Flash Builder on Windows 8.  No files to uninstall.  Caught in loop

    I need to install Flash Builder 4.7 on my windows 8 computer.  I started the install process, but was soon stopped due to error 1.  The software wants me to uninstall/reinstall the software.  there is no program installed on the computer.  Cannot fin

  • Installing Oracle 8i in Solaris Intel Version With Pentium 4

    Hi Guys, I am trying to Install Oracle 8i under Solaris 8 Intel version with Pentium 4 processor fixed.But iam'nt able to continue after I click "Install" button,the runInstaller exited badly with no response.I was told that even Installing Oracle un

  • Committed quantity query

    Does anyone have a query that can detail the commited quantity in the Item Master Detail Inventory Data Detail tab? Thanks, Jeff

  • Safari not displaying swfs correctly

    My web site consists of Flash swf files embedded in html pages. If I have the Address Bar hidden while loading, for ex, my index page and then try to bring up the Address Bar, its swf does not move down with the rest of the window contents, so it blo

  • Where is HR Sample Schema Script for APEX 2.2

    Just installed APEX 2.2 and am reviewing the 2-day developers guide. In there they give many examples based on an HR sample schema which they say can be downloaded from http://www.oracle.com/technology/products/database/application_express/code/hr_sa