Passing large objects in request

Is it bad practice to pass large objects such as an ArrayList with large amounts of data in the request object? Will it impact performance?

dorr67 wrote:
Yes, to be more specific, I'm creating a List from my DAO and putting in the HttpServletRequest object using request.setAttribute("dataList", dataList), then retrieving the List in the jsp to render a datagrid. I was concerned if this could be a problem down the road when dealing with large amounts of data in the list. Pagination will be handled in the grid component, but I was concerned with getting the data source to the grid. I'm using Spring so if there is a more efficient manner to do this, please let me know.
Thanks.Sounds like it doesn't scale good if you have lots of users, but it's only a reference to the list that is passed around.
Kaj

Similar Messages

  • StringBuffer Object  in Request

    Hi,
    How to pass StringBuffer Object From JSP to Struts Action.that's i have to get the String Buffer Object from Request .Instead of Using Session
    Regards
    john
    +91 9791132453

    Parameters to servlets/jsps can only be strings.
    Is there any reason it can't be a String object as opposed to a StringBuffer?
    The only way this would work is if you sent the String as a value on the JSP, and then re-submitted it to the server.
    Thats a round trip for the value. If the value is not too large, you should be ok, but given you are using StringBuffer I kinda doubt thats the case :-).
    Cheers,
    evnafets

  • Passing html object in a JSP to another JSP

    Below, I have a jsp page I want to pass the object name "BP" and all its values to a jsp in another jsp page. I can't use the session object can I? The html the jsp creates is within a form.
    I know the request.getParameter("BP") doesn't work because it must be a string.
    out.println("<form name=myform action='RevUpdate.jsp' method=post>");
    out.println("<PRE><Center><TABLE border = '5'>");
    for (int i=0; i < vBP.size(); i++)
    out.println("<TR><TD><font size='4'>" + ((Fetch_BP_RevLetter)vBP.elementAt(i)).getBP() + "</font></TD><TD><font size='4'><input type='text' size='3' maxlength='2' name='BP' value='" + ((Fetch_BP_RevLetter)vBP.elementAt(i)).getItemRev() + "'/></font></TD></TR>");
    out.println("</Center></Table>");
    out.println("<input type='submit' value='Save'><INPUT TYPE='Button' VALUE='Back' onClick='history.go(-1)'>");
    out.println("</Center>");
    out.println("</form>"); //END OF myform
    HttpSession sessionid = request.getSession(false);
    sessionid.invalidate();

    request.setAttribute()

  • Storing Objects in Request Scope

    Hello,
    I'm trying to pass an object in the request scope between a JSPDynPage and the associated JSP however the object is always null. If I store it in the session I am able to retrieve it.
    Could anyone assist in how to do this?
    My code is as follows, thanks and regards.
    public class MyClass extends PageProcessorComponent {
      private String redirectToPage = "";
      private static final String INITAL_PAGE = "initialpage.jsp";
      private static final String SECONDARY_PAGE = "secondarypage.jsp";
      private static final String BEAN_ALIAS = "myBean";
      public void doProcessBeforeOutput() throws PageException {
        if (redirectToPage == null || redirectToPage.equals("")) {
          this.setJspName(INITAL_PAGE);
        } else {
          this.setJspName(redirectToPage);
      public void onMyButtonEvent (Event event) {
        redirectToPage = SECONDARY_PAGE;
        MyBeanClass myBean = new MyBeanClass();
        IPortalComponentRequest componentRequest = (IPortalComponentRequest)getRequest();
        componentRequest.putValue(BEAN_ALIAS, myBean);
    secondarypage.jsp:
    <%@ page session = "true"%>
    <%@ taglib uri="tagLib" prefix="hbj" %>
    <jsp:useBean id="myBean" scope="request" class="MyBeanClass " />
    <hbj:content id="myContent">
      <hbj:page title="myTitle">
       <hbj:form id="myForm">
         <% if (myBean != null) {
              out.println("null");
            } else {
              out.println("not null");
         %>
       </hbj:form>
      </hbj:page>
    </hbj:content>
    output on the page is always "null" ??

    Hi,
    Thanks for your posts... the null logic was actually a typo.
    I've solved the problem myself - basically I think the <jsp:useBean doesn't work as I expect it (that is automatically obtain the handle to the bean):
    MyDynPage.java:
    package com.my;
    import com.sapportals.htmlb.*;
    import com.sapportals.htmlb.enum.*;
    import com.sapportals.htmlb.event.*;
    import com.sapportals.htmlb.page.*;
    import com.sapportals.portal.htmlb.page.*;
    import com.sapportals.portal.prt.component.*;
    public class MyDynPage extends PageProcessorComponent {
      public DynPage getPage(){
        return new MyDynPageDynPage();
      public static class MyDynPageDynPage extends JSPDynPage{
        public void doInitialization(){
        public void doProcessAfterInput() throws PageException {
        public void doProcessBeforeOutput() throws PageException {
              IPortalComponentRequest componentRequest = (IPortalComponentRequest)getRequest();
              componentRequest.putValue("myRequestParam", "My Request Param Value");
              MyBean myBean = new MyBean("My Bean Title Value");          
              componentRequest.putValue("myBean", myBean);
             this.setJspName("myJSP.jsp");
    MyBean.java:
    package com.my;
    import java.io.Serializable;
    public class MyBean implements Serializable {
         private String txtTitle;
         //setters
         public void setTxtTitle(String txtTitle) { this.txtTitle = txtTitle; }
         //getters
         public String getTxtTitle() { return this.txtTitle; }
         public MyBean(String txtTitle) { //constructor
              this.txtTitle = txtTitle;
    myJSP.jsp:
    <%@ page session = "true"%>
    <%@ taglib uri="tagLib" prefix="hbj" %>
    <jsp:useBean id="myBean" scope="request" class="com.my.MyBean" />
    <hbj:content id="myContext" >
      <hbj:page title="PageTitle">
       <hbj:form id="myFormId" >
        <%
               String myRequestParam = (String)componentRequest.getValue("myRequestParam");
              out.println("myRequestParam: " + myRequestParam + "<br>");
              if (myBean == null) {
                   out.println("myBean is null<br>");
              } else {
                   out.println("myBean is not null<br>");
                   out.println(myBean.getTxtTitle() + "<br>");
              com.my.MyBean myOtherBean = (com.my.MyBean) componentRequest.getValue("myBean");
              if (myOtherBean == null) {
                   out.println("myOtherBean is null");
              } else {
                   out.println("myOtherBean is not null<br>");
                   out.println(myOtherBean.getTxtTitle() + "<br>");
        %>
       </hbj:form>
      </hbj:page>
    </hbj:content>
    The output is:
    myRequestParam: My Request Param Value
    <b>myBean is null</b>
    myOtherBean is not null
    My Bean Title Value
    It appears that you can save objects in the request scope however you need to manually retrieve them. I'm pretty sure that this is not the case in other J2EE servers as the <jsp:useBean tag should imply that I want the bean retrieved from the scope automatically or created if it's null.
    However the use of the <jsp:useBean appears to work correctly/as expected when using the session scope.
    Thanks for your assistance.
    DSR

  • How to pass JSON object for a PUT operation of restful

    Hi,
    I am trying to proxy restful call through an OSB proxy and I would like to know how I can pass json object via OSB proxy to an external rest service for a PUT operation? I am using Oracle 11g.
    I have created a business service, that point to the external rest service and created a proxy service that route to the business service. I thought it automatically takes the JSON, which is the data need to be send to the rest service, but didn't work, I get 405 error in the osb access log. is that how it works, or there is something else I need to do? if so, can you please help and tell me how?
    appreciate any kind of help.
    thanks
    Marwa.

    Hi Anju,
    Most of the example I see is dealing with data being pass either as query-string or html form. We are passing JSON object from the UI and rest services are configured to take JSON. therefore, in the PUT and POST data are passed either as an attachment or part of the request object. Do you know or have an example how to do it? I don't need to any kind of transformation of data because I need JSON on both end and I am trying to use the OSB proxy in between my UI and rest services to take advantage of monitoring capability of the OSB.
    appreciate any help, my deadline is getting close and I kind stuck.
    Thanks
    M.

  • Large Objects (LOBS) in xcelsius

    Please let me know if Large Objects (LOBS) pass through to Xcelsius?
    Thanks in Advance!

    Hi,
    The error is caused as the otn_airports table is not created.
    This is the command to create the table:
    CREATE TABLE otn_airports(airport_code VARCHAR2(3),
    description VARCHAR2(80), name VARCHAR2(40) NOT NULL)
    The same query is present in createTable() method of PopulateTable class.
    Check if the query is proper.
    If you face the same problem again then create the table
    using the above command manually and insert the data using the following commands:
    INSERT INTO otn_airports(airport_code, description, name) VALUES("ABE","Regional Airport","Allentown");
    INSERT INTO otn_airports(airport_code, description, name) VALUES("ABI","Municipal","Abilene");
    INSERT INTO otn_airports(airport_code, description, name) VALUES("ABQ","International Airport","Albuquerque");
    INSERT INTO otn_airports(airport_code, description, name) VALUES("ABR","Regional Airport","Aberdeen");
    INSERT INTO otn_airports(airport_code, description, name) VALUES("ABX","Albury","Albury");
    INSERT INTO otn_airports(airport_code, description, name) VALUES("ABY","County Airport","Albany");
    INSERT INTO otn_airports(airport_code, description, name) VALUES("ABZ","Dyce","Aberdeen");
    INSERT INTO otn_airports(airport_code, description, name) VALUES("ACA","International Airport","Acapulco");
    INSERT INTO otn_airports(airport_code, description, name) VALUES("ACE","Lanzarote","Lanzarote");
    INSERT INTO otn_airports(airport_code, description, name) VALUES("ACI","The Blaye","Alderney");
    Now run the sample.
    Regards,
    Anupama

  • How to pass an object from jsp to other jsp using SendRedirect

    How to pass an object from one jsp to the other jsp using ssendRedirect with out using the session
    I am having 2 jsps
    x.jsp and y.jsp
    From x.jsp using sendRedirect iam going to y.jsp
    From x.jsp i have pass an object to the y.jsp
    Is it possible without putting the object in session
    Is it possible using EncodeUrl
    Please help me Its Urgent

    Is it possible without putting the object in sessionAnything is possible. Would you accept that it is very difficult?
    When you send a redirect, it tells the browser to send a new request for the target page. That means any request parameters/attributes are lost.
    Is it possible using EncodeUrl response.encodeURL() puts the session id into a url if the browser does not support cookies. It is purely for retaining the session.
    There are two ways that you can communicate across a sendRedirect.
    1 - use the session
    2 - pass a parameter in the url.
    parameters are string based, so passing objects is almost out of the question.
    Potentially you could serialize your object, encode it in base64 (so it is composed completely as characters) and pass it as a parameter to the other page, where you retrieve it, unencode it, and then load the serialized object.
    Or you can just use the session.

  • Trying to pass and object variable to a method

    I have yet another question. I'm trying to display my output in succession using a next button. The button works and I get what I want using test results, however what I really want to do is pass it a variable instead of using a set number.
    I want to be able to pass the object variables myProduct, myOfficeSupplies, and maxNumber to method actionPerformed so they can be in-turn passed to the displayResults method which is called in the actionPerformed method. Since there is no direct call to actionPerformed because it is called within one of the built in methods, I can't tell it to receive and pass those variables. Is there a way to do it without having to pass them through the built-in methods?
    import javax.swing.JToolBar;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JTextArea;
    import javax.swing.JScrollPane;
    import javax.swing.JPanel;
    import java.net.URL;
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    public class Panel extends JPanel implements ActionListener
         protected JTextArea myTextArea;
         protected String newline = "\n";
         static final private String FIRST = "first";
         static final private String PREVIOUS = "previous";
         static final private String NEXT = "next";
         public Panel( Product myProduct, OfficeSupplies myOfficeSupplies, int maxNumber )
                 super(new BorderLayout());
              int counter = 0;
                 //Create the toolbar.
                 JToolBar myToolBar = new JToolBar( "Still draggable" );
                 addButtons( myToolBar );
                 //Create the text area used for output.
                 myTextArea = new JTextArea( 450, 190 );
                 myTextArea.setEditable( false );
                 JScrollPane scrollPane = new JScrollPane( myTextArea );
                 //Lay out the main panel.
                 setPreferredSize(new Dimension( 450, 190 ));
                 add( myToolBar, BorderLayout.PAGE_START );
                 add( scrollPane, BorderLayout.CENTER );
              myTextArea.setText( packageData( myProduct, myOfficeSupplies, counter ) );
              setCounter( counter );
         } // End Constructor
         protected void addButtons( JToolBar myToolBar )
                 JButton myButton = null;
                 //first button
                 myButton = makeNavigationButton( FIRST, "Display first record", "First" );
                 myToolBar.add(myButton);
                 //second button
                 myButton = makeNavigationButton( PREVIOUS, "Display previous record", "Previous" );
                 myToolBar.add(myButton);
                 //third button
                 myButton = makeNavigationButton( NEXT, "Display next record", "Next" );
                 myToolBar.add(myButton);
         } //End method addButtons
         protected JButton makeNavigationButton( String actionCommand, String toolTipText, String altText )
                 //Create and initialize the button.
                 JButton myButton = new JButton();
                     myButton.setActionCommand( actionCommand );
                 myButton.setToolTipText( toolTipText );
                 myButton.addActionListener( this );
                   myButton.setText( altText );
                 return myButton;
         } // End makeNavigationButton method
             public void actionPerformed( ActionEvent e )
                 String cmd = e.getActionCommand();
                 // Handle each button.
              if (FIRST.equals(cmd))
              { // first button clicked
                          int counter = 0;
                   setCounter( counter );
                 else if (PREVIOUS.equals(cmd))
              { // second button clicked
                   counter = getCounter();
                      if ( counter == 0 )
                        counter = 5;  // 5 would be replaced with variable maxNumber
                        setCounter( counter );
                   else
                        counter = getCounter() - 1;
                        setCounter( counter );
              else if (NEXT.equals(cmd))
              { // third button clicked
                   counter = getCounter();
                   if ( counter == 5 )  // 5 would be replaced with variable maxNumber
                        counter = 0;
                        setCounter( counter );
                      else
                        counter = getCounter() + 1;
                        setCounter( counter );
                 displayResult( counter );
         } // End method actionPerformed
         private int counter;
         public void setCounter( int number ) // Declare setCounter method
              counter = number; // stores the counter
         } // End setCounter method
         public int getCounter()  // Declares getCounter method
              return counter;
         } // End method getCounter
         protected void displayResult( int counter )
              //Test statement
    //                 myTextArea.setText( String.format( "%d", counter ) );
              // How can I carry the myProduct and myOfficeSupplies variables into this method?
              myTextArea.setText( packageData( product, officeSupplies, counter ) );
                 myTextArea.setCaretPosition(myTextArea.getDocument().getLength());
             } // End method displayResult
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event dispatch thread.
         public void createAndShowGUI( Product myProduct, OfficeSupplies myOfficeSupplies, int maxNumber )
                 //Create and set up the window.
                 JFrame frame = new JFrame("Products");
                 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                 //Add content to the window.
                 frame.add(new Panel( myProduct, myOfficeSupplies, maxNumber ));
                 //Display the window.
                 frame.pack();
                 frame.setVisible( true );
             } // End method createAndShowGUI
         public void displayData( Product myProduct, OfficeSupplies myOfficeSupplies, int maxNumber )
              JTextArea myTextArea = new JTextArea(); // textarea to display output
              JFrame JFrame = new JFrame( "Products" );
              // For loop to display data array in a single Window
              for ( int counter = 0; counter < maxNumber; counter++ )  // Loop for displaying each product
                   myTextArea.append( packageData( myProduct, myOfficeSupplies, counter ) + "\n\n" );
                   JFrame.add( myTextArea ); // add textarea to JFrame
              } // End For Loop
              JScrollPane scrollPane = new JScrollPane( myTextArea ); //Creates the JScrollPane
              JFrame.setPreferredSize(new Dimension(350, 170)); // Sets the pane size
              JFrame.add(scrollPane, BorderLayout.CENTER); // adds scrollpane to JFrame
              JFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); // Sets program to exit on close
              JFrame.setSize( 350, 170 ); // set frame size
              JFrame.setVisible( true ); // display frame
         } // End method displayData
         public String packageData( Product myProduct, OfficeSupplies myOfficeSupplies, int counter ) // Method for formatting output
              return String.format( "%s: %d\n%s: %s\n%s: %s\n%s: %s\n%s: $%.2f\n%s: $%.2f\n%s: $%.2f\n%s: $%.2f",
              "Product Number", myOfficeSupplies.getProductNumber( counter ),
              "Product Name", myOfficeSupplies.getProductName( counter ),
              "Product Brand",myProduct.getProductBrand( counter ),
              "Number of Units in stock", myOfficeSupplies.getNumberUnits( counter ),
              "Price per Unit", myOfficeSupplies.getUnitPrice( counter ),
              "Total Value of Item in Stock is", myOfficeSupplies.getProductValue( counter ),
              "Restock charge for this product is", myProduct.restockingFee( myOfficeSupplies.getProductValue( counter ) ),
              "Total Value of Inventory plus restocking fee", myOfficeSupplies.getProductValue( counter )+
                   myProduct.restockingFee( myOfficeSupplies.getProductValue( counter ) ) );
         } // end method packageData
    } //End Class Panel

    multarnc wrote:
    My instructor has not been very forthcoming with assistance to her students leaving us to figure it out on our own.Aren't they all the same! Makes one wonder why they are called instructors. <sarcasm/>
    Of course it's highly likely that enough information was imparted for any sincere, reasonably intelligent student to actually figure it out, and learn the subject in the process.
    And if everything were spoonfed, how would one grade the performance of the students? Have them recite from memory
    public class HelloWorld left-brace
    indent public static void main left-parenthesis String left-bracket right-bracket args right-parenthesis left-brace
    And everywhere that Mary went
    The lamb was sure to go
    db

  • How to pass an object as method parameter

    Hi Guys
    I was testing a simple program and was trying to pass an object to a method but it didnt seem to work and I couldnt find out WHY.
    I am posting the code so please let me know who can i make my method ADD_EMPLOYEE work so that when i pass an object of LCL_EMPLOYEE, it updates I_EMPLOYEE_LIST.
    *& Report:  ZOO_HR_SAMPLE_1
    *& Author:  Avinash Pandey
    *& Date:    25.03.2009
    *& Description: Concepts of OO in ABAP
    REPORT  zoo_hr_sample_1.
    *&       Class LCL_EMPLOYEE
           Local class
    CLASS lcl_employee DEFINITION.
    Public section
      PUBLIC SECTION.
    Data type
        TYPES:
          BEGIN OF t_employee,
            no  TYPE i,
            name TYPE string,
            wage TYPE i,
         END OF t_employee.
    Method
        METHODS:
          constructor
            IMPORTING im_employee_no TYPE i
                      im_employee_name TYPE string
                      im_wage TYPE i,
            add_employee
             IMPORTING im_employee TYPE REF TO lcl_employee,
           display_employee_list,
           display_employee,
           get_no EXPORTING ex_no TYPE i,
           get_name EXPORTING ex_name TYPE string,
           get_wage EXPORTING ex_wage TYPE i.
      Class methods are global for all instances
        CLASS-METHODS: display_no_of_employees.
    Protected section
      PROTECTED SECTION.
      Class data are global for all instances
        CLASS-DATA: g_no_of_employees TYPE i.
        CLASS-DATA: i_employee_list TYPE TABLE OF t_employee.
    Private section
      PRIVATE SECTION.
       CLASS-DATA: i_employee_list TYPE TABLE OF t_employee.
        DATA: g_employee TYPE t_employee.
    ENDCLASS.               "LCL_EMPLOYEE
    *&       Class (Implementation)  LCL_EMPLOYEE
           Text
    CLASS lcl_employee IMPLEMENTATION.
    Class constructor method
      METHOD constructor.
        g_employee-no = im_employee_no.
        g_employee-name = im_employee_name.
        g_employee-wage = im_wage.
        g_no_of_employees = g_no_of_employees + 1.
      ENDMETHOD.                    "constructor
    Method
      METHOD display_employee.
        WRITE:/ 'Employee', g_employee-no, g_employee-name.
      ENDMETHOD.                    "display_employee
    Method
      METHOD get_no.
        ex_no = g_employee-no.
      ENDMETHOD.                    "get_no
    Method
      METHOD get_name.
        ex_name = g_employee-name.
        WRITE: / 'Name is:' , ex_name.
      ENDMETHOD.                    "get_no
    Method
      METHOD get_wage.
        ex_wage = g_employee-wage.
      ENDMETHOD.                    "get_no
    Method
      METHOD add_employee.
      Adds a new employee to the list of employees
        DATA: l_employee TYPE t_employee.
        l_employee-no = im_employee->get_no.
        l_employee-name = im_employee->get_name.
        l_employee-wage = im_employee->get_wage.
        APPEND l_employee TO i_employee_list.
      ENDMETHOD.                    "add_employee
    Method
      METHOD display_employee_list.
      Displays all employees and there wage
        DATA: l_employee TYPE t_employee.
        WRITE: / 'List of Employees'.
        LOOP AT i_employee_list INTO l_employee.
          WRITE: / l_employee-no, l_employee-name, l_employee-wage.
        ENDLOOP.
      ENDMETHOD.                    "display_employee_list
    Class method
      METHOD display_no_of_employees.
        WRITE: / 'Number of employees is:', g_no_of_employees.
      ENDMETHOD.                    "display_no_of_employees
    ENDCLASS.               "LCL_EMPLOYEE
    REPORT
    DATA: g_employee1 TYPE REF TO lcl_employee,
          g_employee2 TYPE REF TO lcl_employee.
    START-OF-SELECTION.
    Create class instances
      CREATE OBJECT g_employee1
        EXPORTING
          im_employee_no   = 1
          im_employee_name = 'John Jones'
          im_wage          = 20000.
      CREATE OBJECT g_employee2
        EXPORTING
          im_employee_no   = 2
          im_employee_name = 'Sally Summer'
          im_wage          = 28000.
    Call methods
      CALL METHOD g_employee1->display_employee.
      CALL METHOD g_employee1->add_employee
        EXPORTING
          im_employee = g_employee1.
      CALL METHOD g_employee1->get_name.
      CALL METHOD g_employee2->display_employee.
      CALL METHOD g_employee2->display_no_of_employees.
    The error I am getting is:
    Field GET_NO/GET_NAME/GET_WAGE is unknown.
    Please help me out on this.
    Thanks a lot you people

    hi.
    The following parts of your program were changed.
    The result is OK?.
    *(1)change
    CLASS lcl_employee DEFINITION.
    Public section
    PUBLIC SECTION.
    display_employee,
    *get_no EXPORTING ex_no TYPE i,
    *get_name EXPORTING ex_name TYPE string,
    *get_wage EXPORTING ex_wage TYPE i.
    get_no returning value(ex_no) TYPE i,
    get_name returning value(ex_name) TYPE string,
    get_wage returning value(ex_wage) TYPE i.
    *(2)change
    CLASS lcl_employee IMPLEMENTATION.
    Method
    METHOD add_employee.
    Adds a new employee to the list of employees
    DATA: l_employee TYPE t_employee.
    *l_employee-no = im_employee->get_no.
    *l_employee-name = im_employee->get_name.
    *l_employee-wage = im_employee->get_wage.
    l_employee-no   = im_employee->get_no( ).
    l_employee-name = im_employee->get_name( ).
    l_employee-wage = im_employee->get_wage( ).
    APPEND l_employee TO i_employee_list.
    ENDMETHOD. "add_employee
    Result List
    Employee          1  John Jones
    Name is: John Jones
    Name is: John Jones
    Employee          2  Sally Summer
    Number of employees is:          2

  • How to Pass Java Objects between Web Dynpro and Java SAP iViews

    Basically I have an SAP web dynpro iView that I do stuff with and I want to pass an object to another iView which is just a regular Java iView. From what I've read and tried, I can't just stick something in the session object and hope that the Java iView can pull it down the other end. I had a dream that it was possible (seriously).
    Anyway, are there any possible solutions around? Please advice and share you throughts. I will try to dream about it again tonight and see if its really gonna work this time.
    thanks for your help in advance

    There is no easy way you can pass objects other than those supported by express such as String, map, list etc.
    Though not advised, you can create a class with static variables to handle the storage of such java objects during transition between form and workflow. You will need to somehow identify the objects uniquely .

  • How can I pass an object to a function by value?

    Hi
    I have a function with an argument. this argument is an object. I don't want to alter this object. But java passes this object by reference and some fields in this object are altered after function return.
    How can I pass this object by value and keep my original data unbroken?
    thanks for any help

    a.toraby wrote:
    I have a function with an argument. this argument is an object. I don't want to alter this object. But java passes this object by reference and some fields in this object are altered after function return.
    How can I pass this object by value and keep my original data unbroken?How you approach it is likely to depend on how much control you have over the code in question. If it's legacy code and has been badly designed, there's probably very little you can do to protect existing code short of a complete refactoring.
    What you could do as an interim measure is:
    1. Create an immutable wrapper to your existing mutable class.
    2. Create new methods that replicate the existing ones, but take the immutable class instead.
    3. Deprecate the old methods.
    This won't break client code, but they will now get warnings when they compile and you can add documentation to point them to the new class/methods.
    If you are in control of the code (especially if you're still in the design stages), you've got several options:
    1. As Dr.Clap says, make your class immutable (probably best).
    2. If this isn't possible, create mutable and immutable variants of your class. This is often best achieved by hanging them both from an interface.
    Winston

  • JPA2 - downloading large objects from database

    Hi,
    I would like to enable user to download large (up to 20Mb) files, stored in Oracle database.
    I think I should use a stream, but I don't know how to get JPA to return a stream of Large Object. Can you help?
    I'm using EclipseLink.

    Hello,
    http://wiki.eclipse.org/EclipseLink/Examples/JPA/Pagination#Using_a_ScrollableCursor describes using a scrollable cursor to return entities. Since this is going through JPA (you didn't mention what api you are using to access EclipseLink) you will want to be careful to manage/clear your cache appropriately so it does not use all your available memory. You will probably want to make this query read-only, and clear the cache after a few iterations using em.clear().
    http://wiki.eclipse.org/Introduction_to_EclipseLink_Queries_(ELUG)#Stream_and_Cursor_Query_Results describes and has links to using streams and cursors with the native EclipseLink read queries.
    Best Regards,
    Chris

  • How to set  an object in request scope in  a jsp uysing  jstl

    I usally use scriptlet in jsp to set an object in request is
    there a way to do this using jstl
    instead of this
    <%request.setAttribute("test",myObject);%> I want to use tag ?

    The <c:set> tag should be useful...
    Of course if you can access it as a JSTL variable it IS already an attribute in scope.

  • How to pass an object as a parameter

    how do you pass an object as a parameter? (what type should it be ?)

    Well you can use a [url http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html]String
    Or you can take a [url http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Double.html]Double
    And you can pass [url http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Event.html]Events
    and get yourself in trouble
    and you can use a [url http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Frame.html]Frame
    or maybe take a [url http://java.sun.com/j2se/1.4.2/docs/api/java/util/List.html]List
    but some will use [url http://java.sun.com/j2se/1.4.2/docs/api/java/util/Collection.html]Collection
    depends you your direction
    so if you need to know
    if you should use a [url http://java.sun.com/j2se/1.4.2/docs/api/java/util/Map.html]Map
    then this is what to do
    just browse the [url http://java.sun.com/j2se/1.4.2/docs/api/]API

  • How to pass class object  as in parameter in call to pl/sql procedure ?

    hi,
    i have to call pl/sql proecedure through java. In pl/sql procedure as "In" parameter i have created "user defined record type" and i am passing class object as "In" parameter in call to pl/sql procedure. but it is giving error.
    so, anyone can please tell me how i can pass class object as "In" parameter in call to pl/sql procedure ?
    its urgent ...
    pls help me...

    793059 wrote:
    I want to pass a cursor to a procedure as IN parameter.You can use the PL/SQL type called sys_refcursor - and open a ref cursor and pass that to the procedure as input parameter.
    Note that the SQL projection of the cursor is unknown at compilation time - and thus cannot be checked. As this checking only happens at run-time, you may get errors attempting to fetch columns from the ref cursor that does not exist in its projection.
    You also need to ask yourself whether this approach is a logical and robust one - it usually is not. The typical cursor processing template in PL/SQL looks as follows:
    begin
      open cursorVariable;
      loop
        fetch cursorVariable bulk collect into bufferVariable limit MAX_ROWS_FETCH;
        for i in 1..bufferVariable.Count
        loop
          MyProcedure( buffer(i) );   --// <-- Pass a row structure to your procedure and not a cursor
        end loop;
        ..etc..
        exit when cursorVariable%not_found;
      end loop;
      close cursorVariable;
    end;

Maybe you are looking for

  • Keyword FIND problem in CS3 Bridge (Windows XP Professional)

    Select a large group of photos. File > File Info. In File Info dialogue box, enter Europe in the keyword field. Next, select a sub-group, add the keyword as above Italy. For another sub-group add the word France, and for a third sub-group add the wor

  • Making package(s) for x86 instead of 686

    I have a need to build a custom version of a couple of Arch packages for use on a special purpose Live CD - these packages are NOT for installing or running on my regular Arch distro itself. The ONLY thing I want to customize for each package is to c

  • Combining 2 Sales Orders - 'Complete' with 'Partial'  Delivery into 1 Delv

    Hi folks, I have a typical requirement from my client and it is as follows: My client want to combine 'Sales Orders' marked with 'Complete Delivery' indicator(VBAK-AUTLF check-box is checked) at the Header -> Shipping, with Sales Orders marked for 'P

  • Deleting applications in 7610

    I INSTALLED AN APPLICATION SOFTWARE AND NOW I COULD NOT DELETE IT.EVERY TIME I TRY MY PHONE GET STUCK. PLZ HELP!

  • Using registrar for Muse

    Hello Adobe community, I was just wondering if have to go through registrar to get a domain for my muse site? Or can I get it somewhere else?