Assigning a javascript value to a JSP variable

How do i assign a javascript value to a JSP variable?
eg
<%
String JSPvar;
%>
<script language="JavaScript1.2">
<!--
var javascriptVar="hey"
-->
</script>
<%
JSPvar = javascriptVar ???
%>

You do know that the JSP runs on the server and generates HTML, including Javascript, that is executed on the client, don't you?

Similar Messages

  • Assigning html input value to a jsp variable

    I have the following problem: I need to assign the value of html <input> field to a jsp variable. This should be done without submittion of the form.
    <form name="main">
    <table>
    <tr>
    <td><input type="text" name="gantry" value="123"></td>
    </tr>
    <table>
    </form>
    Is there any way to access main.gantry.value from jsp and assign it to a variable? I tried
    <% prevGantry = main.gantry.value; %>
    but it didn't work, and the problem is not with parsong or initialisation. Please, can anyone help?
    Best regards, SoVa.

    No it can't be done. You are mixing up java with javascript.
    Java/JSP runs on the server end. Generates an HTML page and stops running.
    The page loads in the browser, and and can run javascript locally.
    The only way to run java code again is to go through the request/response process. ie submit a form, click a link, make an Ajax call...
    The only way to get a field from the screen into a java variable is via request.getParameter().

  • Assigning a node value from an XML variable to a String type  in Weblogic Process Integrator

    Hi,
    Is there any way to assign a node value from an XML variable to a String variable
    in Weblogic Process Integrator...
    Thanx.
    Narendra.

    Nerendra
    Are you talking about using Xpath on the XML document and assigning to a
    variable, it is unclear what you are asking
    Tony
    "Narendra" <[email protected]> wrote in message
    news:3bba1215$[email protected]..
    >
    Hi,
    Is there any way to assign a node value from an XML variable to a Stringvariable
    in Weblogic Process Integrator...
    Thanx.
    Narendra.

  • Unable assign a BPM Object field value to a JSP Variable using "invoke"

    Hi,
    I'm unable to retrieve a value returned by a BPM Object Method and use it in JSP. Here is what I'm trying to achieve:
    BPM object named : "myObject" has a method "getRequiredValue" which returns a "String". I want to assign the value returned by "getRequiredValue" to a JSP Variable "myVariable" using invoke method as below:
    <% String myVariable = ""; %>
    <f:invoke var="${myObject}" methodName="getRequiredValue" retAttName="myVariable"/>
    <% out.println ("myVariable: " + myVariable); %>
    When I execute the above code I don't get the value being returned by "getRequiredValue" into "myVariable".
    Any help would be highly appreciated!
    regards,
    MK

    1. Make sure you mark the "Server Side Method" property of the getRequiredValue method to "Yes".
    2. I guess you dont need to specify "<% String myVariable = ""; %>". Try removing it.
    3. Replace "<% out.println ("myVariable: " + myVariable); %>" by <c:out value="${myVariable}"/> just in case!
    4. Lastly, I hope "myObject" is the name of the instance variable in your screenflow, and not the BPM object name.
    Hope this helps
    -Hemant

  • Get Javascript Value in a JSP page

    Let's say this is my javascript function in a html page
    .<head>
    <!-- Function getFields -->
    function getFields(){
    if (row >= 0){
    for(var i=0; i<costForm.elements.length; i++){
    if(costForm.elements.type == "text" || costForm.elements[i].type == "hidden"){
    dynTableFields[i] = (costForm.elements[i].value)? costForm.elements[i].value : "";
    if(costForm.elements[i].type == "select-one"){
    dynTableFields[i] = costForm.elements[i].selectedIndex;
    </head>
    How do i get the costForm.elements.length value in another jsp page. Coz the html page has dynamic rows by the users. and i need the values in the jsp page to know how many rows the user created.
    using normal request.getParameter("costForm.elements.length") doesn't work

    request.getParameter() will only get data that's been submitted thru a form or the query string of a URL. You'd have to record the length in a hidden field to read it on the back end, and then you can't just loop thru the fields like that in JSP on the server anyway, unless you have all fields named with a prefix and number, like: field1, field2, field3, etc.

  • Error while assigning a character value to a numeric variable.

    I fire a sql statement and check the number of rows returned by the sql.
    I check this result with the application logs.
    The application logs keeps the sqls fired by the application and the no of rows returned, in the example below the sql returned 8454 rows.
    My script compares the two results.
    ***********Application Log***********
    4/14/2008 11:15:01 AM: 0059 SQL SELECT "CLUSTER_CD",
    4/14/2008 11:15:01 AM: 0060 "PRODUCT_DESC",
    4/14/2008 11:15:01 AM: 0061 "TEAM_CD"
    4/14/2008 11:15:01 AM: 0062 FROM "OPS$TMS"."MAP_CLUSTER_TEAM_PROD"
    4/14/2008 11:15:01 AM:      3 fields found: CLUSTER_CD, PRODUCT_DESC, TEAM_CD, 8,454 lines fetched
    ***********Application Log***********
    My script:
    #!/bin/ksh
    typeset -i resA
    typeset -i resB
    opstms_conn_string="abc/[email protected]"
    set `sqlplus -s $opstms_conn_string << EOF
    set pages 0
    WHENEVER SQLERROR CONTINUE
    SELECT count(*)
    FROM MAP_CLUSTER_TEAM_PROD;
    exit
    EOF`
    resA=$1 ##returns 8454
    resB=`grep '3 fields found: CLUSTER_CD, PRODUCT_DESC, TEAM_CD,' BCVP_Main_Loader.qvw.log | awk '{print $10}'`
    ##resB returns 8,454
    ## here i get syntax error
    if [ $resA -eq $resB ]; then
    echo "QA passed for sql1"
    else
    echo "QA failed for sql1"
    fi
    The problem is as resB is integer variable it does not accept character value: 8,454 so returns a syntax error:
    How do I change the value assigned to resB into a numeric variable?
    error:
    + grep 3 fields found: CLUSTER_CD, PRODUCT_DESC, TEAM_CD, BCVP_Main_Loader.qvw.log
    run.ksh[52]: 8,454: syntax error

    Change:
    resB=`grep '3 fields found: CLUSTER_CD, PRODUCT_DESC, TEAM_CD,' BCVP_Main_Loader.qvw.log | awk '{print $10}'`
    to this:
    resB=`grep '3 fields found: CLUSTER_CD, PRODUCT_DESC, TEAM_CD,' BCVP_Main_Loader.qvw.log | awk '{print $10}' | tr -d ,`
    to drop the comma. Or you could do it in awk(1):
    resB=`grep '3 fields found: CLUSTER_CD, PRODUCT_DESC, TEAM_CD,' BCVP_Main_Loader.qvw.log | awk '{ gsub( /,/, "", $10 ); print $10}'`
    Or you could to it all in awk(1):
    resB=`awk '
    /3 fields found: CLUSTER_CD, PRODUCT_DESC, TEAM_CD/ {
    gsub( /,/, "", $10 )
    print $10
    ' BCVP_Main_Loader.qvw.log`
    (This example was not tested, it's just for a model.)
    Someone more of an SQL guru than I can probably tell you how to change your numeric locale to avoid presenting those commas in the first place and avoid the problem.
    HTH

  • Get a binding value in a jsp variable

    Hello,
    I need to get the value of <c:out value="${bindings.PreviousSet.enabledString}" /> in a variable that I'm using in JSP.
    Do you know how can I do it?
    I need to do that because the image that I'm going to show in a page depends on that value.
    I have the following line
    <input type="image" src="images/wizard/anterior.gif" name="event_PreviousSet" value="PreviousSet" <c:out value="${bindings.PreviousSet.enabledString}" />/>
    if the value is enabled I'll show an image otherwise I'll show anotherone.
    Thanks

    In the case of the first question you can use the binding expressions directly in other JSTL expressions, not just c:out, for instance you can use a <c:if test="${bindings.PreviousSet.enabledString eq 'true'}>
    to conditionally print something in the page.
    The expression here refers to a "bindings" attribute on the request, so likewise if you want to get at the value in code you can use request.getAttribute("bindings") and work on down.
    Pauls question - you have to think slightly differently because everything is abstracted through the ADF model layer. A good place to start would be the ADF Primer:
    http://otn.oracle.com/products/jdev/collateral/papers/10g/ADFBindingPrimer/index.html
    Also check out:
    http://otn.oracle.com/products/jdev/tips/shmeltzer/setwhereclause/index.html

  • How to assign the class value dynamically  in jsp:useBean ?its urgent

    Hi
    I want to set the class value of <jsp:useBean> dynamically
    when i am trying to this way
    <jsp:useBean id="<%=id %>" class="<%=beanclass %>" scope="request">
    <jsp:setProperty name="<%=id %>" property="*"/>
    </jsp:useBean>
    where beanclass is .class file that is to be used by the usebean tag
    i am getting following error
    The value for the useBean class attribute <%=beanclass %> is invalid.
    please help as soon as possible
    regards,
    Rameshwari

    You can not do that.The jsp:useBean and jsp:setProperty are action tags and not custom tags. Action tags get translated into Java code in the translation unit and are then compiled. Custom tag are backed by classes and the tag get translated into a method call of the class.

  • How to assign a default value to a query variable

    If I create a query, and it contains a variable that I want the user to input, can I also assign a default to that variable which the user will see when they run the query? If they make no selection it would use the default instead of the user input?
    Thanks

    Hello Peter - One way might be by using the "CASE" function inside the SQL.
    It might be good for you to post your curent SQL here in the forum and a bit more explanation of what you are looking for.  That way folks can review and provide suggestions on how to accomplish on how it can be done...
    Zal

  • Assign Javascript Value to JSP

    I have a dynamic link that links to a Javascript function:
    test
    The javascript function:
    function frames(testing)
    <%=testHere%> = testing
    <%
    HttpSession testSession = request.getSession(true);
    testSession.putValue("tested", testHere);
    %>
    I want to assign the javascript value, testing, into JSP value,testHere, which will be place in the session, which is :~
    .......putValue("tested", testHere).
    Does anyone know how to solve it? =)
    Thanks in advance...

    You can't. As is stated here about 3 times a day, Java, the JSP code, and servlets run on the Server, while javascript runs on the client (in the browser). By the time javascript begins to run, the JSP is compiled, run, the response generated and sent to the browser as HTML.
    The only means to do this is to send the variable back to the browser by requesting the same or another page and including the javascript value as a parameter to that page.

  • How to assign bean value to a local variable in JSP using struts.

    Hi everybody!
    I've a problem that puzzled me on how to assign a bean value to a local variable like String in JSP using struts.
    we can have someting like this to display the value
    <bean:write name="detailService" property="status" />or
    <bean:define id="theStatus" name="detailService" property="status"/>
         This is country: <%=theStatus%>but an error occured when I tried like this:
    String currentStatus = "<bean:define id="theStatus" name="detailService" property="status"/>";
    or
    String currentStatus = "<bean:write name="detailService" property="status" />";Is there a way to do this?.....
    Any help pretty much appreciated

    Java != JSP.
    The <bean:define> and <bean:write> tags are custom tags meant to appear in the HTML section of a JSP file, as opposed to the scriptlet section. They actually get turned into java code as part of the translation process.
    The <bean:write> tag naturally just writes out what you tell it to.
    The <bean:define> tag defines a local variable, and gives it a value.
    this should do it.
    <bean:define id="theStatus" name="detailService" property="status" type="java.lang.String"/>
    <%
      String currentStatus = theStatus;
    %>With the advent of JSTL, you shouldn't really need to use scriptlet code anymore. Personally I am for 0% scriptlet code in any jsp I write.

  • 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.

  • Passing javascript values to jsp without refreshing the page

    Hi,
    How do u pass a value of a javascript variable to the jsp without refreshing the page ?
    For example, a file called test.jsp in which a javascript variable x contains value 254. I need to pass the value of x to a method declared in test.jsp(same page).

    Hi Mona,
    when i say refresh i do mean a blink of the browser.
    This is a small example i wrote to show you how you can pass javascript varables to JSP variables. If you don't want the refresh to be seen by the user just include this code in a hidden frame on a page and instead of refreshing the entire page, refresh the hidden frame.
    i have to say, i didn't test the code so i don't guarantee it's flawless.
    if you need an more detailed example just tell me, i'll create one, but it won't be for today :)
    <html>
    <head>
         <title>Log in to the system</title>
    </head>
    <body>
    <script>
    //we retrieve the parameter 'user' from the URL
    <%
      String username = request.getParameter("user");
    %>
    var user = "<%= username%>";
    //check if there is a username in the URL
    if(user=="null")
      //there is no username so we log the person in as a guest
      user="guest";
      //we refresh the page and set the user parameter to 'guest'
      //the parameter now contains the javascript variable 'user'.
      //The parameter can be read by the JSP (see the top op this script).
      //This way we gave the javascript variabele to the JSP variable
      location="login.jsp?user="+user;
    else if(user=="guest")
    {  alert("Welcome "+user+", I hope you like this site"); }
    else
    {  alert("Welcome "+user+", I'm glad to see you again"); }
    </script>
    </body>
    </html>

  • How to Open URL value stored in a variable in JSP

    Hi all,
    I want to know how i can use value of a string variable in a JSP as url to open.
    <% String abc="some url value" ; %>
    then i want to open abc as URL in JSP
    Please suggest something on this.
    any help in advance will be highly appreciated.
    thanks,
    savdeep.

    thanks rahul but,
    I want to open the URL in
    <% String URLvariable="abc.htm" ; %>
    <% out.println("< a href=URLvariable>"+rs.getString("Some JSP value")+"</a>"); %>
    please suggest how should i open the above URL value stored in JSP variable.
    any help will be highly appreciated.
    thanks,
    savdeep.

  • Seting a JSp variable to session scope in JSp page itself

    Hi,
    I have code like this
    <HTML>
         <HEAD>
              <TITLE>Change Password</TITLE>
              <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet/vclinical.css" TITLE="Style">
    </HEAD>
    <BODY>
    <form name="form">
    <select name="ss" onChange="this.form.qq.value=options[selectedIndex].value;getit()">
    <option value=1>ss1</option>
    <option value=2>ss2</option>
    </select>
    <input type="text" name="qq" value="">
    <%
    String asd=request.getParameter("qq");
    session.setAttribute("Stored", asd);
    System.out.println("value is"+asd);
    %>
    </form>
    </BODY>
    </HTML>
    here i want to set value of a JSP variable qq to session scope and here i am not invoking any servlet i want value of qq in next JSP page i am not submitting the page so how i can handle this. this code does not work so please tell me how to do this i am using struts frame work

    if you are using the struts framework, then you can make an ActionForm with getters and setters for the stuff that you are writing in the JSP i mean the radio buttons and text boxes etc
    from that action form you can get the values any time any where
    you just need to enter some thing like below in the struts-config.xml file
    <form-bean name="the action form name" type="package name.Actionform name" />
    <action path="/controller " type="package name.controller name" name="Action form name" scope="session">
    you can either put the action form in request scope or session scope

Maybe you are looking for

  • Account assignment category in third party sales

    Hi, Can any body pls tell me from where we can get account assignment category as 1 in third party sales in PO. here i am getting X instead of 1. i need to get 1 by defalt. Please help me. Regards DVSK

  • Automatic invoice generation for service contract

    Hello, I want to create the  automatic invoicce generation for service contract based on the order. whenever i raise service contract order system should create the invoice automatically. could please let me know the settings?

  • Unable to load staging area table in teradata from ODI

    Hi i'm unable to load data in Staging area in teradata. while loading i'm geeting following Error org.apache.bsf.BSFException: exception from Jython: Traceback (innermost last): File "<string>", line 9, in ? Load Error: See D:\CRM_MOD\/CRM_PRODUCT_SS

  • Constructions Industry - Use of SO BOM

    Hi, We are using ECC 6 and my client is a constuction company. The company is using SAP material no - material type DIEN and this is entered during SO creation. We dont keep any inventory as the nature of the business is construction/service. For exa

  • Storage resource

    Hi all,       In  process Industry we got intermediate storage is there for the phase. In a process Order operation wise confirmation happens. But we want to capture the phase wise qty in a specific storage location. with that we can calculate the ex