Passing Vectors to Methods

import java.util.*;
public class usingVectors
static Scanner console = new Scanner(System.in);
public static void main(String[] args)
          int VECTOR_SIZE;
          System.out.print("Enter the size of the array: ");
          VECTOR_SIZE = console.nextInt();
          System.out.println();
Vector<Integer> listA = new Vector<Integer>();
System.out.print("Enter " + VECTOR_SIZE + " integers: ");
fillArray(listA, VECTOR_SIZE);
System.out.println();
System.out.print("List of Integers that you inputted: \n ");
printArray(listA, VECTOR_SIZE);
System.out.println();
System.out.println("The position of the smallest integers in the array is: " + indexSmallest(listA, VECTOR_SIZE));
System.out.println("The smallest integer in the array is: " + listA[indexSmallest(listA, VECTOR_SIZE)]);
public static void fillArray(int list, int sizeOfVector)
int index;
for (index = 0; index < sizeOfVector; index++)
list[index] = console.nextInt();
     public static void printArray(int list, int sizeOfVector)
          int index;
          for (index = 0; index < sizeOfVector; index++)
          System.out.print(list[index] + " ");
     public static int indexSmallest(int list, int sizeOfVector)
          int index;
          int smallIndex = 0;
          for (index = 0; index < sizeOfVector; index++)
          if (list[smallIndex] > list[index])
     smallIndex = index;
          return smallIndex;
Im trying to pass a vector to a method. Im not sure what i am doing wrong if anyone could look at what im doing wrong i would appreciate it.
ER:usingVectors.java:19: fillArray(int,int) in usingVectors cannot be applied to (java.util.Vector<java.lang.Integer>,int)
fillArray(listA, VECTOR_SIZE);

My first problem was to write a method, smallestIndex that takes as its parameters an int array and its size. Return the smalles element in the array and its postion. Now i have that done and it was good. He wants us to change that program to use vectors. So i feel like i have done most of it right but like you said the error. It won't pass the vector through to the method. I believe
ok thank you. I guess what i should ask you now. In my line of code. How do i set the parameters to pass a Vector instead of the int?
THANK YOU FOR YOU HELP
Vector<Integer> listA = new Vector<Integer>();                     
        System.out.print("Enter " + VECTOR_SIZE + " integers: ");                       
        fillArray(listA, VECTOR_SIZE);  **This is where i call my method with the vector name listA, and the int VECTOR_SIZE, it pops the problem here or would it be in the declaring the new varibles at the start of the method**                      
        System.out.println();                                  
        System.out.print("List of Integers that you inputted: \n     ");                       
        printArray(listA, VECTOR_SIZE);                       
        System.out.println();                                        
        System.out.println("The position of the smallest integers in the array is: " + indexSmallest(listA, VECTOR_SIZE));  
        System.out.println("The smallest integer in the array is: " + listA[indexSmallest(listA, VECTOR_SIZE)]);
    public static void fillArray(int list, int sizeOfVector) *Or would it be here?*
        int index;
        for (index = 0; index < sizeOfVector; index++)
            list[index] = console.nextInt();
    }

Similar Messages

  • Passing vectors

    Does anyone have any examples of passing a vector from method to method?

    I agree with the principle that you might need access to methods not defined in List but in this case I really don't think it's necessary. What could you use the Vector for other than a dynamic size list? Why would you need to call setSize()? By saying that the method takes a List you have documented the concept that the method does something with a list, not necessarily a Vector. It's confusing to specify a Vector in the method because it leads you to believe that it does some Vector specific stuff to it, which it most likely doesn't.
    Regardless, Vector shouldn't be used because it's now a legacy class. Let's all join the 21st century and start using ArrayList :-). And don't give me the, "but Vector's synchronized and Arraylist isn't" argument.
    List list = Collection.synchronizedList(new ArrayList());

  • Urgent help req : work item id not getting passed in the method

    Hi ,
    I have created a subtype zcats of business object CATS and delegated it .
    I have created a new method Approve1 ( with attributes  SYNCRONUS & DIALOG )  in zcats which is similar in coding  to Approve method of CATS ( DIALOG) .
    I have include the method Approve1 of business object zcats in a standard task .
    The problem is that when the eorkflow gets triggered ,  the workitem id is not getting passed in the method APProve1 of zcats.
    Can someone please help me with this .
    Points would surely be awarded .

    BEGIN_METHOD APPROVE1 CHANGING CONTAINER.                 
      DATA: WORKITEMID_IMP LIKE OBJECT-KEY-ITEMID.              
      DATA: WI_CHCKWI LIKE SWWWIHEAD-WI_ID.                     
      DATA: WORKITEM TYPE SWC_OBJECT.                           
       <u> WORKITEMID_IMP = OBJECT-KEY-ITEMID</u>.                     
        SWC_GET_ELEMENT CONTAINER '_WORKITEM' WORKITEM.         
        SWC_GET_PROPERTY WORKITEM 'WorkitemReference' WI_CHCKWI.
        IF SY-SUBRC EQ 0 AND NOT WI_CHCKWI IS INITIAL.          
          WORKITEMID_IMP = WI_CHCKWI.                           
        ENDIF.                                                  
        CALL FUNCTION 'CATS_WF_APPROVAL'                        
          EXPORTING                                             
            WORKITEMID_IMP = WORKITEMID_IMP                     
          TABLES                                                
            CONT_IMP = CONTAINER.                               
      END_METHOD.                                               
    hi ,
    the above is the code in the method .
    At the first step of execution underlined above , the work item id is appearing blank .
    I think that the value is not passed to the container , but i am not sure og how to pass data to this conatiner

  • Passing Parameter between Methods

    I have some problems because i don't really know how to pass parameter between methods in a java class.
    How can i do that? below is the code that i did.
    I want to pass in the parameter from a method called dbTest where this method will run StringTokenizer to capture the input from a text file then it will run storeData method whereby later it will then store into the database.
    How can i pass data between this two methods whereby i want to read from text file then take the value to be passed into the database to be stored?
    Thanks alot
    package com;
    import java.io.*;
    import java.util.*;
    import com.db4o.ObjectContainer;
    import com.db4o.Db4o;
    import com.db4o.ObjectSet;
      class TokenTest {
           private final static String filename = "C:\\TokenTest.yap";
           public String fname;
         public static void main (String[] args) {
              new File(filename).delete();
              ObjectContainer db=Db4o.openFile(filename);
         try {
            String fname;
            String lname;
            String city;
            String state;
             dbStore();
            storeData();
         finally {
              db.close();
         public String dbTest() {
            DataInputStream dis = null;
            String dbRecord = null;
            try {
               File f = new File("c:\\abc.txt");
               FileReader fis = new FileReader(f);
               BufferedReader bis = new BufferedReader(fis);
               // read the first record of the database
             while ( (dbRecord = bis.readLine()) != null) {
                  StringTokenizer st = new StringTokenizer(dbRecord, "|");
                  String fname = st.nextToken();
                  String lname = st.nextToken();
                  String city  = st.nextToken();
                  String state = st.nextToken();
                  System.out.println("First Name:  " + fname);
                  System.out.println("Last Name:   " + lname);
                  System.out.println("City:        " + city);
                  System.out.println("State:       " + state + "\n");
            } catch (IOException e) {
               // catch io errors from FileInputStream or readLine()
               System.out.println("Uh oh, got an IOException error: " + e.getMessage());
            } finally {
               // if the file opened okay, make sure we close it
               if (dis != null) {
                  try {
                     dis.close();
                  } catch (IOException ioe) {
                     System.out.println("IOException error trying to close the file: " +
                                        ioe.getMessage());
               } // end if
            } // end finally
            return fname;
         } // end dbTest
         public void storeData ()
              new File(filename).delete();
              ObjectContainer db = Db4o.openFile(filename);
              //Add data to the database
              TokenTest tk = new TokenTest();
              String fNme = tk.dbTest();
              db.set(tk);
        //     try {
                  //open database file - database represented by ObjectContainer
        //          File filename = new File("c:\\abc.yap");
        //          ObjectContainer object = new ObjectContainer();
        //          while ((dbRecord = bis.readLine() !=null))
        //          db.set(fname);
        //          db.set(lname);
        //          db.set(city);
            //          db.set(state);
    } // end class
         Message was edited by:
    erickh

    In a nutshell, you don't "pass" parameters. You simply call methods with whatever parameters they take. So, methods can call methods, which can call other methods, using the parameters in question. Hope that makes sense.

  • Passing vectors in a JSP Page

    Hi All,
    Can anybody please tell me as how I can pass vectors from a page to another page and how Can I retieve the value from the next page?
    Thanks,
    Aarthy

    I am using this code in the first page
    request.getSession.setAttribute("vec",v2);In the Recipient page
    Vector v5=new Vector();
    v5=(Vector)request.getSession().getAttribute("vec");I am getting nullPointerException when i try to get
    the size of the vector.Can anyone tell as where I am
    going wrong?
    Thanks,
    AarthyHow did u delclare your vector v2
    did u say
    Vector v2 = new Vector()
    session.setAttribute("vec",v2);
    if you just have said
    Vector v2 ;
    session.setAttribute("vec",v2);
    and trying to access v2.size() will throw NULL pointer exception
    good luck
    KM

  • Unable to detect any parameter in html (webresource) when value is passed from onload method of form

    Unable to detect any parameter in html (webresource) when value is passed from onload method of form
    I am trying out some stuff. For which I created a simple Entity. In the form of the entity I have added a simple web resource (html). And for the onload of the form I am calling the following function
    function HelpDeskActivityOnLoadhandler()
     var customParameters = encodeURIComponent("first=First Value&second=Second Value&third=Third Value");
        Xrm.Utility.openWebResource("tsi_scriptzz",customParameters);
    Here is the code for the  tsi_scriptzz.html
    <html>
     <body>
      <script type="text/javascript">
        var vals = new Array();
        if (location.search != "") {
         vals = location.search.substr(1).split("&");
         for (var i in vals) {
          vals[i] = vals[i].replace(/\+/g, " ").split("=");
      </script>
     </body>
    </html>
    MY PROBLEM IS -> location.search is always coming back with empty string. So, it not getting the parametrs I am passing from the load method of the form.
    Could someone kindly help me.
    Thanks,
    Hasib

    Hello, I tried it myself. I got a new_test.htm file and a new_test.js file. The loadWebResource function is called on the OnLoad event of an Entity.
    function loadWebResource()
    var params = encodeURIComponent('param1=value one&param2=value two&param3=value three');
    Xrm.Utility.openWebResource('new_test.htm', params);
    <html>
    <head>
    <title>Web Resource Parameter Example</title>
    <!-- Use ../ClientGlobalContext.js.aspx if your webresource is in a deeper folder on CRM -->
    <script src="ClientGlobalContext.js.aspx" type="text/javascript"></script>
    <script type="text/javascript">
    document.onreadystatechange = function () {
    if (document.readyState == 'complete') {
    var params = getParams();
    for(var i=0; i<params.length; i++)
    log(params[i].name + ' ' + params[i].value);
    // this functions puts the params in a 'dictionary format'
    // f.e params[0].name = param1 & params[0].value = 'value one'
    // You could customize this function or find some on the internet to retrieve a param fe by name...
    // This is just an example how to get the name and values
    function getParams(){
    var params = [];
    var querystring = Xrm.Page.context.getQueryStringParameters().Data;
    var querystringparts = querystring.split('&');
    for(var i=0; i<querystringparts.length;i++)
    var split = querystringparts[i].split('=');
    params.push({
    name: split[0],
    value: split[1]
    </script>
    </head>
    <body>
    </body>
    </html>
    Hope it helps now. Kind Regards

  • Passing vector of object with multiple datatype

    Hi
    I want to pass vector of objects to stored procedure and I am facing some problem
    please suggest is it possible or I need to follow some other way.
    I have one class detail with two attributes i.e int ID and string course
    In main I have created 1000 objects of different ID and course and pushed back the objects to avector of detail and passed to a function my function is
    void bulkdatainsert(vector<detail>rec)
    stmt = conn->createStatement ("begin storeBulk(:1);end;");
         stmt->setMaxIterations(rec.size());
         stmt->setMaxParamSize(1,1024);
         setVector(stmt,1,rec,"course"); // The error coming here
    The error is due to the type rec .
    I want to know can we pass objects of multiple data to stored procedure through OCCI ?
    If not do we need to break every attribute and make vector of corresponding attributes and pass to stored procedure?
    please suggest me
    Thanks

    I think Custom objects are not supported directly.
    Following are the normal ones which you can use
    void setVector(
    Statement *stmt,
    unsigned int paramIndex,
    const vector< T > &vect,
    const string &schemaName,
    const string &typeName);
    Intended for use on platforms
    where partial ordering of function
    templates is not supported, such
    as Windows NT. Multibyte
    support.
    void setVector(
    Statement *stmt,
    unsigned int paramIndex,
    const vector<T* > &vect,
    const string &schemaName,
    const string &typeName);
    Intended for use on platforms
    where partial ordering of function
    templates is supported. Multibyte
    support.
    void setVector(
    Statement *stmt,
    unsigned int paramIndex,
    const vector<BDouble> &vect
    const string &sqltype);
    void setVector(
    Statement *stmt,
    unsigned int paramIndex,
    const vector<Bfile> &vect,
    const string &schemaName,
    const string &typeName);
    void setVector(
    Statement *stmt,
    unsigned int paramIndex,
    const vector<BFloat> &vect
    const string &sqltype);
    void setVector(
    Statement *stmt,
    unsigned int paramIndex,
    const vector<Blob> &vect,
    const string &schemaName,
    const string &typeName);
    void setVector(
    Statement *stmt,
    unsigned int paramIndex,
    const vector<Blob> &vect,
    const UString &schemaName,
    const UString &typeName);
    Sets a const Blob vector; UTF16
    support.
    void setVector(
    Statement *stmt,
    unsigned int paramIndex,
    const vector<Clob> &vect,
    const string &schemaName,
    const string &typeName);
    Sets a const Clob vector;
    multibyte support.
    void setVector(
    Statement *stmt,
    unsigned int paramIndex,
    const vector<Clob> &vect,
    const UString &schemaName,
    const UString &typeName);
    Sets a const Clob vector; UTF16
    support.
    void setVector(
    Statement *stmt,
    unsigned int paramIndex,
    const vector<Date> &vect,
    const string &schemaName,
    const string &typeName);
    Sets a const Date vector;
    multibyte support.

  • Passing vectors or whatever

    writing video store applet for school.
    applet is main menu only, create frames for other duties(i.e. add a new customer...etc.)try to pass vectors to other frames from applet but get null pointer exception when I try to load vector with object.
    any ideas.
    thanks

    here is a pert of the code, I tried to highlight the problem spots
    import javax.swing.*;
    import javax.swing.JApplet.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.awt.Font;
    public class videoApp extends JApplet implements SwingConstants{
         private JFrame newVideo,newCustomer,newRental;
         private Vector customerList,videoList,rentaList;
         private addCustomer newCust;
         private addVideo newVid;
         //,newVideoPanel;
         private JButton transaction = new JButton("Video Rental");
         private JButton addCust = new JButton("New Customer");
         private JButton addVideo = new JButton("New Video");
         private JButton listVideo_customer = new JButton("Videos/Customer History");
         private JButton listCustomer_video = new JButton("Customer/Video History");
         public void init(){
              Container appPane = getContentPane();
              appPane.setLayout (new FlowLayout ());
              appPane.add(transaction);
              appPane.add(addCust);
              appPane.add(addVideo);
              appPane.add(listVideo_customer);
              appPane.add(listCustomer_video);
              pass vector to class
         --->newCust = new addCustomer();//(customerList);<---
              newVid = new addVideo();
              addCust.addActionListener(new ActionListener () {
                                  public void actionPerformed (ActionEvent event) {
                                  newCust.show();
    }//ends videoApp
    import javax.swing.*;
    import javax.swing.JApplet.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.awt.Font;
    //should extend JPanel instead creat frame in videoApp add addcustomer?
    class addCustomer extends JFrame implements SwingConstants{
    private String tmpName,tmpAddress,tmpPhone,tmpId;
    private static int i = 100;//for id
    private Customer cust;
    private Vector custList = new Vector();
    private int width;
    private int height;
    JLabel header = new JLabel ("Add A Customer");
    JLabel name = new JLabel ("Name");
    JTextField nameTxt = new JTextField("",20);
    JLabel address = new JLabel ("Address");
    JTextField addressTxt = new JTextField("",20);
    JLabel phone = new JLabel ("Phone");
    JTextField phoneTxt = new JTextField("",20);
    JLabel id = new JLabel ("Id");
    JTextField idTxt = new JTextField("",20);
    JButton addButton = new JButton("Add Customer");
    JButton exitButton = new JButton("Close");
    public addCustomer(){//(Vector v){
              *****receives vector from applet
              custList = v;
              Toolkit tk = Toolkit.getDefaultToolkit();
              Dimension size = tk.getScreenSize();
              width = size.width;
              height = size.height;
              setSize(width/2,height/2);
              setLocation(width /4, height / 4);
              setTitle("New Customer");
              Image img = tk.getImage("tv.gif");
              setIconImage(img);
              Container contentPane = getContentPane ();
              GridBagLayout custLayout = new GridBagLayout();
              contentPane.setLayout(custLayout);
              GridBagConstraints custConstraints = new GridBagConstraints();
              setConstraints(custConstraints,0, 0, 2, 1);
              custConstraints.insets.bottom = 10;
              header.setFont(new Font("Arial", Font.ITALIC, 24));
              contentPane.add(header,custConstraints);
              custConstraints.insets.bottom = 2;
              setConstraints(custConstraints,0,1, 1, 1);
              contentPane.add(name,custConstraints);
              setConstraints(custConstraints,1, 1, 1, 1);
              contentPane.add(nameTxt,custConstraints);
              setConstraints(custConstraints,0,2, 1, 1);
              contentPane.add(address,custConstraints);
              setConstraints(custConstraints,1,2, 2, 1);
              contentPane.add(addressTxt,custConstraints);
              setConstraints(custConstraints,0,3, 1, 1);
              contentPane.add(phone,custConstraints);
              setConstraints(custConstraints,1,3, 2, 1);
              contentPane.add(phoneTxt,custConstraints);
              setConstraints(custConstraints,0,4, 1, 1);
              contentPane.add(id,custConstraints);
              custConstraints.insets.bottom = 10;
              setConstraints(custConstraints,1,4, 2, 1);
              idTxt.setEditable(false);
              idTxt.setBackground(Color.white);
              contentPane.add(idTxt,custConstraints);
              //custConstraints.insets.right = 50;
         setConstraints(custConstraints,0,5, 1, 1);
              contentPane.add(addButton,custConstraints);
              //custConstraints.insets.right = 0;
         setConstraints(custConstraints,1,5, 1, 1);
              contentPane.add(exitButton,custConstraints);
              exitButton.addActionListener(new ActionListener () {
                        public void actionPerformed (ActionEvent event) {
                        setVisible(false);
              addButton.addActionListener(new ActionListener () {
                   public void actionPerformed (ActionEvent event) {
                        tmpId = createId();
                        idTxt.setText(tmpId);
                        cust = new Customer(nameTxt.getText(),addressTxt.getText(),phoneTxt.getText(),tmpId);
                        System.out.println("Name: "+cust.getName()+" Address: "+ cust.getAddress()+" Phone: "+ cust.getPhone()+" Id: "+ cust.getId());
                        ****null pointer exception***
                        custList.addElement(cust);
                        //System.out.println("Name: "+ nameTxt.getText());
                        //System.out.println("Name: "+ cust.getName() +" Address: "+ cust.getAddress()+" Phone: "+ cust.getPhone()+" Id: "+ cust.getId());
    /*exitButton.addActionListener(new ActionListener () {
                                  public void actionPerformed (ActionEvent event) {
                                  Enumeration customerList = custList.elements();
                                  while(customerList.hasMoreElements())
                                       cust= (Customer)customerList.nextElement();
                                       System.out.println("Name: "+cust.getName()+" Address: "+ cust.getAddress()+" Phone: "+ cust.getPhone()+" Id: "+ cust.getId());
         private void setConstraints(GridBagConstraints component,int x, int y, int w, int h) {
         component.gridx = x;
         component.gridy = y;
         component.gridwidth = w;
         component.gridheight = h;
         private static String createId()
              String id;
              id = "C" + i ;
              i++;
              return id;
    }//ends addCustomer

  • Call Paje jsp passing parameters with method post

    How can I call a jsp page with outputlink, passing parameters with method post ?
    Ex: I need that the word "?pNumMensagem=#{currentRow["NumMensagem"]}" not was exposed when a call P0077_2.jsp.
    <h:outputLink binding="#{P0077.hyperlink1}" id="hyperlink1" target="t1" value = "#{facesContext.externalContext.requestContextPath}/faces/P0077_2.jsp?pNumMensagem=#{currentRow["NumMensagem"]}">
    <h:outputText binding="#{P0077.outputText14}" id="outputText14" value="#{currentRow['NumMensagem']}"/>
    </h:outputLink>
    Thanks.
    Heitor.

    Any body have an idea ?

  • Passing vector into class/methods

    I am new to Vectors check this simple code out. I am trying to pass a vector onto another class then add an integer element to it. I see that its looking for an identifier but i dont unerstand how the code is for an identifier for a vector.
    ERRORS: .\Remove.java:4: <identifier> expected
         public static void AddIntegers(varray);
    ^
    .\Remove.java:4: ')' expected
         public static void AddIntegers(varray);
    ^
    .\Remove.java:4: cannot resolve symbol
    symbol : class varray
    location: class Remove
         public static void AddIntegers(varray);
    ^
    C:\Computer Work\Lab4\RemoveTest.java:11: cannot resolve symbol
    symbol : method varray ()
    location: class RemoveTest
              rm.AddIntegers(varray());
    ^
    .\Remove.java:4: missing method body, or declare abstract
         public static void AddIntegers(varray);
    ^
    .\Remove.java:6: cannot resolve symbol
    symbol : variable varray
    location: class Remove
              varray.AddElement(new Integer(13));
    ^
    6 errors
    Tool completed with exit code 1
    import java.io.*;
    import java.util.*;
    public class RemoveTest
         public static void main(String[] args)
              Vector varray = new Vector();
              Remove rm = new Remove();
              rm.AddIntegers(varray);
              System.out.println(varray);
    public class Remove
         public static void AddIntegers(varray);
              varray.AddElement(new Integer(13));

    I think the question whether you should use Vector over arrays, but rather should you use Lists over arrays. Vectors are kind of deprecated. You should be using the Collections Framework as a whole, and that means that ordered items are in java.uti.Lists, where are a kind of java.util.Collection, and a Vector is just a particular kind of List, and not necessarily even the best kind -- an ArrayList or LinkedList is often better.
    The advantage of arrays over Lists is that they can hold primitive types trivially. You can only hold objects in Lists, so you can put primitive class wrapper objects in Lists, but that has its disadvantages. Apparently in JDK 1.5 there's some syntactic sugar to make this easier, but there are still other disadvantages.
    The advantages of Lists over arrays are like what you mentioned -- things like resizings are automatic, there are lots of convenience methods, etc. The Collections Framework provides an abstraction of, well, collections, which is a good thing over futzing with details like with arrays, frequently.

  • Passing vectors into JSP from Servlet and passing data back to Servlet

    I have been building an MVC application.
    It has a controller which instantiates classes and evokes methods to
    populate vectors. These vectors are then passed into a JSP. This part of the application works fine.
    What I am having trouble with is a new JSP I have designed; this will
    display the data that is actioned by the FORM action. This is actioned
    based on the Search criteria entered by the user. Based on this a further vector is populated and brought back to the JSP as a vector
    and this is rendered via the TABLE tag. Again this works fine.
    Against each of the rows displayed, I have a print checkbox which can be checked by the user. On checking the records they want to print, they should then hint a Print button which should go back to the Servlet and print the data. THIS IS WHERE I HAVE THE PROBLEM. On going
    back to the servlet the checkbox values are not displayed, rather
    the values that initially populate the JSP. How do I get these new values back into the vector and hence accessible from the Servlet.
    Any help with be very much appreciated.
    Chris

    Thanks for this.
    Just to clarify I am not using Struts.
    What I am having difficulties with is the fact that:
    I can't get the checked values back to the Servlet - they keep the values they have in the bean - so as part of instantiating the bean class I set the value of the item to 'off'. The user will then check
    the checkbox which should presumbably set the value to 'on'. This isn't happening because the setter method of the bean is not evoked again
    because I don't come into this JSP again - the Servlet has finished here
    and now needs to print the records. It can't do this because as
    far as it is concerned nothing has changed since it last passed through
    the vector to the JSP.
    Even when I do the following:
    Enumeration paramNames = request.getParameterNames();
    String param = null;
    while (paramNames.hasMoreElements())
    param=(String)paramNames.nextElement();
    System.out.println("parameter " + param + " is " +
    request.getParameter(param));
    what comes back is the valus of 'off' as opposed to 'on'.
    The other thing is that 'request.getParameterNames()' only works
    with the first record in the vector, i.e. it doesn't fetch any other
    records that are rendered in the <TABLE> tag.
    In desperation is there anybody out there who can help me.
    Thanks
    Chris
    I am going to assume you are using a MVC framework
    like Struts or very similar (I am assuming that from
    the language you are using).
    When the servlet passes the vector back to the JSP
    page and you render the HTML that is passed back the
    client your Vector is gone. The Vector is not
    available at the HTML level that is being viewed at
    the browser.
    When the user selects the checkboxes and submits the
    page (by clicking the print button) the controller
    servlet (called ActionServlet in Struts, yours maybe
    called something else) forwards the request to the
    appropriate JavaBean and Servlet to process the
    request. Either the JavaBean has to recreate the
    Vector (not recommended) or the processing Servlet can
    (better). You can do this by recreating the Vector
    from scratch for the HttpRequest parameters or, at the
    time of the initial request, saving Vector to a
    session and then updating with the data you get back
    from the client (again from the HttpRequest
    parameters).
    Either way you have to work with
    HttpRequest.getParameter().

  • How to pass VECTOR to a stream

    i need to pass this vertor to the server side..
    but i don't know what method to use.
    CODE
    VECTOR     
    send_to_server = new Vector();
    send_to_server.add(0,input_str_name);
    send_to_server.add(1,input_str_password);
    I ALREADY CREATED A SOCKET AND CALLED S AND ALSO HAVE THIS CODE FOR CONNECTION.
    //Create socket
    Socket s = new Socket(server, port);
    //input from server| bytes to char
    InputStream is = s.getInputStream();
    //to allows us to use more function | dis.readDouble
    DataInputStream dis = new DataInputStream(is);
    //send output to server |char to bytes
    OutputStream os = s.getOutputStream();
    //to allow us to use more function
    DataOutputStream dos = new DataOutputStream(os);
    s.close();
    PLEASE HELP ME TO SEND THE VERTOR WITH THE PROPER METHODS OR FUNCTION...

    hi,how are you
    why not try to use ObjectInputStream and ObjectOutputStream,thus all will become simply
    for example:
    ObjectOutputStream writeSocket = new ObjectOutputStream(connectedSocket.getOutputStream());/* connectedSocket=socket connected */
    writeSocket.writeObject(Your Vector Object);

  • Dynamic return types? (public T extends E Vector T method(T param)

    Is it possible to have a method that returns Vector<MyType extends MyBaseType> dynamically? So that I could call the method using something like
    Vector<MyType> test1 = method(new MyType());
    as well as
    Vector<MyBaseType> test2 = method(new MyBaseType());
    For the first call, method would do something like
    Vector<MyType> retval = new Vector<MyType>();
    MyType c1 = new MyType();
    retval.add(c1);
    and for the second call
    Vector<MyBaseType> retval = new Vector<MyBaseType>();
    MyBaseType c1 = new MyBaseType();
    retval.add(c1);
    The best I've managed to come up with after going through various online sources (the most helpful being Gilad Bracha's generics tutorial) was
    public <T extends MyBaseType> Vector<T> test(T param)
    Class<T> entry2 = (Class<T>) param.getClass();
    Vector<T> retval = new Vector<T>();
    retval.add(entry2);
    return retval;
    But that doesn't even compile.
    I could also live having to specify an instance of Vector<T> (e.g. Vector<MyType>) as method parameter (but I'd still need to be able to instantiate objects of MyType in the method body and add those to the vector.

    >
    Hi there: in the future, please highlight your code and click the CODE button in the editor to format your code properly.
    You're close with your attempt. You can fix it by doing this:
       public <T extends MyBaseType> Vector<T> test(T param)
             throws IllegalAccessException, InstantiationException {
          Class<T> entry2 = (Class<T>) param.getClass();
          Vector<T> retval = new Vector<T>();
          retval.add(entry2.newInstance());
          return retval;
       }But you're better off, if possible, to do something like this:
       public <T extends MyBaseType> Vector<T> test(Class<T> type)
             throws IllegalAccessException, InstantiationException {
          Vector<T> retval = new Vector<T>();
          retval.add(type.newInstance());
          return retval;
       }This assumes you were just passing "param" to tell the method the type to use. If the parameter you're passing is what you actually want to add to the vector, it's really simple:
       public <T extends MyBaseType> Vector<T> test(T param) {
          Vector<T> retval = new Vector<T>();
          retval.add(param);
          return retval;
    Edit: Rereading your original post, it looks like yes, you need to create the instance in the method itself. So the second snippit is the one you want. Remember that this would require the type to have a visible, no-argument constructor.
    Edited by: endasil on 19-Oct-2009 11:16 AM

  • How to construct a standard rowKeyStr based on a value passed to a method ?

    Hi to all im on a proyect and i really appreciate some people can help with this
    looking ADF joins all use rowKey values and i need to know how to generate a standard rowKeyStr based on a value passed to an event, so it let me access any page on my Jsp ADF application and pass some values to a method and get the rowKeyStr.
    i have this method actually getting the current row, how i can generate a standard rowKeyStr value.
    public String myrowKeyStr(String id) {
    if (id != null) {
    PbeVisitasViewImpl vo = (PbeVisitasViewImpl)getPbeVisitasView1();
    Key k = new Key(new Object[]{id});
    Row[] found = vo.findByKey(k,1);
    vo.setCurrentRow(vo.findByKey(k,1)[0]);
    return someRowKeyStr;
    }

    once you do the
    Key k = new Key ( new Object[] { p1 } );
    The rowkeystring comes from:
    String strRowKeyStr = k.toStringFormat();
    Just type k. and press ctrl-space to see the list of methods.

  • Problem in passing vector from an applet to servlet

    Hi,
    I m facing problem in reading an object in the servlet (that i send from an applet). I have used BufferedInputStream ... The servlet reads the object but it takes about 30 seconds to do this ... If i don't use BufferedInputStream, it gives an "error reading inputstream header" ... if i use it, it take 30 seconds ... i m using netscape ent. server 4.0 ...
    Servlet code is as follows :
    try {
    InputStream in = req.getInputStream();
    inputFromApplet = new ObjectInputStream(new BufferedInputStream(in));
    saveVector = (Vector)inputFromApplet.readObject();
    I don't understand why it takes so long ... is there any other way ? Please help on this ... you may email me on [email protected]
    Thanks in advance..

    When you send a Vector through a stream, it must not only pass the Vector itself, but all the objects that the Vector refers to, all the objects that those objects refer to, and so on. Combine all this data with a slow internet connection, and passing what may seem like a small Vector could take minutes or hours.
    Are you sure you're passing a very small amount of data over a fast connection?

Maybe you are looking for

  • Getting file data and displaying it in a dynamic text box

    The purpose of this function is to load and display a specific menu for a restaurant (lunch, dinner, dessert, etc.) This script is located inside of a movie clip that has the text box and buttons. There are 4 buttons that have event listeners that go

  • Is there any way I can restore to leopard?

    I bought a macbook 3 years ago, updated to all the new software directly, everything went well, no crashes...until now. Installed Lion 2 days ago and today it just blocked all over... had to restart the whole computer! I went over to mac because of t

  • Email on the release of purchase order

    hi, the requirement is that, when the purchase order is released and saved in me28/me29n .then a email should be triggered to the concernd vendor . is there any standard procedure for this. As in NACE tcode,there is output type(NEU) for purchase orde

  • When Inbound deliveries split no quantity found to pack

    Hi, My client is using the DELVRY03 Idoc to create inbound deliveries for purchases from vendors. The materials being purchased are batch managed and HU managed. Currently the set up runs without issue provided that there is no delivery split when fo

  • SCOM 2012 System Center Operations Manager has stopped working when adding Web Console.

    I am trying to ad the Web console to one of my Management Servers but at the point where it asks what website to use it fails with the "System Center Operations Manager Setup has Stopped working error. This is the included information. Problem Event