How to pass a javascript variable to a javabean method

Hi
I need to pass a String from a Javascript argument to a javabean method. localUrl will be instantiated with a string not from any form item(option box, textbox, etc) so cannot use
String param = request.getParameter("XXX").
My code below does not work as localUrl is not seen by javaBean and returns a null.
function ShowWaitDisplay(localUrl)
var Description = <%=RandomFeeds.getDescription(localUrl)%>;
//Do something with the string Description
Thanks
Andrew

Since, java bean code will be executed on the server side and java script executes on client side, by the time your javascript variable created, the bean code is already been executed.

Similar Messages

  • How to pass a JavaScript variable into a java method

    I would like to know how to pass a JavaScript variable into a java method with in a <% %> tag inside a JSP file like so:
    <%@ page contentType="text/html;charset=windows-1252"%>
    <html>
    <head>
    <script LANGUAGE="JavaScript">
    myValue = someDynamicValue;
    <% System.out.println(myValue)%>
    </script>
    </head>
    <body>
    </body>
    </html>
    obviously "System.out.println(myValue)" will not work because myValue is seen as a java variable and not a JavaScript variable.
    I would like to know how to let the jsp file, that I wrote in the above code, see myValue as a JavaScript variable and not a java variable so that I can pass it to a java method.
    NOTE: the java method does not have to be a println() method, it can be any method of my choice.
    NOTE: someDynamicValue is a JavaScript value that can dynamically change

    I don't believe you can. JSPs are really just elaborate templates that an engine such as Tomcat parses and generates an HTML page based on. That page is then displayed to the user. By the time you want to use some function in Javascript, the JSP has already been parsed and generated.
    Basically, Javascript and JSPs can't talk to each other. One's server-side and the other is client-side.

  • How to pass a javascript variable to a query in BEx?

    Hi All,
    We're using BEx SAP BW 3.x
    I'm using portal eventing to pass a variable to a BW template.  While I can pick up this value using javascript, I do not know how to pass it to the query.
    Let me just say, I am new to BEx, so any guidance you could give me would be most welcome.
    Thanks in advance,
    Liz.

    Hi,
    Perhaps this JavaScript can help?
    document.appletName.getQueryObject().setParam(1, param value);
    Call this peice of code on some event, for example the click event of a Button.
    There are many more examples on this forum, search for more.
    Regards,
    Michael

  • How to pass the javascript variable value to a jsp

    Hi
    I am trying to set a javascript variable with onClick event of a radio button in jsp
    and I am assigning this variable to a hidden property in JSP whic has the corresponding getter an setter method in form.
    But I am not able to retrtieve the value assigned in either form/action .can any body help me in this:
    The code is
    <script language="javascript">
    var jais="";
         function setValue(val)
              jais=val;
         document.o.value=jais;
    </script>
         <html:hidden property="o" value=""/>
    <input type=radio name="1"
                                            value="xyz"
                                                                          onclick="setValue('XYZ')" >
                                            ABC                                        
    and in the correspoding form bean I have
    private String o_val =null;
    public String geto()
    return o_val;
    public void seto(String strs)
    o_val=strs;
    In the action I am trying to access
    by
    1)String j=((form name)form.geto();
    2)String j=request.getParameter("o")
    but with both of them I am getting the value null
    Thanks in Advance

    You need to set the value of the hidden field in your function.
    Setting an unrelated variable will not help.
    function setValue(val)
    document.forms[0].o.value = val;
    also your get/set methods should be getO() and setO().

  • How to pass a jsp variable into javascript??

    <p><%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
    <p><%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
    <p><html>
    <p><c:set var="binrmapi" value="http://localhost/paas-api/bingorooms.action;jsessionid=XXXXXX?userId=TEST2&sessionId=1&key=1" />
    <p><c:import var="testbinrm" url="${fn:replace(binrmapi, 'XXXXXX', jsessionid)}"/>
    <p><c:set var="tuples" value="${fn:split(testbinrm, '><')}" />
    <p>Time until next game
    <p><c:forEach var="tuple" items="${tuples}">
    <p><c:if test="${fn:contains(tuple, 'row ')}">
    <p> <p><code>
    <p> <c:set var="values" value="${fn:split(tuple, '=\"')}" />
    <p> <font color="blue">
    <p> <c:out value="${values[17]}" />
    <p><c:set var="remainingtime" value="${values[17]}" />
    <p> </font>
    <p> </code>
    <p></c:if>
    <p></c:forEach>
    <p><form name="counter"><input type="text" size="8" name="d2"></form>
    <p><script>
    <p>var milisec=0
    <p>var seconds=eval("document.myForm.remaining").value;
    <p>function display(){
    <p> if (milisec<=0){
    <p> milisec=9
    <p> seconds-=1
    <p>}
    <p>if (seconds<=-1){
    <p> milisec=0
    <p> seconds+=1
    <p> }
    <br>else
    <p> milisec-=1
    <p> document.counter.d2.value=seconds+"."+milisec
    setTimeout("display()",100)
    <p>}
    <p>display()
    <p></script>
    <p></body>
    <p></html>
    <p>This is my code that i was working on, in the jsp part of the script, i get a api call and save a value of time in the variable remainingtime.. and in the javascript, i try to have a countdown clock counting down the remaining time.. but i guess it doesnt work.. how can i get that working? thanks alot
    Message was edited by:
    hamham3001
    Message was edited by:
    hamham3001
    Message was edited by:
    hamham3001
    Message was edited by:
    hamham3001

    Re: How to pass a jsp variable into javascript??Here is the sameple one, hope it will solves your problem.
    <html>
    <body>
    <form name=f>
    <%!
    String str = "A String"
    %>
    <script>
    var avariable = <%=str%>
    <script>
    </form>
    </body>
    </html>
    Let me know if you face any problem

  • How to put a javascript  variable containg the i18n key  in the i18n tag

    I have a list of values in a List box.when the user selects a praticular value.,i need to show the java script localized alert message for the selected value.
    how can i pass the javascript variable to i18n tag.
    For ex:
    function test(){
    var selectedvalue='name';
    var localizedstring='<i18n:message key="+selectedvalue+"/>';--This is not working
    alert('<i18n:message key="+selectedvalue+"/>');
    the alert message is a blank string,even though i have the key in my resource bundle.
    Also..if i give directly pass the key value to i18n string it works. like..
    var localizedstring='<i18n:message key="+name+"/>';--This is  working
    *(am passing the variable value)*

    The following should be able to pass ans.
    <script language="Javascript">
    function check_answer(ans) {
    if (testing.result.value==ans ){
    window.alert("You have got 10 marks.");
    </script>
    <body>
    <form name="testing"...>
    <%
    ResultSet rs = stmt.executeQuery("select * from level where...");
    while(rs.next())
    out.println("<tr>");
    out.println("<td>" + rs.getString("question") + "</td>");
    ans = rs.getString("answer");
    out.println("</tr>");
    out.println("<input type='text' name='result'>);
    out.println("<input type='button' value='Enter' onclick='check_answer('<%= ans%>')'>");
    %>jag

  • How to pass the USER variable to RPD in 11g?

    I am trying to figure out how to pass the USER variable to the RPD in 11g.
    In 10g, I had define an intializtion block to store the USER variable and pass it to a statement that has to be executed before the query is executed.
    We use the Oracle VPD technology that allows to restrict data access. This is the statement that has to be executed before a query can run.
    select vpd_adwh.setclnvpdcontext_fnc('VALUEOF(NQ_SESSION.cuser)', UPPER(:USER))) from dual
    That is the 10g version and it works fine.
    In 11g, I tried to use
    select vpd_adwh.setclnvpdcontext_fnc('VALUEOF(NQ_SESSION.cuser)', UPPER('VALUEOF(NQ_SESSION.USER)')) from dual
    but this is not working.
    Any help?

    any ideas?

  • How can I assign javascript variables to jsp or java variables.?

    How can I assign javascript variables to jsp or java variables.?

    See I have generated some variables in the javascript which is on the jsp page. I want to assgin these variables to the jsp vaiables. Or how can I access javascript variables from jsp on the same jsp page.

  • How to pass Unix environment variable to a SQL procedure or SQL * Plus

    Can any body suggest me how to ,
    How to pass Unix environment variable to a SQL procedure or SQL * Plus file..
    I am trying to invoke a SQL Procedure from Unix
    by passing the value of a Unix environment variable.
    Is it possible..?
    Thanks in advance.
    Regards,
    Srinivas Jaltaru

    Within your shell script you can use what is known as a "here document" which is basically a way of wrapping a call to Oracle. The following call to Oracle loops and writes rows to files with numerically increasing file names. Two unix shell variables are used, one in a select statement and one in a spool command :
    <pre>
    #!/bin/bash
    export ORACLE_SID=DEV05
    FILENO=1007351
    while [ ${FILENO} -le 1008400 ]
    do
    FILENAME=farm_${FILENO}.txt
    DUMMY=`sqlplus -s user20/user20 <<SQLSTOP
    set lines 73
    set pages 0
    set head off
    set termout off
    set echo off
    set feedback off
    select rpad(searchx, 8)
    from blastx@PRODUCTION
    where searchx = ${FILENO} ### here's a shell variable
    spool /export/home/user20/sql/psiblast/BACKUP2_D/${FILENAME} ### here's a shell variable
    spool off
    SQLSTOP`
    FILENO=`expr ${FILENO} + 1`
    done
    exit 0
    </pre>

  • How to pass values to variables in WAD 7.0 using java script

    Hi.,
    My requirement is based on WAD 7.0.
    The sales value has to displayed in WAD using graph with various chart types.
    I have created variables for plant and material group in a query.
    I have created drop down box for plant with all plants in it, check box for material group and a Submit button in WAD in FORM tag of HTML coding.
    Once all the values are set in drop down box, checkbox and if the user clicks on submit button, the values has to captured by the variables for which I have created and the graph has to be aligned to the new values in variables.
    Kindly help me how to use java script to get the values from FORM and pass it to variables.
    Regards,
    Selva

    Hi Selva,
    You do not need to use Javascript for this. Instead you can achieve this by using API Commands in WAD 7.0.
    Please configure Action on the ButtonGroup webitem to use 'Commands'.
    ->Choose Command 'Set Variables Values / SET_VARIABLES_STATE' under Commands for Web Templates
    ->Set Display Variable Screen setting to OFF
    ->Choose Query Variable for Plant, Select Variable Type as 'Binding Type', Binding Type as 'Data Provider Selection', Data Provider as the one you have assigned to the Dropdown webitem, Characteristic as 0PLANT or as that assigned to the Dropdown webitem
    ->Repeat above steps for Query Variable Material Group
    Now when you make a selection from the Dropdown webitems, the Chart output will change accordingly. Let me know if this helps.
    --Priya

  • How to access a javascript variable from Java?

    Here is my code:
    function validateLoginForm() {
        var username = document.getElementById('un');
        setCookie('un', username, 3650);
        //etc.
    <%   
        HttpSession httpSession = request.getSession();
        httpSession.setMaxInactiveInterval(30 * 60); //30 minutes
        httpSession.setAttribute("un", username); //!prob here - cannot resolve 'username'
    %>
    }...but how do I access the javascript variable 'username' from the Java code?
    Thanks,
    James

    The only way to pass values between JavaScript and JSP is through cookies. It sucks, I know, but right now that is the only option.
    You already are creating a cookie in JavaScript. So go ahead and read it in Java:
    Cookie[] cookies = request.getCookies();
    for(int i = 0; i < cookies.length; i++) {
        Cookie c = cookies;
    if (c.getName().equals("un")) {
    // Do what you need here.

  • How to pass table type variable into function from SQL*PLUS ?

    How to pass a table type variable from sql*plus prompt into a function ?
    Thanx in advance.

    Krishna,
    Do you mean like this?SQL> DECLARE
      2      TYPE t_tbl IS TABLE OF VARCHAR2(20);
      3      l_sample_tbl           t_tbl;
      4
      5      FUNCTION print_contents ( p_tbl IN t_tbl )
      6      RETURN VARCHAR2
      7      IS
      8          l_string            VARCHAR2(1000);
      9      BEGIN
    10          FOR i IN 1..p_tbl.COUNT LOOP
    11              IF (i = 1) THEN
    12                  l_string := p_tbl(i);
    13              ELSE
    14                  l_string := l_string || ', ' || p_tbl(i);
    15              END IF;
    16          END LOOP;
    17          RETURN (l_string);
    18      END print_contents;
    19
    20  BEGIN
    21      l_sample_tbl := t_tbl();
    22      l_sample_tbl.EXTEND;
    23      l_sample_tbl(1) := 'one';
    24      l_sample_tbl.EXTEND;
    25      l_sample_tbl(2) := 'two';
    26      l_sample_tbl.EXTEND;
    27      l_sample_tbl(3) := 'three';
    28      l_sample_tbl.EXTEND;
    29      l_sample_tbl(4) := 'four';
    30      l_sample_tbl.EXTEND;
    31      l_sample_tbl(5) := 'five';
    32      DBMS_OUTPUT.PUT_LINE(print_contents(l_sample_tbl));
    33  END;
    34  /
    one, two, three, four, five
    PL/SQL procedure successfully completed.
    SQL> HTH,
    T.

  • How To pass a period variable

    Hi experts!
    I have a model in visual composer that calls a query which has a filter on the characteristic 0FISPER, when I execute this query in the query Designer, the period of fiscal year is asked in the format "009.2007 - 008.2008".
    The problem is that I don't know how to pass this value in VC, because if I indicate the static text "009.2007 - 008.2008" in the field "Fiscal year period" in the connector between the inputform and the query, when I execute the VC model the following error appears:
    "Nested Exception. Failure to execute native function. Nested Exception.
    INVALID_VARIABLE_VALUES"
    Do you have any idea how to pass the values of the period to the variable of the query??
    Thnks in advance!!!

    Hi Roberto,
    the solution is available in the WIKI:
    <a href="https://www.sdn.sap.com/irj/sdn/wiki?path=/display/vc/howtoselectranges&">https://www.sdn.sap.com/irj/sdn/wiki?path=/display/vc/howtoselectranges&</a>
    Best Regards,
    Marcel Salein

  • How to pass a shell variable to rman scripts

    I want to backup datafile to different directory
    depending on the current time,and I can do this to
    pass a shell variable to rman scripts,and this
    variable will used as part of format ,like this:
    backup incremental level=0
    tag rman_inc0_bck
    filesperset 5
    format '$(DIR)/rman_fulldb_%u_%s_%p_%d'
    (database include current controlfile)
    and $(DIR) is shell variable ,but rman will not
    recognize this ,how to achieve this?

    You could send your script to rman thru a pipe | or <<
    echo "backup incremental level=0
    tag rman_inc0_bck
    filesperset 5
    format '$(DIR)/rman_fulldb_%u_%s_%p_%d'
    (database include current controlfile);" | rman target /You could also create a "temp script" and then use it from rman with cmdfile
    sed "s,XXXDIR,$(DIR)," yourtemplate > /tmp/rmanscript.$$
    rman target / cmdfile /tmp/rmanscript.$$
    rm /tmp/rmanscript.$$

  • How to pass Applet form variables without showing it on top ?

    I am running one applet with some form variables. After submit I want to pass those to .asp file to store into database.
    If I use URL method then all are getting displayed on URL location of browser which I do not want. I want to pass many form variables to another .asp file, so it may not be good also.
    What is the best way of doing it ? Need urgent help about it.

    Well If you create a POST request instead as a GET request the variables will not show up in the URL.
    On tips how to do that you can either check out this thread:
    http://forums.java.sun.com/thread.jsp?forum=31&thread=56388
    or one of these:
    http://search.java.sun.com/Search/java?qt=applet+GET+POST+variables&col=javafrm&rf=0
    Sjur

Maybe you are looking for

  • IMac CD with mini-DVI - Video adapter woes

    I bought a mini-DVI to video adapter when I first got my iMac Core Duo. I never used it, and so a few weeks ago I was distressed to find out that it didn't work. So I ordered another, assuming the cable was the problem. Nope -- this one has the same

  • Adobe story is not loading. Once the program has accepted my password, it get stuck on the "loading" page.

    Help! I cannot access anything in adobe story. It is perpetually stuck on the loading page. I tried deleting my history and using a private browser page. Nothing is working.

  • SubSubMenus not appearing

    I have a menu that has a submenu that is created from XML. Some of those submenu items have submenus, but those items are not appearing. When I set left=0 in ul.MenuBarVertical ul, the content of all of the submenus are visible (so it has the data),

  • Tags Changing?

    I have a Coldfusion website that is pulling all content from a MS Access Database. I have a backend administration site to allow website admins to go in and post new/updated code and submit it back to the database. The admin puts the new code in a te

  • Memory Allocation Error during Boot

    Hi, I am posting this on a different computer than the one on which I istalled Java because I can no longer get it to boot. Here's the history: I am working in Windows 98 I added a line to the autoexec.bat so that the PATH lines looked like this: SET