Retrieve values from a table of a JSP page in Servlet.

Hello all,
I am new in JSP servlet world, I want to create a grid on JSP page using Servlet.
Suppose i have some records in a JSP page and This JSP page will display these records in a tabular form. And, on a button click that table data should be
accessible in servlet,
Now, How can i traverse among all the rows of that table of JSP page in servlet. or How can i retrieve a specific cell record of that table of JSP page in servlet.
Can anyone please answer this.
Thank you and regards.

Hi,
Create in your HTML form inputs with the same name i.e.:
<input name="a[]" value="2" >
<input name="a[]" value="9" >
In your jsp page use :
String Values[] = request.getParameterValues("a[]") ;
This will give you a string array of two elements.
for (int x = 0; x < Values.length; x++)
    System.out.println(Values[x]) ;
}Will print :
2
9
Hope this helps.
Bill Moo

Similar Messages

  • Retrieving values from a table

    Hi all,
    I need to retrieve values from CSKS-KOSTL for values containing the pattern entered by the user. For example, if the user enters 1, need to retrieve all the KOSTL values starting with 1. But when i write a SELECT statement mentioning where kostl in '1', it is ignoring all the values like (0000001, 00001034, 0012334, and others). Only values starting with 1 is only retrieved as this is a character field and due to conversion routine, zeroes are prefixed while storing in the database.
    Could any one let me know how to retrieve the values from the database in this situation?

    If you want to use IN operator in your where clause then you should define a range variable(R_KOSTL) which refers to CSKS=KOSTL and populate the range as below
    R_KOSTL-SIGN = 'I'.
    R_KOSTL-OPTION = 'CP'.
    R_KOSTL-LOW = '1*'.
    APPEND R_KOSTL.
    and then write your select statement as .... WHERE kostl IN r_kostl.
    The approach suggested by Amit should also work fine.
    Thanks
    Kiran

  • Can retrieve value from one table, but not the other (exception thrown)

    Hi
    I hope some friendly soul can help me out here. I have a local Access database file. I am able to get a value from all tables except for one, which throws this error: "System.NullReferenceException:
    Object reference has not been specified to an object".
    The rather simple lines of code when working is this:
    Dim email As Object
    value = MyDataSet.Tables("Table")(0)(1).ToString
    Msgbox(email)
    However, when simply changing from "Table" to "AnotherTable", the exception is thrown. I
    have seriously no idea why. I've made sure the datatypes are the same and that the values are not NULL.
    What gives?

    Hello,
    Going with your last reply, you should be accessing data via the strong typed classes that get generated.
    Example using Microsoft Northwind database accessing the customers table in a MS-Access database. Note the check for Rows, we could even go farther if we are questioning issue with the data via try-catch statements writing errors to the IDE Output window.
    I would highly recommend never referencing rows without first checking if there are rows and secondly never reference columns by ordinal index, always use the column name. One example with ordinal positioning, suppose someone did SomeDataTable.Columns("SomeColName").SetOrdinal(3)
    and you expect the ordinal position to be 1 ? things will crash-n-burn. Food for thought :-)
    Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Me.CustomersTableAdapter.Fill(Me.MainDataSet.Customers)
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    If MainDataSet.Customers.Rows IsNot Nothing Then
    Dim FirstCompanyName As String = MainDataSet.Customers.FirstOrDefault.CompanyName
    MessageBox.Show(FirstCompanyName)
    Else
    MessageBox.Show("No rows in customer table")
    End If
    End Sub
    End Class
    In this case we get the first record from below in Button1 Click
    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

  • Retrieving values from a table in ADF

    Hi All,
    Can any one give me the code or an example as how to retrieve the values associated with the table in jspx page.
    I am working in ADF10.1.3.
    Thanks,

    Hi,
    I am using ADF10.1
    I have a table with multi selection in my jspx page.
    I have to get the table particular row and using that need to get other values associated with the table.
    I have used the floowing code..but this is not functioning properly
    SelectedRowSet = this.getTable1().getSelectionState().getKeySet();
    rowSetIter = selectedRowSet.iterator();
    // Get the Selected Row Values from
    if (selectedRowSet.size() > 0)
    for (int counter = 0; counter < selectedRowSet.size(); counter++)
    int index = (Integer) rowSetIter.next();
    JUCtrlValueBindingRef currentRow =
    (JUCtrlValueBindingRef) getTable1().getRowData(index);
    Row row = currentRow.getRow();
    if (row!=null)
    variable name = ((String) row.getAttribute());
    Debugger is raising an exception at JUCtrlValueBindingRef line.
    Do share some ideas on it.
    Thanks,

  • ADF: Retrieve values from view and autofill in JSP

    Hi,
    I am using jdev 10.1.3 with ADF.
    I have a jsp page, on which I have 10 fields. On filling one particular field, the other related fields should be retreived from a Synonym or view (That I have in my database.) and automatically filled in jsp page.
    If I am not clear, I have a jsp page which has account number, bill to and ship to fields.
    There is a Synonym table which has the account number, billto and ship to fields. when I fill in the account number field in my jsp, then it should be validated against the synonym and retrive the bill to and ship to information for that particular account number and displayed automatically in the JSP.
    Can you give me any examples or URLs please?
    Thanks,
    Priya

    Hi
    I hope you can solve your problem with one of following solutions.
    1. Return the resultset to jsp program.
    In this getrow() method in Viewtable.java will look like this
    public void getrow() throws SQLException,IOException {
    System.out.println("see what happen" );
    String query = "SELECT PRODID,QUANTITY FROM INVENTORY";
    st = con.createStatement();
    rs = st.executeQuery(query);
    return rs;
    and your jsp program will be....
    <% ResultSet rs = view.getrow();
    while (rs.next()) {
    qty = rs.getString("QUANTITY");
    id = rs.getString("PRODID");
    System.out.println(qty + " " );
    %>
    2. If you just want to print the details then pass the "out"
    variable to getrow() method. ex:view.getrow(out)
    3. Otherwise store all your values in an array and return it.
    bye
    Sridhar

  • Retrieving lists from other layer into a JSP page - Design Question

    Hi all,
    What should be a good design technique in order to allow a JSP page to present some list obtained from other layer of my application. I intend to leave only presentation logic in the JSP layer, while all data access will be in other layer.
    For example, I have a JSP page that will show the results of a SQL query originated from an entry form in other JSP page. Let's name them 'search.jsp' and 'result.jsp'
    I want that all JDBC access be done in some other layer.
    Question 1:
    What would be better for this task? A servlet or a bean? (A bean, I suppose?)
    Then this bean (?) would have to find some way to pass all the result set into this 'result.jsp'. I think it would be very poor design if I used some Data Object, because it would have to store all rows and pass them at once.
    I don't want, either, that the presentation (JSP) layer access directly the data access layer (JDBC, files...). This way, I don't want any JSP page accessing the Resultset object directly.
    Question 2:
    What do you think could be a good design technique?
    I thought of some intermediate layer that provided data objects and data access interfaces. I mean, as my data will come from different sources, like some database (JDBC), some Electronic Document Manager, I thought of having a common access interface, that would provide methods for accessing the resultsets. This could be even a java.util.Enumeration that has a hasMoreElements() method that could be implemented as the next() method from JDBC result sets and the nextElement() method that would actually bring the next row of data.
    This way the JSP layer would see only hasMoreElements() and nextElement() methods from the middle layer. On the other hand, the data layer would provide as many different implementations to this access interface (Enumeration?) as there were data sources (JDBC, Files, ...)
    Question 3:
    What do you think of this design?
    Question 4:
    Is there any flaw in my approach? Which?
    Question 5:
    Could you suggest other designs?
    I really thank you all, for any kind of answer. I actually use this design for development, however I've never seriously discussed it with someone... this is going to be of great value for me.
    Regards,
    Filipe Fedalto

    Well I saw you question and I'll tell you what I do.
    I have JSP's which post form data to servlets.
    The servlet then calls a factory to produce a ResultContainer (analagous to your lists) which is generated
    via JDBC, and/or request parameters etc...
    this provides a single point of reference and a "group" of containers (functions really) that can be produced and reused (same container different amount of data)
    I also have other static classes which can manipulate the data in the containers
    (such as add additional info to the items in the containers) before I forward the container (request attribute)
    to the JSP page
    Additionally I use Type safe constants for all my HTML form tag names (easier to change and ensure the same name is used everywhere when reading parameters) and again for item statuses
    and any other info I need to send along with the page (using Javascript to update the
    status to another type safe constant).
    I've found that using factories for ResultContainers is very worthwhile and allows you to implement additional servlets extremely quickly (mostly reusing containers that exist) and since the
    container is the same for all my JSPs (this may not be the case with you) I can implement JSP's
    very quickly as well (just change the view)
    btw I refrain from calling my ResultContainer a bean because it is not serializable
    I don't know if this will help but at least it gives me a forum to test my ideas
    Thanks

  • Unable to retrieve values from a table

    I have created a table called ct_temp and it's structure is:
    create table ct_temp(id char(2),srs number(3),amt number);
    Result : Table Created
    I now insert the following rows into the table:
    id  srs  amt
    1 62 30000
    2 65 50000
    3 65 70000
    4 65 80000
    5 62 16000
    6 65 10000
    7 65 100000
    8 65 10
    Commit
    Then I issue the following query to retrieve data based on a specific criteria (Actually I have condensed the table and data because in Production, I have large number of rows; so for simplicity I am using 8 rows with one table)
    criteria : I then want to retrieve the following:
    for srs = 62, all values that is greater than 10,000
    Answer: select decode(srs,62,ab.amt)temp1 ,decode(srs,65,ab.amt)temp2 from ct_temp ab
    where decode(srs,62,ab.amt)>10000
    Works like a charm and retrives the results.
    Now comes the big issue
    I want to retrieve the values for srs = 62 which is greater than 10,000 and at the same time I also want to retrieve the values for srs = 65 which is less than srs = 62.
    Typically I wrote the query as:
    select decode(srs,62,ab.amt)temp1 ,decode(srs,65,ab.amt)temp2 from ct_temp ab
    where decode(srs,62,ab.amt)>10000
    and decode(srs,65,ab.amt)<decode(srs,62,ab.amt)
    Expected results should be:
    srs amt
    62 30000
    62 16000
    65 10
    I should atleast get one row for srs = 65 which is id # 8 but it displays blank rows or "no rows returned".
    I am actually preparing a ad-hoc report for the business analyst and stuck at this step due to which I am unable to proceed any further. I have used DECODE function because of the requirement specified by Business Analyst.
    I have tried the following in the office:
    using EXISTS operator = no luck
    using INLINE VIEW = no luck
    using UNION operator = No luck
    Is there any way around? Please help me guys.
    Sandeep
    NOTE: The reason why I have used DECODE function is because in Production environment there are columns called
    a) return line item which has numerous values like '001', '002', '062', '067'
    b) there is another column called amount
    c) so for every return line item there is an amount
    so the business wants:
    d) if the line item number = 62 then the amount should be dispplayed and it should be displayed as "AB Taxable income"
    e) if the linte item number = 65 then the amount should be retrived and displayed as "Amount taxable in AB"
    So seeing these multiple conditions for a "SELECT" statement, I used DECODE fuction.

    user11934091 wrote:
    What I have not been able to understand is why you have taken "0" there? Nulls! You need to use a number and not a null for a maths predicate.
    The following is ALWAYS false:
    and decode(srs,65,ab.amt) < decode(srs,62,ab.amt);
       is in fact: 
    and NULL < numberNull is not smaller than any number. Null is not larger than any number. Null is not equal to any number. Null is null. When it is not, that condition using Null is FALSE!!! Always.
    So look at your data. You are introducing 2 new derived values called TEMP1 and TEMP2 using decode(). So let's add these to derived values as columns to the table so that you can see how the data set now looks like:
    // add the 2 new columns
    SQL> alter table ct_temp add( temp1 number, temp2 number );
    Table altered.
    // populate these new columns using your decode statements
    SQL> update ct_temp
      2  set     temp1 = decode(srs,62,amt),
      3          temp2 = decode(srs,65,amt);
    8 rows updated.
    SQL> commit;
    Commit complete.This is how the data set now looks like:
    SQL> select * from ct_temp;
    ID        SRS        AMT      TEMP1      TEMP2
    1          62      30000      30000
    2          65      50000                 50000
    3          65      70000                 70000
    4          65      80000                 80000
    5          62      16000      16000
    6          65      10000                 10000
    7          65     100000                100000
    8          65         10                    10
    8 rows selected.Here are your 2 queries on this data set:
    // 1st query finds 2 rows
    SQL> select * from ct_temp where temp1 > 10000;
    ID        SRS        AMT      TEMP1      TEMP2
    1          62      30000      30000
    5          62      16000      16000
    // 2nd query finds the same 2 rows and then test
    // whether TEMP2 is smaller than TEMP1 - as TEMP2
    // is NULL for those 2 rows, this smaller than condition
    // is FALSE. Thus no rows are found.
    SQL> select
      2          temp1,
      3          temp2
      4  from       ct_temp ab
      5  where      temp1 > 10000
      6  and        temp2 < temp1;
    no rows selected
    // You thus need to change NULLs into a number - this is done
    // below using the NVL function. In my original example I did
    // this in the DECODE itself by returning 0 instead of NULL.
    SQL> select
      2          temp1,
      3          temp2
      4  from    ct_temp ab
      5  where   temp1 > 10000
      6  and     nvl(temp2,0) < nvl(temp1,0);
         TEMP1      TEMP2
         30000
         16000Bottom line. YOU CANNOT EVALUATE NULLS USING MATHEMATICAL PREDICATES.
    So - change the NULL to a number and the do the evaluation. Or determine what the business rule is for when there is no value to evaluate in the predicate and apply that rule.
    That simple.

  • How to get value from a checkbox in a jsp page?

    hi there
    i have a form in a jsp which contains a <input type='checkbox' name='xx'>
    when i submit the form, how can i get the value for this checkbox? i could use request object to get parameter. i tried the following and could not get any value:
    request.getParameter("xx");
    is there any to get it? thanks.

    "checkbox" can have multiple values b/c you can check more than 1 checkbox and they can have same name.
    Example
    <input type="checkbox" name="number" value="1">one
    <input type="checkbox" name="number" value="2">two
    <input type="checkbox" name="number" value="3">three
    To get values of "number" field:
    String [] numberValues = request.getParameterValues("number");
    where numberValues[0] is the 1st value checked, numberValues[1] is 2nd value checkted and so on.....
    If you have no checkbox checked then you might get a "null pointer exception", so make sure you check to see if it's null first before accessing your numberValues array.
    If you just have 1 checkbox; then you can just call request.getParameterValue("number") and that will return your value.

  • Retrieve values from a HTML table !!!

    Hi.
    How can i retrieve values from a HTML table using javascript ?
    I´m trying to use the command "document.getElementsByTagName" without success.
    Thanks in advance.
    Eduardo

    Hi, Deepu.
    I´m still with trouble in retrieving the value in HTML.
    In debug the C_CELL_ID seems to be correctly updated but
    when using the command "document.getElementById" the value is always "null".
    I implemented in the method DATA_CELL the code :
      if i_x = 3 and i_y = 2.
      C_CELL_ID             = 'zs'.
      C_CELL_CONTENT = 10. 
      endif.
    And in HTML :
    var ztest = document.getElementById('zs');
    alert(ztest);
    Could you help me please.
    Many regards
    Eduardo S.
    Message was edited by: Eduardo   Silberberg

  • Retrieving values from table control using DYNP_VALUES_READ

    Hi all,
    I am trying to retrieve the values from the table control using the FM DYNP_VALUES_READ. I have a situation where user enter values in table control in T.code FB60 in Withholding tab for validation purpose. There i'll have to check based on some entries maintained in SET.
    I am unable to get the values when i scroll to the next page in the table control. FM raising an exception invalid_dynprofield.
    Expecting reply...

    You have to populate the dynpfields internal table before calling the function,
    data: repid like sy-repid.
    dynpfields-fieldname = 'PNAME'.
    append dynpfields.
    repid = sy-repid.
    call function 'DYNP_VALUES_READ'
    exporting
    dyname = repid
    dynumb = sy-dynnr
    tables
    dynpfields = dynpfields
    exceptions
    others.
    read table dynpfields index 1.
    pname = dynpfields-fieldvalue.
    Now you will have the field value in pname
    Hope this helps
    Vinodh Balakrishnan

  • How to retrieve 2 values from a table in a LOV

    Hi
    I'm pretty new to APEX. I try to retrieve two values from a table using a LOV. I have a table named DEBIT with then columns SITE, NAME and KEY
    I want to display NAME to the user in a list. When the user select an item from the list, I want to retrieve the data of the SITE and KEY column of this item in order to launch an SQL command based on this two values.
    How to retrieve thes two values whant the user chooses an item from the list ?
    I apologize for my english, being french.
    Regards.
    Christian

    Christian,
    From what I understood about your requirement, you want a 'select list with submit' which displays "NAME" and based on the value selected, you want to get the corresponding values for "SITE" and "KEY" from the table.
    <b>Step 1: Create a select list with submit, say P1_MYSELECT </b><br><br>
    Use something like this in the dynamic list of values for the select list: <br>
    SELECT NAME display_value, NAME return_value
    FROM DEBIT<br><br>
    <b>Step 2: Create a page process of type PL/SQL block. Also create 2 hidden items P1_KEY and P1_SITE. </b><br><br>
    In the PL/sQL, write something like:
    DECLARE
      v_key DEBIT.KEY%TYPE;
      v_site DEBIT.SITE%TYPE;
      CURSOR v_cur_myvals IS
              SELECT KEY, SITE
              FROM DEBIT
              WHERE NAME = :P1_MYSELECT;
    BEGIN
      OPEN v_cur_myvals;
      LOOP
              FETCH v_cur_myvals
              INTO  v_key,v_site;
              EXIT WHEN v_cur_myvals%NOTFOUND;
    :P1_KEY := v_key;   
    :P1_SITE := v_site; 
      END LOOP;
      CLOSE v_cur_myvals;
    END; <br><br>
    Then you can use these values for whatever purpose you need to.
    Hope this helps.

  • How to get values from a table(in jsp) for validation using javascript.

    hi,
    this is praveen,pls tell me the procedure to get values from a table(in jsp) for validation using javascript.
    thank you in advance.

    Yes i did try the same ..
    BEGIN
    select PROD_tYPE into :P185_OFF_CITY from
    magcrm_setup where atype = 'CITY' ;
    :p185_OFF_CITY := 'XXX';
    insert into mtest values ('inside foolter');
    END;
    When i checked the mtest table it shos me the row inserted...
    inside foolter .. Now this means everything did get execute properly
    But still the vallue of off_city is null or emtpy...
    i check the filed and still its empty..
    while mtest had those records..seems like some process is cleaining the values...but cant see such process...
    a bit confused..here..I tried on Load after footer...
    tried chaning the squence number of process ..but still it doesnt help
    some how the session variables gets changed...and it is changed to empty
    Edited by: pauljohny on Jan 3, 2012 2:01 AM
    Edited by: pauljohny on Jan 3, 2012 2:03 AM

  • How to retrieve the values from a table if they differ in Unit of Measure

    How to retrieve the values from a table if they differ in Unit of Measure?

    If no data is read
    - Insure that you use internal code in SELECT statement, check via SE16 desactivating conversion exit on table T006A. ([ref|http://help.sap.com/saphelp_nw70/helpdata/en/2a/fa0122493111d182b70000e829fbfe/frameset.htm])
    If no quanity in result internal table
    - There is no adqntp field in the internal table, so no quantity is copied in itab ([ref|http://help.sap.com /abapdocu_70/en/ABAPINTO_CLAUSE.htm#&ABAP_ALTERNATIVE_1@1@]).
    - - Remove the CORRESPONDING, so quantity will fill the first field adqntp1.  ([ref|http://help.sap.com/abapdocu_70/en/ABENOPEN_SQL_WA.htm])
    - - Then loop at the internal table and move the quantity when necessary to the 2 other fields.
    * Fill the internal table
    SELECT msehi adqntp
      INTO TABLE internal table
      FROM lipso2
      WHERE vbeln = wrk_doc1
        AND msehi IN ('KL','K15','MT').
    * If required move the read quantity in the appropriate column.
    LOOP AT internal_table ASSIGNING <fs>.
      CASE <fs>-msehi.
        WHEN 'K15'.
          <fs>-adqnt2 = <fs>-adqnt1.
          CLEAR <fs>-adqnt1.
        WHEN 'MT'.
          <fs>-adqnt3 = <fs>-adqnt1.
          CLEAR <fs>-adqnt1.
      ENDCASE.
    ENDLOOP.
    - You could also create another table with only fields msehi and adqntp and then collect ([ref|http://help.sap.com/abapdocu_70/en/ABAPCOLLECT.htm]) the data to another table.
    Regards,
    Raymond

  • Retrieve data from oracle table, table name passed in runtime into JSP

    Hello All,
    I am new to JSP, i have a requirement,
    I need to retrieve data from oracle table, here table is passed at random. how to get the data displayed in JSP page.
    can any one help me in that
    thanks

    1) Learn SQL.
    2) Learn Java.
    3) Learn JDBC.
    4) Learn DAO.
    5) Learn HTTP.
    6) Learn HTML.
    7) Learn JSP/Servlet.
    8) Learn JSTL.
    9) Apply learned things and develop.
    Whenever you stucks, please come back and post the specific coding/technical problem here.

  • How to get input text values from adf table - Urgent

    Hi Friends,
    This is my requirement. I designed customized master - detail - detail page. I customized the page in below format.
    1. Master Data Field (Input text,etc) .
    2. Detail in table format ( Rows are mapped to child table) and i given two buttons for to create row and delete row. I designed the table based on the example provided in forum for to create customized table. The input text component is mapped to the rows.
    Now i want to retrieve all the data's entered in the rows. The table is mapped to child table. When i read the values from the table its showing null.
    If any one faced this problem and fixed it, please send me the solution.
    Thanks & Regards
    VB

    Did you look into the valueChangeEvent?
    It has oldValue and newValue attributes.
    public void SaveMaterial(ValueChangeEvent valueChangeEvent) {
    Object oldVal = valueChangeEvent.getOldValue();
    Object newVal = valueChangeEvent.getNewValue();
    // check if you see what you are looking for.....
    getSelectedRow();
    SaveMaterial(material);
    }Timo

Maybe you are looking for