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.

Similar Messages

  • How to pass JavaScript value to JSP variable

    I know this is not possible. But I need to do this :
    <script language = "Javascript">
    function findElement() {
    for(i=0; i<document.forms[0].elements.length; i++){
    if(document.forms[0].elements.type == 'text') {
    var elName = document.forms[0].elements.name;
    var elValue = document.forms[0].elements.value;
    // Display element name and value
    //alert(elName +' = '+ elValue)
    <%
    String elName = elName;
    System.setProperty(%>elName<%, %>elValue<%);
    %>
    </script>
    in JSP. I need to get the name and value of the textbox in the form to just change one property on the JSP System. Any help pls

    Thanks man, I think that would work.
    I found something else already though and it works on the same page
    <%
         Enumeration parameters = request.getParameterNames();
         String parameterValue = " ";
         String parameterName = " ";
                   while (parameters.hasMoreElements()) {
                        parameterName = (String) parameters.nextElement();
                        parameterValue = request.getParameter(parameterName);
                   out.println("NAME =========" + parameterName);
                   out.println("VALUE =========" + parameterValue);
                   //System.setProperty(parameterName, parameterValue);
         %>
    Thanks again for the help

  • How to get the value of a variable defined in javascript in JSP

    how to get the value of a variable defined in javascript in/through JSP????

    In Javascript you can use the DOM to access the input element and set it's value before submitting the form. Then it's value will just be passed.

  • Passing JavaScript values to JSP variables

    Can any body correct the follwing code
    <Script language="JavaScript">
    function test( x )
    <%
    int num = x;
    num = num * 2;
    %>
    v.value = "<%out.print(num);%>";
    <input type="button" name="b" value="test" onClick="test(5)">
    <input type="text" name="v" value="0">
    In short, I am trying to pass JavaScript value to JSP variable. I hope that it is possible to do that. If it is possible then how can I do it. I want to assing the variable x passed to the JavaScript function called test to the JSP variable called num.
    Regards,
    Ageel

    Thank you for your reply,,,
    I think then the only way to do it is to post the
    value on the server and then use request.getParameter
    method in jsp code
    but the question now how can I post values to the
    server using JavaScript without reloading the pageyes... you can to it by create a new popup window which will submit the value to server after page was loaded... then, server return a value to the same window in html/jsp page which then using javascript to set it back to the opener and close up the window... however, this is not a good choice unless you have no other alternative...
    >
    There is other possible solution
    if I can get the text field value from the same page
    without reloading it that would work fine and will
    solve my problem, is it possible?yes... you can get the value from the textfield...
    for example :
    function showValueInTextField()
        alert(document.forms[0].elements["mytextfieldname"].value);
    >
    My final question> can jsp change things on the same
    page without reloading it. I mean can it work like
    JavaScript so that I can use it's internal functions
    instead of using java script :S
    not really know what you trying to say here...

  • 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 get the value of a variable in FOX?

    Hi,
    In the FOX program how to get the value of a variable defined in planning area?
    can anyone give me some sample code?
    thanks

    Adding to the last reply,
    you can use VARI(variable) to get the count of the values.
    In the latest version of BPS, you may also use the following new foreach construct:
    FOREACH var IN VARIABLE  variable_id.
    Regards - Ravi

  • How to get a field that using variable in order to create a query

    Hi,
    I found a difficulty when creating a query. so, I would like to ask you some question.
    1. How to get a field that using variable which that field I want to put it in my query?
    For example, I would like to take quantity field in inventory audit report. And when I put my cursor in
    quantity field, there was only variable, item, etc. How to get this and put it in query?
    2. How to combined the invoice quantity with inventory audit report quantity?
    3. I have a query like this:
    SELECT distinct T0.[DocDate] as 'Tanggal', T0.[DocNum] as 'No.Faktur', T1.[ItemCode] as 'Kode Barang',
    T1.[Dscription] as 'Deskripsi', T1.[Quantity] as 'Quantity', ((T1.[LineTotal])/(T1.[Quantity])) as 'Harga
    Satuan', T1.[LineTotal] as 'Harga Total', T3.[CalcPrice] as 'HPP Satuan', ((T3.[CalcPrice]) * (T1.
    [Quantity])) as 'HPP Total', T4.[ItmsGrpNam] as 'Jenis Barang', T5.[SlpName] as 'Nama Sales', T1.
    [WhsCode] as 'Kode Gudang' FROM [dbo].[OINV] T0 INNER JOIN [dbo].[INV1] T1 ON T0.DocEntry =
    T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode INNER JOIN OINM T3 ON T2.ItemCode
    = T3.ItemCode INNER JOIN OITB T4 ON T2.ItmsGrpCod = T4.ItmsGrpCod INNER JOIN OSLP T5 ON
    T0.SlpCode = T5.SlpCode WHERE T3.[TransType] = '13' and T3.[CreatedBy] = T1.[DocEntry] and T0.
    [DocDate] >=[%0] and T0.[DocDate] <=[%1] and T4.[ItmsGrpNam] =[%2] and T1.[WhsCode] =[%3]
    Is it possible if I just take one invoice with invoice quantity and only show up at once although I have a
    lot item cost for that item? (because I'm using FIFOmethod).
    Please help me.. cause I'm stuck with this thing :l.
    Thank you very much, and I'm waiting your respon soon.
    Regards,
    Sisca

    Try this one:
    SELECT distinct T0.DocDate as 'Tanggal', T0.DocNum as 'No.Faktur', T1.ItemCode as 'Kode Barang',
    T1.Dscription as 'Deskripsi', T1.Quantity as 'Quantity', ((T1.LineTotal)/(T1.Quantity)) as 'Harga
    Satuan', T1.LineTotal as 'Harga Total', T3.CalcPrice as 'HPP Satuan', ((T3.CalcPrice) * (T1.
    Quantity)) as 'HPP Total', T4.ItmsGrpNam as 'Jenis Barang', T5.SlpName as 'Nama Sales', T1.
    WhsCode as 'Kode Gudang'
    FROM dbo.OINV T0 INNER JOIN dbo.INV1 T1 ON T0.DocEntry =T1.DocEntry
    INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode
    INNER JOIN OINM T3 ON T2.ItemCode = T3.ItemCode AND T3.TransType = '13' and T3.CreatedBy = T1.DocEntry AND T3.Warehouse = T1.WhsCode
    INNER JOIN OITB T4 ON T2.ItmsGrpCod = T4.ItmsGrpCod
    INNER JOIN OSLP T5 ON T0.SlpCode = T5.SlpCode
    WHERE T0.DocDate >=[%0\] and T0.DocDate <=[%1\] and T4.ItmsGrpNam =[%2\] and T1.WhsCode =[%3\]
    Thanks,
    Gordon

  • How can i assign a Javascript variable to JSP variable

    Hi guys
    how i can assign a javascript variable to jsp expression.,
    e.g.,
    <input type = "button" value = "Add more" onclick = "return submitform1('<%=s%>')">
    function submitform1(String s)
          var s1 = s
    document.form1.action = "../intimation.do";    /* Here i want to pass the value s1 to jsp or servlets without using hidden fields and Query string*/
           document.form1.submit();
          return false;
    /*  i want to pass the values thru session whether it is possible */
    pls give sample code
    Reply
    Marimuthu

    You don't have the session.
    All you have is HTTP.
    The only way to communicate from the client to the server is via an HTTP request. The only way to send a value like that is with a parameter.
    Using a form with method="submit" as mentioned will pass the parameters without displaying them in the url bar (is that what you wanted?)

  • How to get record count value in variable

    Hi,
    i wanted to capture record count value in the variable?
    Please let me know how to do this?
    Thanks,
    jag

    To determine count of records, use: count(field_name) -- replace field_name with your appropriate field.
    You don't have to save the record count value in a variable. You can directly use the condition <?if: count(field_name) > 0?> display table <?end if?>
    If you want to store it in a variable: use <?variable:record_cnt;count(field_name)?>
    Take a look at this post that uses a record count: https://blogs.oracle.com/xmlpublisher/entry/no_data_found
    Thanks,
    Bipuser

  • How to get table headers in jsp page

    hi,
    this is praveen, can any one help me to solve this problem.
    how to get table headers in a jsp page. whether it is possible using javascript or is there any other way.
    pls send rep.
    thank u.

    Hai ,
    I Think  This will help ful for u check it ,
    File=new FileLog("f:/WebServiceTrace/trace2.%g.log", 800000, 10,                                        new  TraceFormatter());
    The above code specifies the path for your log file.
    Then add this file as a log location and then log the traces. For this you can use the following code like:
    Location location=Location.getLocation(className);
              location.addLog(file);
              location.setEffectiveSeverity(Severity.ALL);
              location.entering(methodName);
    To Create j2ee apllication
    In path new-j2ee-jsp to create JSP's can only be used for J2EE applications.
    So as you are using this in Portal Application, this does not work.
    You can test this bahavior by creating a new Web Application (New-Project-J2EE-Web Module Project)
    In this Web Module Project, try creating JSP, this will work.
    So dont use new-j2ee-jsp to create JSP in Portal Application instead use New-File and name the file as jsp.
    Regards ,
    venkat

  • How to get ep authority in jsp page

    Hi all:
    I want to create a j2ee project and some jsp pages to deploy to EP server.
    My question is how to get user name or user authority in jsp page.
    Is there any APIs to use or something else.
    Thanks in advance.
    Allen

    Hai ,
    I Think  This will help ful for u check it ,
    File=new FileLog("f:/WebServiceTrace/trace2.%g.log", 800000, 10,                                        new  TraceFormatter());
    The above code specifies the path for your log file.
    Then add this file as a log location and then log the traces. For this you can use the following code like:
    Location location=Location.getLocation(className);
              location.addLog(file);
              location.setEffectiveSeverity(Severity.ALL);
              location.entering(methodName);
    To Create j2ee apllication
    In path new-j2ee-jsp to create JSP's can only be used for J2EE applications.
    So as you are using this in Portal Application, this does not work.
    You can test this bahavior by creating a new Web Application (New-Project-J2EE-Web Module Project)
    In this Web Module Project, try creating JSP, this will work.
    So dont use new-j2ee-jsp to create JSP in Portal Application instead use New-File and name the file as jsp.
    Regards ,
    venkat

  • How to get result from another JSP file?

    I have to write a jsp (my.jsp) to get information from another jsp file (other.jsp).
    The other.jsp return integer value (0 / 1) so that user can tell if certain service is available or not. And in my.jsp I need to collect such result and other information from a text file to make up of a XML string.
    How can I call other.jsp to get the result? Thanks a lot.

    Hi, I think I didn't describe the problem clearly
    enough. In fact, there is a JSP file, and if our
    database is currently connected, the JSP will return
    value 1, otherwise, it will return 0. My java program
    need to get that result, and then form an XML string,
    and send the string back to the client. I'm just
    wonder how can I write such a program to read result
    from JSP file. Thanks a lot.Why is this function implemented as a JSP file? It should be implemented as a bean. It would be simple to get the information you require from that bean.

  • How to get Javascript plugin?

    I cannot load images into a layered stack in Photoshop. The error message says it's because I don't have the Javascript plugin. I have Java installed, but I don't see how to get the plugin.

    Good day!
    Java and JavaScript are not identical.
    http://en.wikipedia.org/wiki/Javascript
    Please read this and proceed accordingly as you have not even given information about version or OS:
    http://forums.adobe.com/thread/419981?tstart=0
    Regards,
    Pfaffenbichler

  • How to get the querystring in jsp

    hi guys
    plz help me,
    how to get the query string in jsp page, is there any methods for getting querstring like getString() getParameter() ?

    C:\Documents and Settings\Administrator\ven\build\generated\src\org\apache\jsp\getcustomer_jsp.java:62: getQueryString() in javax.servlet.http.HttpServletRequest cannot be applied to (java.lang.String)
    i am getting error like this , if i used that method, shall i import any packages?

  • How To get getServletContext() object inside JSP from  Eclipse  IDE

    Dear friends,
    I can access methods in getServletContext class from Netbeans in my JSP web project using the following steps.
    String path=getServletContext().getRealPath("\mypath");
    . But In Eclipse when i try to build,it says that "can not find method -getServletContext()".
    How to get this object in my JSP Scriptlet From Eclipse IDE? Plz help me?

    use Expression Language instead.
    I would.
    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSPIntro7.html
    regards,i

Maybe you are looking for

  • Keyboard no longer works in finder

    my keyboard works in any application except finder, mouse still works, just can't type anything, such as re-naming a folder. Dual 1GHz Mirror   Mac OS X (10.4.3)  

  • Problem with alerts via mail

    Hi everybody. I' ve customized an alert  to receive a mail when the mapping fails in a intefase. At first time when the error ocurred i could see in the integration engine monitor that the interfase had an error and i recived a mail to inform me abou

  • Editing Code in Dreamweaver

    I started out designing my website in dreamweaver but then switched to Microsoft Expression. After working with ME for a while, I want to go back to dreamweaver. For some reason, the code does not load up properly in dreamweaver when doing the split

  • Clustering a JMS Topic

    I'm trying to create a distributed JMS topic using the wlconfig ant task (MBean). I can create a topic on a single server fine, but I can't figure out how to create a distributed topic that I could access on any server in the cluster. This is what I

  • Firefox focus issues

    Hi! I have a sometimes very irritating problem with Firefox. I have a Logitech G7 mouse with a tiltable wheel that I've set up to change tabs in forefox, and a sidebutton that I use to close tabs with. I'm just using xbindkeys to bind the mouse butto