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().

Similar Messages

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

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

  • 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

  • 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

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

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

  • 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

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

  • 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

  • Help: How to assign dynamically a javascript variable to a jsp variable???

    Hello all,
    What I need to do is to assign the value of the html form element which is a checkbox in this case:
    <input name="ADB02_checkbox" type=checkbox id="ADB02_checkbox" onClick="decide_enable_or_disable_particular_checkbox()" value="ADB02">
    to a jsp variable :
    <%
    String riderCode = "";
    %>
    Its dynamic because i need to do different operations based on different rider codes like in this function:
    function decide_enable_or_disable_particular_checkbox() {
    var rider = document.rider_form;
    alert(rider.ADB02_checkbox.value);
    if (rider.<%= riderCode%>_checkbox.checked == true) {
    enable_all_row_elements_for_<%= riderCode%>();
    else {
         disable_all_row_elements();
    which uses the naming of the rider code to call other corresponding functions.
    so is there any way that you guys ca suggest a solution.
    what i thought is to do this:
    function decide_enable_or_disable_particular_checkbox() {
    var rider = document.rider_form;
    HERE--> riderCode = rider.ADB02_checkbox.value;
    alert(rider.ADB02_checkbox.value);
    if (rider.<%= riderCode%>_checkbox.checked == true) {
    enable_all_row_elements_for_<%= riderCode%>();
    else {
         disable_all_row_elements();
    or
    add an onFocus="riderCode = document.rider_form.ADB02_checkbox.value;" in the checkbox tag.
    but can i do that or is there any other way or is it totally impossible to assign javascript values to jsp variables.

    Hi again,
    I got a problem here abt looping in javascript.
    The prob is that only the 1st loop works the rest are not.
    So only the checkbox in the 1st row is enabled, the rest aren't.(only ADB02 is enabled not DLP01 cause ADB02 is 1st in the loop)
    Here are 2 of many of the checkboxes in different rows:
    <input name="ADB02_checkbox" type="checkbox" id="ADB02_checkbox" value="checkbox" onClick="val_checkbox()" disabled=true>
    <input name="DLP01_checkbox" type="checkbox" id="DLP01_checkbox" value="checkbox" onClick="val_checkbox()" disabled=true>
    This is declared in jsp:
    <%
    //to be used with javascript function prepare_elements() for checking to enable/disable checkbox , to check age base and limit of insured
    String[][] riderCheckArray = {
    {allPlans.PLAN_HER_MY_FUTURE, allRiders.RIDER_ACCIDENTAL_DEATH_BENEFIT, "20", "60"},
    {allPlans.PLAN_HER_MY_FUTURE, allRiders.RIDER_LIFELINE_BENEFIT, "20", "50"},
    {allPlans.PLAN_HER_MY_FUTURE, allRiders.RIDER_MEDICASH_100_PLAN, "0", "55"},
    {allPlans.PLAN_HER_MY_FUTURE, allRiders.RIDER_MEDICASH_200_PLAN, "0", "55"},
    {allPlans.PLAN_HER_MY_FUTURE, allRiders.RIDER_MEDICASH_300_PLAN, "0", "55"},
    {allPlans.PLAN_HER_MY_FUTURE, allRiders.RIDER_MANUTERM_REDUCING_TERM_ASSURANCE_PLAN, "16", "65"},
    {allPlans.PLAN_HER_MY_FUTURE, allRiders.RIDER_PERSONAL_ACCIDENT_BENEFIT, "20", "65"},
    {allPlans.PLAN_HER_MY_FUTURE, allRiders.RIDER_15_YEAR_LEVEL_AND_CONVERTIBLE_MANUTERM_RIDER, "16", "55"},
    {allPlans.PLAN_HER_MY_FUTURE, allRiders.RIDER_20_YEAR_LEVEL_AND_CONVERTIBLE_MANUTERM_RIDER, "16", "50"},
    {allPlans.PLAN_HER_MY_FUTURE, allRiders.RIDER_5_YEAR_RENEWABLE_AND_CONVERTIBLE_MANUTERM_RIDER, "16", "60"},
    {allPlans.PLAN_HER_MY_FUTURE, allRiders.RIDER_10_YEAR_RENEWABLE_AND_CONVERTIBLE_MANUTERM_RIDER, "16", "60"},
    %>
    Here's the script (the riderCheckArray[any no.] should be eg: riderCheckArray[0] (has an i in front))
    <script>
    <!--////////////////////////////////////PREPARE PAGE BASED ON PLAN///////////////////////////////////-->
    function prepare_elements() {
    var rider = document.rider_form;
    <!--///////////////////////////////////////////////////for her@myfuture////////////////////////////////////-->
    for (i=0 ; i < <%= riderCheckArray.length%> ; i++) {
    if ("<%= txtPlanCode%>" == "<%= riderCheckArray[i][0]%>" ) {
    riderCode = "<%= riderCheckArray[i][1]%>";
    if (<%= insuredAge.intValue()%> < <%= Integer.parseInt(riderCheckArray[i][2])%> ||
    <%= insuredAge.intValue()%> > <%= Integer.parseInt(riderCheckArray[i][3])%>) {
    disable_particular_checkbox();
    alert("This rider cannot be attached. This rider can only be attached for age range " +
    <%= riderCheckArray[i][2]%> +
    " to " +
    <%= riderCheckArray[i][3]%>);                    
    else {                    
    enable_particular_checkbox();
    <!--////////////////////////////////////ENABLE/DISABLE checkboxes////////////////////////////-->
    function enable_particular_checkbox() {
    var Rdr_Checkbox = riderCode + "_checkbox";
    var rider = document.rider_form;
    rider.all(Rdr_Checkbox).disabled = false;
    rider.all(Rdr_Checkbox).style.background ="FFFFFF";
    function disable_particular_checkbox() {
    var Rdr_Checkbox = riderCode + "_checkbox";
    var rider = document.rider_form;
    rider.all(Rdr_Checkbox).disabled = true;
    rider.all(Rdr_Checkbox).style.background ="CCCCCC";
    </script>

Maybe you are looking for