Access table fields - JSP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • EvrimAgha
    New Member
    • Aug 2007
    • 11

    #1

    Access table fields - JSP

    Hi

    I have a JSP that builds a table and shows the values in fields according to what has been passed to it through a request.setAttr ibute of a servlet.

    For example the two dimensional array "test" has this data:

    Col1 Col2 Col3
    Row1 a b c
    Row2 d e f



    and JSP will read this from request variable and display it.

    These values (a,d) are displayed as hyper links to a page testpage.jsp.

    What I need to do is, when user clicks a , I need to set b and c in a variable array and pass it to the next page , or when user clicks d I need to pass e and f to next page.

    1. Could you please tell me how to do that ?

    2. Do I need Javascript ? or it can be done in Java? I prefer to have all the code in Java.

    3. How is it possible to access and change a request variable from JavaScript ?


    Appreciate your help in advance
    Evrim
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by EvrimAgha
    Hi

    I have a JSP that builds a table and shows the values in fields according to what has been passed to it through a request.setAttr ibute of a servlet.

    For example the two dimensional array "test" has this data:

    Col1 Col2 Col3
    Row1 a b c
    Row2 d e f



    and JSP will read this from request variable and display it.

    These values (a,d) are displayed as hyper links to a page testpage.jsp.

    What I need to do is, when user clicks a , I need to set b and c in a variable array and pass it to the next page , or when user clicks d I need to pass e and f to next page.

    1. Could you please tell me how to do that ?

    2. Do I need Javascript ? or it can be done in Java? I prefer to have all the code in Java.

    3. How is it possible to access and change a request variable from JavaScript ?


    Appreciate your help in advance
    Evrim
    Clicking a link is a Javascript event not a Java event so you handle that event with Javascript. The form fields in one page become the request parameters in the next page.

    Comment

    • EvrimAgha
      New Member
      • Aug 2007
      • 11

      #3
      Originally posted by r035198x
      Clicking a link is a Javascript event not a Java event so you handle that event with Javascript. The form fields in one page become the request parameters in the next page.

      Thanks for your answer .....

      Would it be possible to provide an example about how to construct these parameters (since they are fields in a table , not text boxes and such).

      Comment

      • madhoriya22
        Contributor
        • Jul 2007
        • 251

        #4
        Originally posted by EvrimAgha
        Hi

        I have a JSP that builds a table and shows the values in fields according to what has been passed to it through a request.setAttr ibute of a servlet.

        For example the two dimensional array "test" has this data:

        Col1 Col2 Col3
        Row1 a b c
        Row2 d e f



        and JSP will read this from request variable and display it.

        These values (a,d) are displayed as hyper links to a page testpage.jsp.

        What I need to do is, when user clicks a , I need to set b and c in a variable array and pass it to the next page , or when user clicks d I need to pass e and f to next page.

        1. Could you please tell me how to do that ?

        2. Do I need Javascript ? or it can be done in Java? I prefer to have all the code in Java.

        3. How is it possible to access and change a request variable from JavaScript ?


        Appreciate your help in advance
        Evrim
        Hi,
        Try to do it this way:-
        1. Set a parameter in ur url, like
        Code:
         
        href = [url="http://ur/url?RowId = someValue"]http://ur/url?RowId = someValue[/url](this valued should be unique so that later u can identify the row through it)
        2. In the next page get this RowId using getParameter
        Code:
         
        String str = request.getParameter("RowId");
        3. Based upon this RowId fetch the data from ur getAttribute List.

        thanks and regards,
        madhoriya

        Comment

        Working...