Assigning values to a javascript variable

Hi,
Using request dispatcher, i'm forwarding the control to a html from a servlet like this(obj.forward(/index.html?field1=value1&field2=value2).
In the receiving end, ie., in the html i would like to assign those 2 field1,field2 values to a javascript variables. Javascript located in the index.html.
I don't know how to do this.
Pls any one help me to get of this pblm
Thanks in Advance
Kannan.T

Hi thanks for ur reply,
You r telling while forwarding a request from one
servlet to another servlet, we can't add query
string(requestparameters). But then how come this
code is working?
RequestDispatcher
rdis=getServletContext().getRequestDispatcher("/MyServ
let?type=normal");
rdis.forward(req,res);Well I owe an apology here - I was not completely correct. I have tested and found that you can indeed add parameters that way. The catch is that these parameters are nested to that forwarded /included resource. It is not available in the original jsp or to some other resource included from the original jsp unless ofcourse you add the parameter again.
>
please give me a solution.
Like this i have to forward my request (with
querystring) to a html page.
That htmlpage should receive parameters and assign
the values to a javascript variables.
how can i achieve this.
thanks in advance.My original reply stands.
You cannot do that in a html page. You have to have a jsp that generates the html.
ram.

Similar Messages

  • I want to assign the value of a Javascript variable to JSP Variable

    I want to assign the value of a Javascript variable to JSP Variable .. for example :
    <%
    Bla Bla Bla
    %>
    <script>
    var JavaScriptVariable="hello"
    </script>
    <%
    String JSPVariable=// The Value of JavaScriptVariable ;
    %>
    How can i do that ??
    Thanks

    >I want to assign the value of a Javascript variable to JSP Variable
    cannot be done.Friend try to understand concepts properly Javascript is always excuted by the browser @clientside where as JSPCode is executed Websever(ServletContainer) @serverside.Through you are combining JSP Code blocks(Tags,Expressions,scriptlets...) & javascript under a single page webserver can only identify what is their under JSP Code blocks.
    Hope this could be an appropriate answer for your question.
    However,you can as well submit a request by encoding your URL with request parameters and the submit to the page and then collect it using request.getParameter(name).
    But under a single context state it is not possible
    REGARDS,
    RaHuL

  • How to assign a JSP variabl's value to a JavaScript variable?

    Hello,
    I want to assign a JSP variable's value to JAVASCRIPT variable.
    or how to assign JavaScript variable's value to JSP varialbe
    HOw do i do it ?
    can anyone please help?
    Regards and thanks for your time.
    Ashvini

    I want to assign a JSP variable's value to
    JAVASCRIPT variable.
    var jsVariable = <%=someVariable%>;
    or how to assign JavaScript variable's value to JSP
    varialbeYou can't. JSP is server-side and JavaScript is client-side. The JSP variables are never available on the client side for any sort of assignment.

  • Assigning value to array type variable in a loop

    Hi
    I have a scenario in which i am assigning value from a array type variable(x) to the invoke variable of a database adapter. The variable x is exact replica of the invoke variable.
    My copy operation in assign activity looks like this-
    <copy>
    <from variable="Var" part="InputParameters"
    query="/ns7:InputParameters"/>
    <to variable="Invoke_call_XXDPI_EDI_852_PKG_InputVariable"
    part="InputParameters"
    query="/ns7:InputParameters *(* bpws:getVariableData('iterator') *)* "/>
    </copy>
    It is inside a while loop activity.
    PS *()* are square brackets
    But it is erroring out at run time.
    Does anybody has an alternate idea to assign value to an array type?.
    i have seen that while extracting value from an array type variable it works fine
    A similar kind of operation is shown below.
    <copy>
    <from variable="Var" part="InputParameters"
    query="/ns7:InputParameters *(* bpws:getVariableData('iterator') *)* "/>
    <to variable="Invoke_call_XXDPI_EDI_852_PKG_InputVariable"
    part="InputParameters"
    query="/ns7:InputParameters"/>
    </copy>
    Thanks
    Ayush
    Edited by: Ayush fujitsu on Aug 14, 2009 4:36 AM

    Hi Ayush
    I suppose you are getting some error like "source node returns multiple elements".
    In second case there is no problem because you are assigning *InputParameters[bpws:getVariableData('iterator')]* (+suppose InputParameters[1]+) to target. Here it works fine because you are fetching oonly 1 value from source and assigning it to the target.
    Now in first case you are saying copy InputParameters to target[1] suppose. You know that source is an array which contains multiple index so which index field from the source will be assigned to the target.
    Try your process with only 1 source value it will work but when multiple values will be there it will fail. You have to merge both the cases and it will look like
    *<copy>*
    *<from variable="Var" part="InputParameters"*
    query="/ns7:InputParameters ( bpws:getVariableData('iterator') ) "/>
    *<to variable="Invoke_call_XXDPI_EDI_852_PKG_InputVariable"*
    part="InputParameters"
    query="/ns7:InputParameters ( bpws:getVariableData('iterator') ) "/>
    *</copy>*
    And the easiest way to do this is by the transform activity as said above.
    Regards
    Suryaveer
    Edited by: Suryaveer on Aug 15, 2009 11:19 PM

  • Passing struts-tag value to java / javascript variable in JSP

    Hello all,
    Im trying to pass the value got from the struts-tag to the java variable in the Jsp. However Im not able to get the o/p. Can u guys help me on this pls...
    <logic:notEmpty name="TreeBean" property="list">
        <logic:iterate id="Type" name="TreeBean" property="list" indexId="i">
         <br/><bean:write name="Type" />
        </logic:iterate>
    </logic:notEmpty>Here the list can be populated in the jsp page. However i want the values into jsp list. Im not able to populate the same..
    <% List jspList = null;
    %> I want the values into the jspList variable for further processing. Can u guz pls help me on this....

    Which do you want it in?
    A java variable for use in <% scriptlet code %> or a javascript variable for use on the client end?
    scriptlet:
    <jsp:useBean id="TreeBean" type="java.util.List" class="java.util.ArrayList" scope="?????" />
    Having scriptlet code on the page is considered bad coding style.
    What is it you are trying to accomplish by making the value accessible?
    What are you trying to do in java / javascript that can't be done with JSP tags?

  • Assign value to Object type variable

    CREATE OR REPLACE TYPE emp AS OBJECT (
    empid NUMBER,
    age NUMBER,
    dob date);
    CREATE OR REPLACE TYPE emp _tab AS TABLE OF emp;
    Pls hlep me assign value to the object type variable in loop..(assume there is 5 10 records in emp table)
    declare
    v_emp_tt emp _tab ;
    begin
    for i in (select empid ,age ,dob from emp ) Loop
    v_emp_tt := i.empid; --this is wrong pls help me correct it.
    end loop;
    end;
    thanks,

    I would keep the type/object naming convention distinct from the table name.
    In terms of assignment:
    CREATE OR REPLACE TYPE to_emp AS OBJECT
    (empid NUMBER,
    age NUMBER,
    dob date);
    CREATE OR REPLACE TYPE tt_emp AS TABLE OF emp;
    declare
    v_emp tt_emp;
    begin
    select to_emp_obj(emp_id, age, dob)
    bulk collect into v_emp
    from emp;
    end;

  • How to display the value of a javascript variable in a html region ?

    Hello,
    I need to display my page title or name in a html region.
    I added a script in the <title> section of the template header... :
    (thanks Andy : Get page name from page attributes ?
    <script type="text/javascript">
    var pageTitle = '#TITLE#';
    </script>... so I can use it in a javascript variable.
    But now I don't know how to display it in a html syntax..
    Thanks!
    Fanny

    ... so I can use it in a javascript variable.Don't see any reason to modify page templates to introduce an unnecessary global JS variable when the document property is already there. Display it using an appropriate HTML element, e.g <tt>h1</tt> if it's the overall page heading.
    <h1>
      <script type="text/javascript">
        document.write(document.title);
      </script>
    </h1>

  • Assigning value to a CLOB variable

    Hi,
    I've a variable var1 in CLOB datatype.
    When I try to put the following statement in my procedure, it raises errors.
    var1 := 'New value for this variable';
    Why? or is there any function that I need to convert the value to CLOB before assigning it ?
    Please advise.
    Thanks.

    Hi,
    you can find all that you request at the
    SYS.DBMS_LOB Package.
    you can read & write into the lob RAW data or files and perform all kinds of stuff.
    Read the package and get wise.

  • Assigning javascript variables to java variables in JSP

    Does anyone know if it possible to assign a javascript value to a java variable in a javascript function? I want to be able to use the javascript value in a PreparedStatement call, but I can't assign the value of the javascript variable to a java variable. I know the opposite can be done using hidden variables in the form, but I need:
    javascript -> java variable in a JSP scriptlet.
    Any help would be much appreciated,
    Thanks,
    -Dave

    Can't do that.
    html/javascript is in the client side.
    jsp is in the server side.
    In order to put html/javascript values (client side) into jsp (server side) it must be submitted.
    Try remoting. Using an iframe with a jsp as the source of it and the html target pointing at it.
    -------------

  • How to access javascript variable's value in a jsp tag?

    Is there any way to access the value of a javascript variable in jsp?

    Hi
    by the way your question is ambigous, i understand the question to some extent here i there is a sample code which may be help full to you. As this problem is faced by me when i was developing some dynamic pages in my company.
    <%@ page language="java" %>
    <html>
    <head>
    <script language="JavaScript">
    var i = 10;
    var k = 20;
    </script>
    </head>
    <%
         String Jspi = "";
         Jspi = ("<script>document.write(i);</script>");
         out.println(Jspi);
         Jspi = ("<script>document.write(k);</script>");
         out.println(Jspi);
    %>
    </body>
    </html>
    This will help u out.
    Cheers
    Rambee

  • Assign value to ODI variable from Jython

    Hello Experts,
    I have a procedure where I'm using Jython code. I want to assign a value to an ODI project variable from a Jython function:
    Example:
    #COUNTER = len(v_jythonList) ---> being #COUNTER the ODI project variable and len() the jython function
    Now, i noticed that using ODI variables adds # sign which is use for comments in Jython code. Is there a way to assign values to ODI variables from Jython script?
    Please help!.
    Thanks.
    Pablo.

    Hi,
    Does this post help you :- How to assign value for a ODI variable from Jython Script
    Doc id 424579.1 on metalink should help.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • How to get javascript variable in jsp variable

    Hi all,
    i have a variable str in my javascript function
    var str = somevaluei want this str value in jsp variable in the same page...
    how can this be done..???
    any ideas...
    Thanks

    I dont know if its possible or not.
    Actually it depends on what do you want to do with the variable.
    as far as assisginng value to the hidden variable is concerned it can be done this way.
    <% jsp code
    String hiddenVar = "";
    %>
    < html code
    <input type type = "hidden" name="hidden" vale="<%=hiddenVar %>"
    html ends>
    while in js function you can assign vale to the hidden variable which will ultimately assign value to the JSP variable as follows.
    var str = "value";
    document.form_name.hidden_field_name.value = str.
    hope this hepls.

  • JSP Session in JavaScript variable problem

    Hi,
    I have a session variable msgSize that is being set by a Java file in the session.
    aRequest.getSession().setAttribute("msgSize", msgSize);It's value is variable depends on record count of recordset.
    In JSP page where I have to assign it's value to a javascript variable. I am doing this a s follows. I have done this in the JSP file.
    <script type="text/javascript" >
    <!--
    function getVal()
    m=${msgSize};
    -->
    </script>First Problem is I am unable to get this value inside a External JS file. It throws error but inside jsp it is working. How can i use this inside External JS?
    Second problem is once the above code executed value never refreshed to new value?
    Means first time it executed it get value 200 next time again i executed the code the real recordset is 105 but still displaying 200. But when I restart the server next time it takes value 105 by itself....
    How I tackle this problem.?
    Regards,

    problem is I am not refreshing the whole JSP page everytime, only refreshing the partial page using ajax call that's why not getting the session new value...
    any suggestions what to do to get new value?

  • Jsf and javascript variables

    Hello, I am working on a visual jsf project.Inside my project, in a bean java class I have a string variable.Also, I have a jsp page in my project which has some javascript code inside it.Now, I want a method of the javascript to get the value of the string variable that I have in my bean.How is that possible?
    for example, I have the method
    function showAddress(address){
    and a variable in my bean: String addr;
    So I want when I run my project, the value of "address" in my javascript function to have the value of the string addr,but I haven't figured out how I can do that.

    as balusc said:
    The jsf code is generated on server side, then sent to the client (browser). At this time javascript can't call any jsf related code anymore.
    But what you can do is assign a value to a javascript variable when you are processing the jsf file on the server side. Or you can work with ajax and make requests to the server...
    If you work with an IDE, you will notice it will not allow you to assign a javascript value to a jsf variable, no matter how you write it :) The other way round it works

  • Without using applets geting the output into a javascript variable

    Hi,
    I'm not using executeCommand applets in my webpage,but with the url
    i'm running the transaction. I'm passing the url to iframe as a <b>src</b> in the same page itself. like
    <b>document.getElementById("<iframe>").src="http://localhost/Lighthammer/Runner?Transaction=<Transaction_Name>&<Input_params>=<value>&OutputParameter=*"</b>. It will take 10 seconds to execute the transaction and load into the iframe.
    So I'm giving the
    <b>SetTimeout("alert(document.getElementById('<iframe>').docuemnt.body.innerHTML",10000);</b>
    In the iframe i'm able to see the output as "<u>oktransaction executed</u>" in <u>xml format</u>.
    But in the alert I'm not able to see the same content. <i>In the alert I'm able to see</i>
    <u><iframe id="<id of iframe>" src="<Which i set in the script>"></iframe></u>
    Help me to get the OutputParameter value into a javascript variable.

    Rakesh,
    A couple of observations:
    1.  Why are you calling Runner directly?  You should be using an XacuteQuery template, and reference "/Lighthammer/Illuminator?QueryTemplate=Folder/TRX" syntax when changing the URL in the iFrame.
    2.  You are also using "localhost" which is not portable and may also be causing your problem since your parent page will be based upon the server path, whereas you are forcing the browser to load localhost content into the iFrame (which unless you are physically sitting on the xMII server itself will never work).
    Regards,
    Jeremy Good

Maybe you are looking for