How to use request.setAttribute in javascript function.

Here is my scenario.
I am storing all open windows handles in the array( javascript ).
I want to send this array to the servlet for which I need to do
request.setAttribute("jsArray", windowArray);
I am getting all kinds of errors while writing above statement in the javascript function.
Here is my code:
function save_javascript_array(){
<% request.setAttribute("jsArray", %> + winArray + <% ); %>
document.forms[0].action="/NASApp/inv/AuditServlet";
document.forms[0].submit();
Thanks in advance.

try something like this:
crate a JavaScript function that set a form parameter with the values contained in the array, for example make a string containing all elements of the array separated by colon (,):
function save_javascript_array()
var data;
data = '';
for( var i=0;i<winArray.length;i++ )
data = data + winArray[i] + ',';
document.forms[0].handles.value = data;
document.forms[0].action="/NASApp/inv/AuditServlet";
document.forms[0].submit();
you must have a form like this:
<form ...>
<input type="hidden" name="handles">
</form>
Now in the servlet you must retirve the parameter called "handles" and iterate over the string:
StringTokenizer tok = new StringTokenizer( request.getParameter("handles"),"," );
while( tok.hasMoreElements() )
String handle = tok.nextToken( );
// do something with this handle...
The code above may be different (I don't remember the names of the methods os StringTokenizer) and I don't known much about JavaScript (e.i. how to iterate over a array and how to concatenate each element in the array)
JaimeS

Similar Messages

  • How to use database look up table function in xsl mapping

    Can anybody tell me how to use database look up table function while mapping xsl between 2 nodes.
    I have an XML file coming in and depending on one of XML elements we need to decide which further path to take. But, using this XML element, we need to query database table, get metadata and accordingly take appropriate path. I have written lookup function which returns metadata value.
    Now, the issue is how do I pass the XML element valu as input to look up function? When I tried to drag it to the input node of lookup function, it throws an error like "Maximum number of parameters exceeded"
    Thanks,

    If the lookup table is always going to remain the same (e.g. a character generator or something similar) you can place the values in a 2D array constant on your diagram, with the input value as one column, the equivalent as the other. When you need to perform the lookup you use an index array to return all the values in the "input column", search it using "search 1D array" and use the resulting index number to index the other column's data. If the values may change, then it would probably be best to load an array control with your equivalent values from a file.
    P.M.
    Putnam
    Certified LabVIEW Developer
    Senior Test Engineer
    Currently using LV 6.1-LabVIEW 2012, RT8.5
    LabVIEW Champion

  • Need an example how to use SCAN_Start with a callback function

    I would appreciate if someone helps me with a working example of how to use SCAN_Start with a callback function. I need just a basic functionality: to specify a channel list (with gains probably), to start a data acquisition task and to receive data buffers utilizing a callback function. t this time whatever I was trying to do caused computer hangups, though it is supposed to be one of the most regular tasks to perform.
    Thank you in advance,
    Mike

    Hello Mike,
    Thank you for contacting National Instruments.
    Attached is an example project which uses a callback function to begin analog acquisition (AI) by calling SCAN_Start. This project acquires from the first 2 channels on your DAQ device. Make sure to modify the device number in the code to match the number of your card.
    Let me know if you have any further questions...
    Sincerely,
    Sean C.
    Applcications Engineer
    National Instruments
    Attachments:
    Acquire_multichannel_61xx.zip ‏11 KB

  • How to get value stored in  javascript function and display in a JSP

    i am doing a questionaire which is for user to input data in every question, After user input the data, a javascript function will be called to do some score calculation. Since each question will carry its final score after the calculation by the javascript function, so i use an array to store those scores and then display those scores in the same page.
    However, i have to make a confirmation page to display both data and calculated score in another jsp, i only know how to display the data as it is a textfield that i can get the value by "request.getParameter("textfield1"); but i dun know how to get those scores as they are stored in an array in the javascript function, what way i can do??

    thank you for all your help!
    I have chosen to set the score value to the hidden field when every time run the function
    <script language="javascript">
    function cal(index){
    var thisForm = document.MC;
    thisForm.score1.value=score[index];//set value to the hidden field     
    </script>
    <input type="hidden" name="score1" value="">
    <input type="hidden" name="score2" value="">
    <input type="hidden" name="score3" value="">
    The function will calculate only one score when every time being called. So that i can only assign one score to one hidden value at a time.
    e.g, assign score[1] to thisForm.score1.value
    assign score[2] to thisForm.score2.value
    assign score[3] to thisForm.score3.value
    how can i do this??

  • How can I call a custom javascript function when clicking on cfgrid cell.

    I would like to call a custom javascript function when
    clicking on a cell in an cfgrid (of html format). The closest thing
    I can find is to use the HREF="" attribute, but it doesn't seem to
    work with javascript inside it.
    Simple example:
    <cfgridcolumn name="Foo" header="Foo"
    href="javascript:customFunction(#ID#);">
    Do I need to tap into the underlying Ext JS funtionality? If
    so, where can I start?
    Thanks!

    Hi,
    According to your post, my understanding is that you want to hide/show list columns based on specify the permission for Users, SharePoint Groups or Active Directory Groups.
    Here is a solution from CodePlex for your reference:
    SharePoint 2013 Column & View Permission
    https://sp2013columnpermission.codeplex.com/
    Best Regards
    Dennis Guo
    TechNet Community Support

  • How to use a mysql built-in function with dataprovider

    hi.
    I want to use a mysql built-in function, for example, MD5() on a column when updating a table with dataprovider.
    Something like this doesn't work:
    MyDataProviderOne.setValue("tablename.field_name", "MD5('some text')");
    How should it be done?
    thanks.
    Mike.

    hi.
    thanks. this helped, but I'd like to use also different functions, that's why, I'd rather do it by MySQL built-in functions with dataprovider... Is there any way to do that?
    best regards.
    Mike.

  • How to use parameters in smartform genrated  function module

    i executed smartform one functional module is genrated  '/1BCDWB/SF00000002'
    now the problem is that  i want to send  output of this smartform through email
    now how to use ' MAIL_RECIPIENT   '      and  ' MAIL_SENDER   ' to send smartform output through email .
    please check following module which generated by smartform.
    plz suggest me  .
    CALL FUNCTION '/1BCDWB/SF00000002'
    EXPORTING
      ARCHIVE_INDEX              =
      ARCHIVE_INDEX_TAB          =
      ARCHIVE_PARAMETERS         =
      CONTROL_PARAMETERS         =
      MAIL_APPL_OBJ              =
      MAIL_RECIPIENT             =
      MAIL_SENDER                =
      OUTPUT_OPTIONS             =
      USER_SETTINGS              = 'X'
    IMPORTING
      DOCUMENT_OUTPUT_INFO       =
      JOB_OUTPUT_INFO            =
      JOB_OUTPUT_OPTIONS         =
      TABLES
        ITAB_PA0001                =   ITAB_PA0001
    EXCEPTIONS
      FORMATTING_ERROR           = 1
      INTERNAL_ERROR             = 2
      SEND_ERROR                 = 3
      USER_CANCELED              = 4
      OTHERS                     = 5
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    Hi
    You can do it while passing these parameters in the CONTROL_PARAMETERS.
    data: ls_CONTROL_PARAMETERS type SSFCTRLOP.
    ls_CONTROL_PARAMETERS-DEVICE  = 'LOCL'.
    ls_CONTROL_PARAMETERS-NO_DIALOG = 'X'.
    ls_CONTROL_PARAMETERS-PREVIEW = ' '.
    Pass this ls_CONTROL_PARAMETERS to the importing parameter of the FM .
         CALL FUNCTION LF_FM_NAME
               EXPORTING
                          CONTROL_PARAMETERS   = LS_CONTROL_PARAM
    In addition to this, you might also want to set the print immediately field on the same structure to 'X'.
    Generally you leave the device field empty, the user master record default printer will be used

  • How to use session variable in JSP function  & How to use both JSP  Servlet

    Hi,
    I am new to JSP and servlets
    Still I am devloping a website in JSP. I am not mixing JSP with servlets, but I do create Java files for bean, logic and database works.
    I try to keep the hard coding part out of JSP.
    I dont how to use both JSP and Servlets in combination.
    Hence If needed I write some functions in JSP.
    but it gives me error
    +<%! public void abc()+
    +{+
    int intUserId = Integer.valueOf((Integer) session.getAttribute("MySession_UserID"));
    +}+
    +%>+
    Saying cannot find symbol session
    1) So can u please tell how can I access session variables within JSP function
    2) And also give me some links/tutorials about useing both JSP and Servlets in combination.
    Thanks
    Venkat

    The application architecture when you use Servlets and JSP in a standard MVC pattern is explained here (under the heading "Integrating Servlets and JSP Pages") and here ...

  • How to use 'REQUEST' value on PL/SQL

    Hi All,
    I have assigned 'SEARCH' as button request to search button. I want to use this value in PL/SQL some thing like
    IF REQUEST='SEARCH' THEN
    --do something
    ELSE
    --do something else
    END IF;
    Can any one suggest how to access the 'REQUEST' value?
    Thanks in advance.
    Regards,
    Hari

    Hi rchalton!
    Sorry for that. Here is an english document which also shows an example of how to use v('REQUEST') or :REQUEST.
    [http://download.oracle.com/docs/cd/E14373_01/appdev.32/e11838/concept.htm]
    regards
    Edited by: Florian W. on 06.04.2009 15:35
    I've also tried to translate this link from german into english with google and it worked very good.

  • How to pass jsp array to javascript function()

    function delete(var arr[][])
    out.print(arr[1][2]);
    <%String [][] arra=new String[1][2];
    %>
    <select name="" onClick="delete(<%=arra%>)">
    <option>fvfvfdfdfddffdd</option>
    </select>

    Thanks again for constant support .Now , here comes my real problem .
    I'm having a listbox . I need to find out how to get the values selected in a JSP variable .
    Like I'm having names of cities in listbox .When , I click on save button , i need the names of selected cities in JSP variable or an array .
    <html>
    <head>
    <script language="JavaScript">
         function show(acl)
              for(var i=0;i<4;i++)
                   if(acl.aclnames.options.selected)
                        // i don't know what to put here
              alert("in show");
    </script>
    </head>
    <body>
    <form name="acl" method="post">
    <select name="aclnames" multiple="true" size="3">
    <option>Ahmedabad</option>
    <option>Baroda</option>
    <option>Surat</option>
    <option>Rajkot</option>
    </select>
    <input type="button" name="save" value="Save" onClick="show(acl)">
    </form>
    </body>
    </html>

  • Use netui tags within javascript function

    Is there anyway to use netui tags within a javascript function? I am trying to create a onChange event handler for a netui:select tag that will call a javascript function which will execute a few netui callMethod tags. The problem is that if the netui tags are embedded within a javascript function they are not translated into javascript. Is there some kind of function that I can wrap the embedded netui tags with so that they will be translated into javascript at runtime? Thanks.

    Hi,
    I am trying to embed JSP code within javascript
    t function, so that it can be called when the user
    leaves the page. No,you can't.
    JSP files are complied on server side while the javascript is the clint side code.
    if you really want to call the functio when the user leaves the page, you can call a function runs on the server side to set the session.
    regards

  • How to use a Logical Database in Function Module.

    Hi Experts,
    I want to use a logical database in a Function Module to fetch data from a standard SAP table into a Internal table for certain filter conditions.
    How can I get get this done????
    I called LDB_PROCESS FM in my FM, but I could not figure out how to store the extract in my IT table since we cant use GET in FM.
    Please provide me a sample code if possible.
    Thanks in Advance,
    Alex.

    Hi,
    i had an example program like this ,in this i want to get the data using pnp logical database with 5 fields in an interface program.
    data: begin of it_final occurs 0,
            pernr like pa0002-pernr,
            vorna like pa0002-vorna,
            nachn like pa0002-nachn,
           usrid like pa0105-usrid,
           usrid_long like pa0105-usrid_long,
           end of it_final.
    get pernr.
      clear : p0000,p0002,p0105.
      rp-provide-from-last p0000 space p_date p_date.
      if p0000-stat2 = '3'.
        v_pernr = pnppernr-low.
      else.
        reject.
      endif.
    *---Get employee pernr, First name ,Last name into final table
      rp-provide-from-last p0002 space p_date p_date.
      if pnp-sw-found = '1'.
       it_final-pernr = p0002-pernr.
       it_final-vorna = p0002-vorna.
       it_final-nachn = p0002-nachn.
      else.
    *---Error message if not infotype 0002 maintained
      T_ERROR-PERNR   = pnppernr-low.
      CONCATENATE TEXT-EMI '0002'
      INTO T_ERROR-MESSAGE SEPARATED BY SPACE.
      APPEND T_ERROR.
      CLEAR T_ERROR.
      endif.
    **--Get SYSTEM USERNAME to final table
      rp-provide-from-last p0105 0001 p_date p_date.
      if pnp-sw-found = '1'.
        it_final-usrid = p0105-usrid.
      else.
    *---Error message if not SYSTEM USERNAME maintained
        T_ERROR-PERNR   = pnppernr-low.
        CONCATENATE TEXT-003 '0105'
        INTO T_ERROR-MESSAGE SEPARATED BY SPACE.
        APPEND T_ERROR.
        CLEAR T_ERROR.
      endif.
    **--Get Email ID to final table
      rp-provide-from-last p0105 0010 p_date p_date.
      if pnp-sw-found = '1'.
        it_final-usrid_long = p0105-usrid_long.
      else.
    *---Error message if not Email ID maintained
        T_ERROR-PERNR   = pnppernr-low.
        CONCATENATE TEXT-004 '0105'
        INTO T_ERROR-MESSAGE SEPARATED BY SPACE.
        APPEND T_ERROR.
        CLEAR T_ERROR.
      endif.
       append it_final.
        clear it_final.
    reward points if useful,
    venkat.

  • How to use multiple models in one Function module?

    Hi,
    In my FM i am using 2 models and if i dont completely exit the Function and use the same fm for another query based on another
    model it is giving error saying invalid type.
    if iv_type_of_search = 'A'.
    start the application BT
        lv_bol_core = cl_crm_bol_core=>get_instance( ).
        lv_bol_core->start_up( 'BP_APPL' ).
    get an instance of dynamic opporunity query
        lr_query = cl_crm_bol_dquery_service=>get_instance( 'BuilHeaderAdvancedSearch' ).
    Contact Search
      elseif iv_type_of_search = 'C'.
    start the application BT
        lv_bol_core = cl_crm_bol_core=>get_instance( ).
        lv_bol_core->start_up( 'BP_APPL' ).
    get an instance of dynamic opporunity query
        lr_query = cl_crm_bol_dquery_service=>get_instance( 'BuilContactAdvancedSearch' ).
    *Opportunity Search
      elseif iv_type_of_search = 'O'.
    start the application BT
        lv_bol_core = cl_crm_bol_core=>get_instance( ).
        lv_bol_core->start_up( 'BT' ).
    get an instance of dynamic opporunity query
        lr_query = cl_crm_bol_dquery_service=>get_instance( 'BTQOpp' ).
      endif.
    Any idea how to over come this or remove the instance of the old query and model every time its run?
    it looks like the object of the last run is still there and i cant find any destructor method or way and
    if i exit se37 it works fine....

    Hi George,
    You can also set up your model (component set) with the components you need.
    Check it on:
    SPRO->CRM->CRM Cross-Application Components->Generic Interaction Layer/Object Layer->Basic Settings
    Kind regards,
    Garcia

  • How to use quarter format in "to_date()" function?

    Hi,
    I'm trying to use to_date() function with quarter format. How do I specify the format?
    For example to convert '2002 quarter 1' using the to_date function.
    I tried to_date('20021', 'YYYYQ'), and I got ORA-01820 cannot appear in date input format.
    Please help, thank you!!!

    You cannot use Q when inputting data, only when retrieving data. When inputting, you must enter a valid date. Oracle has to store a date and if you just enter a quarter, it can't figure out what date to store. See the examples below:
    SQL> -- test table:
    SQL> CREATE TABLE test_table
      2    (test_date DATE)
      3  /
    Table created.
    SQL> -- the wrong way to input:
    SQL> INSERT INTO test_table (test_date)
      2  VALUES (TO_DATE ('2002-1', 'YYYY-Q'))
      3  /
    VALUES (TO_DATE ('2002-1', 'YYYY-Q'))
    ERROR at line 2:
    ORA-01820: format code cannot appear in date input format
    SQL> -- the right way to input:
    SQL> INSERT INTO test_table (test_date)
      2  VALUES (TO_DATE ('27-OCT-2002', 'DD-MON-YYYY'))
      3  /
    1 row created.
    SQL> -- to output:
    SQL> COLUMN "Year and Quarter" FORMAT A16
    SQL> SELECT test_date,
      2         TO_CHAR (test_date, 'YYYY-Q') AS "Year and Quarter"
      3  FROM   test_table
      4  /
    TEST_DATE   Year and Quarter
    27-OCT-2002 2002-4
    1 row selected.

  • How to use "WHOSE" concept in Javascript

    Hi Scripters,
    I have one question about the difference in between Applescript & Javascript?
    My question is about this "WHOSE" concept in Javascript when compared as of to Applescript usage which made it very simple.
    The below mentioned Applescript code will select the entire page items in page 1 of document 1 whoever omiting those items whose geometric bounds are less than 0.
    tell application "Adobe InDesign CS4"
         set selection to (every page item of page 1 of document 1 whose (item 1 of geometric bounds is not less than 0))
    end tell
    Here in this above mentioned code I have used "WHOSE" concept to omit some specific page items, however using javascript it is not possible to use this WHOSE concept to simply the Javscript code.
    thanks

    Unfortunately lack of a nice filtering syntax is indeed one of the many flaws of the JavaScript language.
    Generally speaking we just write this in an ugly way with a for loop:
    var i, p, page=app.document[0].pages[0], s=[];
    for (i=0; i<page.pageitems.length; i++) {
      p = page.pageitems[i];
      if (!(p.geometricBounds[1] < 0)) {
        s.push(p);
    app.select(s);
    Some people like to use Marc Autret's whose and findItems functions though: see http://forums.adobe.com/message/3070983#3070983.

Maybe you are looking for