Scriptlet - can't change bean instance reference?

I am having trouble assigning a reference of a bean to an entirely new object.
What I am trying to do here is replace my cartDetailBean with a de-serialized version from the database.
I have written a utility class called BlobTool which returns an Object. In this case, I expect the Object to be of type CartBean.
<jsp:useBean id="cartDetailBean" class="com.abctech.myapp.CartBean" scope="page"/>
<jsp:useBean id="blobBean" class="com.abctech.myapp.util.BlobTool" scope="page"/>
<%
//Use a temporary cartBean in the scope of the request to inspect it's contents.
cartDetailBean = (com.abctech.myapp.CartBean)
          blobBean.getBlobFromTable("orders",
"serialized_order",
"orderid",
request.getParameter("orderid").toString());                                             
%>After this I try to access the cartDetailBean in JSTL and I get empty values, for example:
<c:out value="${cartDetailBean.customerID}"/>Has none of the values of the CartBean returned by blobBean.getBlobFromTable(...).
How can I put a bean into scope such that I can access it conveniently with JSTL tags?

Well you put java code where it is supposed to be. In a servlet or a java bean.
You put that java code in a servlet, set the request attribute(s) and then forward to the jsp to display the result.
Only one of those parameters to the method is dynamic.
You could write a helper class so that JSTL could access that better.
something like
public class CartHelper{
  String orderId;
  public String getOrderId(){ return orderId; }
  public void setOrderId(String orderId){this.orderId = orderId;}
  public CartBean getCart(){
    BlobTool blobBean = new BlobTool();
    CartBean cartDetailBean = (CartBean)
          blobBean.getBlobFromTable("orders",
"serialized_order",
"orderid", orderId);
    return cartDetailBean;
}and then in JSP:
  <jsp:useBean id="helper" class="com.abctech.myapp.CartHelper"/>
  <c:set target="helper" property="orderId" value="${param.orderid}"/>
  <c:set var="cartDetailBean" value="${helper.cart}"/>
This approach
- removes scriptlet code from your JSP
- removes the details of blob access, and which tables to access from the jsp
- lets you use JSTL in a semi-neat way
Cheers,
evnafets

Similar Messages

  • Can I change a cross reference display without having to recreate it?

    WHen cross references are to figures on the same page, I let the cross reference point to the paragraph number only ("see View 25"). When it is on another page, I use paragraph number and page ("See View 25 on page 34"). But when my text changes, sometimes text moves, sometimes images move and I need to change the cross reference. It is quite bothersome, I have to rmeove the old one and create a new one, hunting for the cross reference in a list of 150 or so.
    Is there a simpler way? E.g. put the insertion point in the cross reference and than some easy way to select a different appearance?

    Thanks for stepping in, Jan. I'm glad the smart page-reference building blocks in Cross-References Pro can actually do what I hoped it could, to solve this riddle for the original poster. I did a quick test, just to be sure it worked as I expected, and it does! It would be great for Adobe to license your technology and build this into InDesign, along with the rest of the extra-strength cross-reference abilities. (Disclaimer: I'm not connected to DTP Tools other than being a happy user.)
    As to the unwanted space, perhaps a character style in nested and/or GREP style could apply some kind of width adjustment that would reduce the displacement to an absolute minimum.
    Regards,
    Peter
    Peter Gold
    Jan Macuch wrote:
    Hi, sorry for being a little late on this one. Here's a sample of the Cross-Reference PRO format you're looking for is:
    See Figure <paranum/> <pagenum usesectionname="true" forcearabic="true" usepage="true" pagetext="on page #" usethis="true" thistext=" " usenext="true" nexttext="on the next page" useprev="true" prevtext="on the previous page" useopposite="true" oppositetext="on the opposite page"/>
    The trick is that you include the words "on" and "on the" in the page wording definitions, but insert just emptu space for the This Page setting. There's a glitch that you end up with an extra space after the reference, but you can replace the normal space by a hair space (code ^| ) which makes it quite tolerable.
    Jan Macuch
    DTP Tools

  • Where can you change the default reference point?

    Screenshot provided where you can manually change it on an object, but I would like to change it so that the Top Left is selected by default. I'm a web developer, and just like the web all my designs origins are anchored to the top left.
    Thanks.

    Which version of Illustrator are you using?
    In CS 5 – for example – you can just change it once, then AI automatically remembers it for future sessions.

  • How can I change the sound of push notifications on an iPhone 4 running with iOS5?

    How can I change the sound of push notifications?
    In settings > sounds there are various options but not the a possibility to change the general sound (!!!) of push notifications.
    Example: How can I change for instance the sound of the push notification of for example the New York Times notifications.
    Thanks for the help!
    Product: iPhone 4 running with iOS5

    What you see - what is available for this is what you get.

  • Why can I not change the location browser I have moved from Indianapolis IN. to Columbus OH. and when I search it takes me to Indianapolis can I change this?

    when doing a internet search it takes me to Indianapolis news, weather, local businesses, ECT. can I change this to reference Columbus Oh. and not Indianapolis ?

    This seems to have been asked a lot around the net, however, there doesn't seem to be an adequate answer to it.
    I am running:
    Operating system is Windows 7Motherboard is Q67H2-AM v1.1
    Bios is ACER ver. 2.10.1207
    GPU is GTX 770
    PSU is 700w
    The Graphics card is plugged in to the 16x slot, the fans spin, but no display and no device is recognized in device manager.
    I have tried a few solutions including uninstalling my onboard graphics driver from the device manager and going to upgrade my 600w power supply to a 700w one.
    I think the issue is that I need to change the BIOS to PEG or PCI Express. However, in the Bios the settings for both "Primary Video" and "Onboard Graphics" are grayed out, meaning that I can't change them.

  • Can we create multiple instances of a Bean in a JSP file?

    Hi,
    I am new to JSP & Servlets programming.
    I need to write a servlet that connects to a database via JDBC ( using IBM DB2 dbms) , sets some Beans with the tuples in the relevant table.
    Then, I need to have a JSP "read" ( or "get") info from the Beans & display the contents to the client.
    ( At a time only 5 tuples must be visible in the UI , with Next & Prev links ...)
    I am using Tomcat 4.0 for this...
    Can any one please help me regarding HOW to go abt it ?
    Esp., should we create 1 instance of a Bean , ( say "DataBean") for EACH tuple , or is there a way to do it with only 1 instance...
    Please, guide me... ( if not possible, at least give me some hints to some GOOD resources ( books, sites,etc.), that deal with this kind of applications)
    Thanks,
    Raghu.

    Once again, thanx a lot for your detailed help -- evnafets !!
    I think I am gaining in my knowledge of JSP & Servlets thanks to your help...
    Now, I am tackling the issue of selecting the BEST way of "STORING" which "PAGE" no. I am displaying.
    Say, I have only 15 tuples(ROWS), & with 5 tuples displayed per page, I have to have 3 "pages", & I need to accomplish the handling of "Prev" & "Next" links using only 1 Servlet & 1 JSP ( apart from the Authorization servlet ).
    I am thinking of storing a "session-scoped" variable called "page-num". Do you think it's the best way?
    Or should I score it as an "application-scoped variable" ( i.e., in the ServletContext ...) ??
    Also, I have got no clues as to which of the following would be a better idea :
    (a) Fetch ALL the tuples in the table & set as many beans. And then display the corresponding 5 tuples in each page.
    Here, more bean instances are needed to hold the data which gets repeatedly passed around ( when Prev & Next links are clicked ).
    OR ..
    (b)Fetch only 5 tuples at a time . I think this may be done by creating a scrollable Resultset & then moving around to the appropriate ROW by saying
    resultSet.absolute( (page_num - 1)*5 + 1 ); & then fetching 5 tuples relative to this row.
    In this case I will need atmost 5 Bean objects per request.
    And YES, one more thing , WOULD you PLEASE try & give me some guidance towards some good references to JSP, Servlets & J2EE ? ( Links, Books, anything ! )
    Sorry for the TROUBLE I gave, but THANKS a lot for the TROUBLE u took ! ;-)
    Thanks & Regards,
    Raghu

  • You changed the order of the menu for "Open in a new window" or "Open in new Tab", How can I change it back? Or how can I omit any reference to tabs? I do not use them at all.

    You changed the order of the menu for "Open in a new window" or "Open in new Tab", How can I change it back? Or how can I omit any reference to tabs? I do not use them at all.

    You can use the Menu Editor add-on to rearrange or remove menu items - https://addons.mozilla.org/firefox/addon/menu-editor

  • How can I change the settings of all instances of a particular effect?

    I've applied the same color correction effect to a lot of clips in the timeline. Now I want to fine tune the color correction (same setting for all clips still). How can I change the setting of all instances of the color correction effect without going into each clip manually?
    Looking forward to your thoughts on this!! Go on and save my cold winter editing day ...

    I was first hoping for File> New > Adjustment layer, but it's always greyed out. I thought that would create an adjustment layer, maybe I'm misunderstanding something? Anyway, if I create a black video stump and then right click it and choose "Adjustment layer", it will turn into one, and everything works as it should with that. If the black video become adjustment layer is placed on a video track atop my video, and I add for example color correction to it, it will be applied to the videos below.

  • Can I change the request params in my backing bean?

    I want to change the request params in the backing bean method.
    For example:
    <h:commandLink value="test" action"myBean.test">
    <f:param name="a" value="1" />
    </h:commandLink>
    When user click the link, myBean.test() will be invoked.
    Can I change the request param values in myBean.test()?
    I mean, if I can change the value of "a" to "2" or add a new param?
    Thanks!

    I'm not sure if You can change any request parameters...
    You can set e.g. a request attribute in the case that You get the request object from the faces context and set the attribute.
    something like this...
    FacesContext fc = FacesContext.getCurrentInstance();
    HttpServletRequest req =    HttpServletRequest)fc.getExternalContext().getRequest();
    req.getParameter("id");
    req.setAttribute("id", new Integer(2));

  • I have multiple songs I would like to include in my slideshow.  Can I change the rate of presentation for each song?  For instance, upbeat song with a 2 secong presenation time and slower song with a 3 second presentation time?

    I have multiple songs I would like to include in my slideshow.  Can I change the rate of presentation for each song?  For instance, upbeat song with a 2 secong presenation time and slower song with a 3 second presentation time

    Alternatives to iPhoto's slideshow include:
    PhotoToMovie  $49.95
    PulpMotion  $129
    FotoMagico $99
    Final Cut Pro X $299
    It's difficult to compare these apps. They have differences in capability - some are driven off templates. some aren't. Some have a wider variety of transitions. Others will have excellent audio controls. It's worth checking them out to see what meets your needs. However, there is no doubt that Final Cut Pro X is the most capable app of them all. You get what you pay for.

  • Can we change the Oracle instance name after confoguration.

    Hi,
    Has anyone tried changing the Instance name in Oracle after all the EPM components are configured.
    I mean, after the system is up and running. Do I have to re-configure everything with new instance name?
    If yes, what happens to data that was already there in the schemas?
    Thanks in advance,
    PM

    Try the following
    "On the machine hosting Shared Services, launch EPM System Configurator with the enableRegTask option: Make EPM_ORACLE_HOME/common/config/version_number the current directory and then launch configtool.bat|.sh -enableRegTask."
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Can not start SAP instance after change the profile

    Dear all
    We use system copy to build SAP system.
    Source
    Ecc 6.0(64 bit)
    Windows Server 2008 SP2
    SQL Server 2008 SP2
    Target
    Ecc 6.0(64 bit)
    Windows Server 2008 SP2
    SQL Server 2008 SP2
    In target system, we want to use the instance profile as source system,
    but after copy from source system we find that if parameter em address_space_mb = 512 in the profile,
    we can not start SAP instance.
    Could anyone explain it?
    Best regards
    Shirley

    Hi Shirley,
    I assume the hardware is less on the target than on the source or they are different at least in terms of hardware specs
    If the system is not starting, check the dev_disp.log, the stderr* files, and the dev_w0 log from the work directory to find the exact error. Does the system start if you increase or decrease this value?
    Regards,
    Paul

  • How can I create a java bean instance from servlet, at runtime?

    Will anybody help me?
    I want to send bean (class) name to a servlet through parameter and I need servlet to create specified bean instance and run its method that I will send through another parameter, at runtime.

    Thanks. I found answer

  • How can I get an instance of my customize cell in tableview?

    Hi,I'd like to generate a customize tablecell in my tableview.but How can I get an instance of my customize cell in tableview when selected item changes?
    public class Person {
              private javafx.beans.property.BooleanProperty active;
              private StringProperty firstName;
              private StringProperty lastName;
              private StringProperty email;
              private Person(String fName, String lName, String email) {
                   this.active = new SimpleBooleanProperty(true);
                   this.firstName = new SimpleStringProperty(fName);
                   this.lastName = new SimpleStringProperty(lName);
                   this.email = new SimpleStringProperty(email);
              public javafx.beans.property.BooleanProperty activeProperty() { return active; }
              public StringProperty firstNameProperty() { return firstName; }
              public StringProperty lastNameProperty() { return lastName; }
              public StringProperty emailProperty() { return email; }
    final ObservableList<Person> data = FXCollections.observableArrayList(
                             new Person("Jacob", "Smith", "[email protected]"),
                             new Person("Isabella", "Johnson", "[email protected]"),
                             new Person("Ethan", "Williams", "[email protected]"),
                             new Person("Emma", "Jones", "[email protected]"),
                             new Person("Michael", "Brown", "[email protected]")
    public class RatingCell extends TableCell<Person,String> {
        private NabiSyncRating rating;//NabiSyncRating is a customize control.it has some method ,like change backgroud-color,value,etc.
        public RatingCell() {
             rating = new NabiSyncRating(-1);
        @Override
        public void startEdit() {
            super.startEdit();
            if (isEmpty()) {
                return;
            rating.setDisable(false);
            rating.requestFocus();
        @Override
        public void cancelEdit() {
            super.cancelEdit();
            rating.setDisable(true);
        public void commitEdit(String value) {
            super.commitEdit(value);
            rating.setDisable(true);
        @Override
        public void updateItem(String item, boolean empty) {
            super.updateItem(item, empty);
    Callback<TableColumn<Person, String>, TableCell<Person, String>> ratingCellFactory = new Callback<TableColumn<Person, String>, TableCell<Person, String>>() {
                        @Override
                        public TableCell<Person, String> call(
                                  TableColumn<Person, String> p) {
                             return new RatingCell();
    TableColumn firstNameCol = new TableColumn();
    firstNameCol.setCellFactory(ratingCellFactory);
    firstNameCol.setMinWidth(100);
    firstNameCol.setMaxWidth(224);
    firstNameCol.setResizable(true);
    tableView.getColumns().addAll(firstNameCol);
    tableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
                  @Override
                  public void changed(ObservableValue observable, Object oldvalue, Object newValue)
                               Person person=(Person)newValue;
                               //I'd like to get the instance of my customize control 'RatingCell' ,How can I get the RatingCell instance which in current row?
                         System.out.println("selected row is : " + newValue );
                  });

    HI,
    I have found a solution to find it
    First ,you need to set person property 'id' as the input parameter for your customized component method 'public void updateItem(String item, boolean empty)'
    ratingCol.setCellValueFactory(new PropertyValueFactory<Person,String>("id"));
    firstNameCol.setCellFactory(ratingCellFactory);and then you need to implement your customize component like this:
    import javafx.scene.control.ContentDisplay;
    import javafx.scene.control.TableCell;
    public class RatingCell extends TableCell<Person,String> {
        private NabiSyncRating rating;
        public RatingCell() {
             rating = new NabiSyncRating(5);
            this.setGraphic(rating);
            this.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
            this.setEditable(true);
        public void updateRating()
             if(rating!=null)
                  rating.selectRating();
        @Override
        public void startEdit() {
            super.startEdit();
            if (isEmpty()) {
                return;
            rating.setDisable(false);
            rating.requestFocus();
        @Override
        public void cancelEdit() {
            super.cancelEdit();
            rating.setDisable(true);
        public void commitEdit(String value) {
            super.commitEdit(value);
            rating.setDisable(true);
        @Override
        public void updateItem(String item, boolean empty) {
             if(item!=null && item.length()>0)
                  if(rating!=null)
                       rating.setId("NR"+item);
                       this.setId("NC"+item);
                super.updateItem(item, empty);
    } and find the current like this :
    tableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
                       @Override
                       public void changed(ObservableValue observable, Object oldvalue, Object newValue)
                            Person person=(Person)newValue;
                            Set<Node> colNodes=tableView.lookupAll("RatingCell");
                            for(Node nod:colNodes)
                                 System.out.println("person.email:"+"NC"+person.email.getValue()+"|nodId: " + nod.getId()+"\r\n" );
                                 if(("NC"+person.email.getValue()).equals(nod.getId()))
                                       System.out.println("get current instance" );
                                      ((RatingCell)nod).updateRating();
                       });Edited by: noob on Apr 20, 2012 4:49 PM

  • Can i create an instance of a jar file?

    Actually,i'm creating a combobox component.For tht i've written a java class,in tht calss i read the javascript code and create an instance of the java class n render tht code.If i want to give this java file and javascript file i need to jar it.i have done tht also but i can't create the instance of tht java class from the jar .can u help me out?
    Thanks in advance.

    Hey thanks so much for the reply.
    Let me tell you the exact scenario. I'm actually developing a struts-application. Hope I can get some help here too.
    I have:
    1. login.jsp-where user logs in.
    -I have a userid and a password as default values for each unique user.
    Where should i store these details -in HashMap??
    -How can I display error messages if userId/passWord is invalid on login.jsp page ??
    2. confirmation.jsp-on successful login, he's shown his details:
    YOur first name: .........
    Your last name: ........ etc.
    -Here I can't use bean:write tag to read from form-bean.
    - how do i display it here without using a scriptlet ?
    3. LoginAction.java
    -Here i will get userId and passWord from LoginFormBean.java setter
    and getter methods.
    -For all validations' results, should i call a boolean getUserDetails() method from form-bean, wherein i can map values(first name, last name etc ) to each key (userid) ?
    i can use methods like:
    if (isValidUserId && isValidPassWord )
    LoginValidateUtil.getUserDetails();
    return mapping.findForward("success");
    But, can I assign many values to a single key using Map ?
    4. LoginFormBean.java
    -Here should I have to use set/getUserDetails() ?
    -If so, how do I use Map there?
    I want to have userId as the only key to which i can map values and not password.
    5. LoginValidateUtil.java
    -Here all validations are defined and boolean result is passed to LoginAction.java.
    Hope you got what I meant.
    Please tell me if i am right in this approach...
    Thanks in advance,
    sanlearns

Maybe you are looking for

  • Five minutes later"this song can no longer be made into a ringtone"

    I downloaded a song that had the bell next to it. Five minutes later, it's downloaded, and I click the bell icon to make my ringtone. A box popped up that said "this song cannot be made into a ringtone- this song can no longer be made into a ringtone

  • XMLSocket.onConnect - success is false?

    I'm using Flash MX 2004 and i've written a sample socket server in php. it responds when i telnet in from everywhere: * using telnet from the Win XP command line from my desktop * using raw telnet from puTTY from my desktop * using telnet from the li

  • PowerPoint 2007 (Windows) to DVD via Keynote?

    HI.... I recently created a 245 slide presentation in PP 2007 for Windows. I need to convert the show to DVD, but now find that my options to do that are limited and the products on the market are not that great. Is there a way to import the WIN 2007

  • Slow opening of file to edit

    Hi there, I it very slow (up to four minutes) to open a photographic (jpg) file to edit with Photoshop (it is ridiculously slow)....should I uninstall it and then reinstall it again? Thank you

  • Getting dump while calling adobe form

    Hello All, I am working on a webdynpro application and within the application I am calling a adobe form, when I call the adobe form I am getting the following short dump: Error in the ABAP Application Program The current ABAP program "CL_WD_ADOBE_SER