How to pass javascript variable to jsp function

i want to check which table header (that is <th> in html )is clicked and based on that a jsp funtion do a query in database and should show records in sorted way according to which column head is clicked.
Table is created in html.
My function is
Vector varray = workcaseid.getWorkcaseId(Long.parseLong(MasterAccountNumber),SelectedColumn);
<table border="1">
          <th ><label onClick="<%SelectedColumn="workcase_id";%>">Workcase Id</label></th>
          <th><label onClick="<%SelectedColumn="status_id";%>">Status</label></th>
<tr><td>etc</td></tr>
</table>

im using bean for business login, following mvc model,and i think mvc is one of good design practice to use.
<jsp:useBean id="workcaseid" scope="session"class="beanFiles.SearchWorkcaseId" />
varray = workcaseid.getWorkcaseId(Long.parseLong(MasterAccountNumber),SelectedColumn);
just tell me whether it is possible to pass javascript variable to jsp variable or not.i can do it by using hidden input type,using form and submit button.

Similar Messages

  • How tp pass javascript variables/arrays to a servlet?

    Plz help me in passing javascript variables/arrays to a servlet

    Hi,
    I am creating table rows & columns containg text fields dynamically as follows:
    function addRowToTable()
    var tbl = document.getElementById('tblSample');
    var lastRow = tbl.rows.length;
    // if there's no header row in the table, then iteration = lastRow + 1
    var iteration = lastRow;
    var row = tbl.insertRow(lastRow);
    // right cell
    var cellRight = row.insertCell(0);
    var el = document.createElement('input');
    el.type = 'text';
    el.name = 'txtRow' + iteration;
    el.id = 'txtRow' + iteration;
    el.size = 20;
    cellRight.appendChild(el);
    Now i am calling function addRowToTable() from jsp page as + key is pressed to add rows dynamically.
    So as per rows different textfields are also getting created dynamically with different id & name.
    Now i am getting session attributes containing the values for textfields from servlet.
    but i am not able to map the values for dynamic textfields getting created?
    I want to print values in appropriate fields.
    Plz help me.

  • How to use session variable in JSP function  & How to use both JSP  Servlet

    Hi,
    I am new to JSP and servlets
    Still I am devloping a website in JSP. I am not mixing JSP with servlets, but I do create Java files for bean, logic and database works.
    I try to keep the hard coding part out of JSP.
    I dont how to use both JSP and Servlets in combination.
    Hence If needed I write some functions in JSP.
    but it gives me error
    +<%! public void abc()+
    +{+
    int intUserId = Integer.valueOf((Integer) session.getAttribute("MySession_UserID"));
    +}+
    +%>+
    Saying cannot find symbol session
    1) So can u please tell how can I access session variables within JSP function
    2) And also give me some links/tutorials about useing both JSP and Servlets in combination.
    Thanks
    Venkat

    The application architecture when you use Servlets and JSP in a standard MVC pattern is explained here (under the heading "Integrating Servlets and JSP Pages") and here ...

  • Need a fast answer... passing javascript variable to jsp page (how to use)

    This test application has 3 frames.
    I'm assigning a value "stuff" to a variable ("testfield1") in a javascript function ("getTest") that exists inside an html frame (testpage1.html)
    Then, I click on the "test submit" hypertext link to pass the value of "testfield1" to the JSP frame (testpage2.jsp) by invoking a function ("getData") in "testpage2".
    In function ("getData"), I am passing the variable "testfield1" as a parameter to the "getData" function in "testpage2".
    In "testpage2" - in the ("getData" function) I try to assign the value of the variable "testfield1" to another variable called "testfld1".
    Then, I try to extract the value of "testfld1" into a variable called "tstfld1" in a JSP scriptlet
    ....I.E. [ String tstfld1  = request.getParameter("testfld1");  ]
    But, the value is apparently not passed successfully, as tstfield1 appears to be "null".
    Can anyone explain what I'm doing incorrectly?
    The code for this test app is below...
    ********testpage0 - the parent frame*********
    <HTML>
    <HEAD>
    <TITLE>GlobalView Reports and Trending Menubar</TITLE>
    </HEAD>
    <FRAMESET FRAMEBORDER="0" ROWS="15%,85%">
    <FRAME SRC="testpage0.html" NAME="testhtmlparent">
    <FRAMESET FRAMEBORDER="0" COLS="23%,77%">
    <FRAME SRC="testpage1.html" NAME="testhtml">
    <FRAME SRC="testpage2.jsp" NAME="testjsp">
    </FRAMESET>
    </FRAMESET>
    </HTML>
    *******testpage1.html********
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <html>
         <head><title>testpage1</title>
         <link rel="stylesheet" type="text/css" href="./standard.css">
              <script LANGUAGE="JavaScript">
              parent.frames[2].location = "blank.html";
              function getTest(reportType)
                   testfield1 = "stuff";
                   alert("testpage1.html...testfield1=" + testfield1 + ", reportType=" + reportType);
                   parent.frames[2].location = "testpage2.jsp";
                   parent.frames[2].getData(testfield1);
                   return;
              </script>
         </head>
         <body bgcolor="#FFFFFF" text="#000000">
              <form name="reportRange">
                   <center>
                        <fieldset style="padding: 0.5em" name="customer_box">
                        <table cellpadding="0" cellspacing="0" border="0">
                             <tr class="drophead">
                                  <td valign="top" height="0" ><span class="drophead">
                                       test submit
                                  </td>
                             </tr>
                        </table>
                        </fieldset>
                   </center>
              </form>
         </body>
    </html>
    *******testpage2.jsp*********
    <%@ page language="java" import="java.io.*, java.util.*" errorPage="error.jsp" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <html>
         <head>
         <title>testpage2</title>
         <script language="JavaScript">
              function getData(testfield1)
                   alert("testpage2.jsp...testfield1=" + testfield1);
                   document.pageData.testfld1.value = testfield1;
                   document.pageData.submit();
         </script>
         </head>
         <body>
              <%
                   String error;
              %>
              <div id="HiddenForm">
                   <form name="pageData" method="post" action="testpage2.jsp" target="_self">
                   <input type="hidden" name="testfld1" value="0">
              </form>
              </div>
              <%
                   String tstfld1 = request.getParameter("testfld1");
              %>
              <P> testfld1 = <%= tstfld1 %> </P>
         </body>
    </html>

    parent.frames[2].getData(testfield1); is in testpage1.html
    so in the document.pageData.testfld1.value = testfield1; document = testpage1.html( not testpage2.html)
    modifying the getData to accept the document object, and refering this object to parent.frames[2].document may help you.
    good Luck ....

  • How to pass javascript variable to PLSQL stored procedure

    Hi,
    How can I pass a javascript variable to a database procedure. I have a form with a radio button group and would like to save the value of the selected radio button to a database table by passing the value to the stored procedure.
    Thanks

    Hi
    You can use iframe to call the procedure. Here is an example used in dynamic page or pl/sql portlet. The pl/sql procedure is called myprocedure and resists in the schema myschema. This example passes 2 parameters, but I have not yet reased a limit.
    First the call within a javascript function:
    myiframe.location.href="myschema.myprocedure?p_myprameter1=" + vJvascriptparameter1 + "&p_myprameter2=" + vJvascriptparameter2;
    Then the iframe:
    <iframe id="myiframe" height="0" width="0" frameborder="0"></iframe>
    You can let the pl/sql procedure print a value, that can be used i the portlet. You can get the value in a javascript this way:
    myvalue=top.window.frames["myiframe"].document.body.innerHTML;
    Best regards
    Klaus

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

  • How to pass javascript variables into an Edge Animate project from HTML

    I have just about got the basics nailed for Edge Animate now - coming from a Flash background it's been fairly straight forward, nice work so far (but more on that later)
    I have had to build a "promoted items" slider for the homepage on one of our sites....previously this would have been a flash animation but, hey ho .
    I originally built it as a jQuery extension/plugin but found it too time consuming to make minor alterations - that's where Edge came in and SEEMED to fill the job pretty well.
    Now for the moment i'll put on hold the whole issue about how we NEED to be able to work with dom-level elements directly on the page (eg, animating divs and images within a ul-li structure which is how these things usually work) and concentrate on the Edge specific issue...
    I've seen a few people asking this same question, but none of the answers either a) work at all for me , or b) are good enough for what I need to do.
    see previous solutions here http://support.muse.adobe.com/message/4658175 and here : http://forums.adobe.com/thread/1065343
    My project uses an internal array of data, and while in "preview" mode it works reasonably well.
    in the Stage creationComplete event i have Edge code like, for example :
       var imagesArray = ["images/img1.jpg", "images/img2.jpg", "images/img3.jpg"];
       var headlinesArray = ["product 1", "product 2", "product 3"];
       var subTxtArray = ["lovely widgets", "smelly doo-dads", "purple whatchamacallits"];
       var linksArray = ["http://www.adobe.com", "http://www.adobe.co.uk", "http://www.adobe.net"];
       //variables set to full internal scope, used immediately after this and called from sub-elements afterwards
       sym.getComposition().getStage().setVariable("imagesArrayData", imagesArray);
    this code obviously needs to be changed via the HTML page that is calling it.
    IDEALLY i would have these elements already on the page ( <div><h1>Product 1</h1><img src="....  etc ) and then jquery it to hell to make it look funky. This is how we NEED to be doing it in the future...that way our content is still searchable and findable by search bots etc. Edge will output a "static" version of the page, i tried that, but it won't work for dynamically built objects. There's no way i've found of building an array of Symbols based on the existing DOM structure like you can do in jQuery itself.
    however, in the meantime i'll settle for being able to set a javascript call up somewhere - like the old flashvars solution (which was horrible fudge, but worked as a way to get data into a project )
    i'd REALLY rather not use an internal jSon call .... it's adding uneccessary bandwidth and additional server processing when the data it needs has already been retrieved from the database when the HTML page is drawn - AND it means i need to make sure that the json producing web service gets ported accross to any other projects that use this same "slider"
    i've tried removing the internal declaration and changing my HTML to :
    <script>
    var imagesArray = ["images/img1.jpg", "images/img2.jpg", "images/img3.jpg"];
       var headlinesArray = ["product 1", "product 2", "product 3"];
       var subTxtArray = ["lovely widgets", "smelly doo-dads", "purple whatchamacallits"];
       var linksArray = ["http://www.adobe.com", "http://www.adobe.co.uk", "http://www.adobe.net"];
    </script>
    <!--Adobe Edge Runtime-->
         <script type="text/javascript" charset="utf-8" src="index_edgePreload.js"></script>
    etc
    but this hasn't worked.
    i'm going to attempt the solution using
    AdobeEdge.bootstrapCallback(function(compId) { ....
    as found on http://forums.adobe.com/thread/1065343
    but this doesnt explain how to set up Stage level variables, rather than targeting a specific Edge property
    Anyone got any ideas? Or do I just scrap the project?
    IMHO : Adobe need to be careful of falling into the same mindset that most of the anti-flash brigade have.
    Please remember that Flash is used for WAY more than just adverts.
    At the moment, Edge will work great as a way to put a simple animation onto the page with REALLY basic interactivity - suitable for a basic advert - but we need our HTML5 animations and scripts to be fully dynamic, data-driven, and portable, and preferably using existing DOM elements.
    One last thing, any chance of a feature to say "my page already uses jQuery, don't import Edge's own outdated version"
    Message was edited by: j1mp

    I have just about got the basics nailed for Edge Animate now - coming from a Flash background it's been fairly straight forward, nice work so far (but more on that later)
    I have had to build a "promoted items" slider for the homepage on one of our sites....previously this would have been a flash animation but, hey ho .
    I originally built it as a jQuery extension/plugin but found it too time consuming to make minor alterations - that's where Edge came in and SEEMED to fill the job pretty well.
    Now for the moment i'll put on hold the whole issue about how we NEED to be able to work with dom-level elements directly on the page (eg, animating divs and images within a ul-li structure which is how these things usually work) and concentrate on the Edge specific issue...
    I've seen a few people asking this same question, but none of the answers either a) work at all for me , or b) are good enough for what I need to do.
    see previous solutions here http://support.muse.adobe.com/message/4658175 and here : http://forums.adobe.com/thread/1065343
    My project uses an internal array of data, and while in "preview" mode it works reasonably well.
    in the Stage creationComplete event i have Edge code like, for example :
       var imagesArray = ["images/img1.jpg", "images/img2.jpg", "images/img3.jpg"];
       var headlinesArray = ["product 1", "product 2", "product 3"];
       var subTxtArray = ["lovely widgets", "smelly doo-dads", "purple whatchamacallits"];
       var linksArray = ["http://www.adobe.com", "http://www.adobe.co.uk", "http://www.adobe.net"];
       //variables set to full internal scope, used immediately after this and called from sub-elements afterwards
       sym.getComposition().getStage().setVariable("imagesArrayData", imagesArray);
    this code obviously needs to be changed via the HTML page that is calling it.
    IDEALLY i would have these elements already on the page ( <div><h1>Product 1</h1><img src="....  etc ) and then jquery it to hell to make it look funky. This is how we NEED to be doing it in the future...that way our content is still searchable and findable by search bots etc. Edge will output a "static" version of the page, i tried that, but it won't work for dynamically built objects. There's no way i've found of building an array of Symbols based on the existing DOM structure like you can do in jQuery itself.
    however, in the meantime i'll settle for being able to set a javascript call up somewhere - like the old flashvars solution (which was horrible fudge, but worked as a way to get data into a project )
    i'd REALLY rather not use an internal jSon call .... it's adding uneccessary bandwidth and additional server processing when the data it needs has already been retrieved from the database when the HTML page is drawn - AND it means i need to make sure that the json producing web service gets ported accross to any other projects that use this same "slider"
    i've tried removing the internal declaration and changing my HTML to :
    <script>
    var imagesArray = ["images/img1.jpg", "images/img2.jpg", "images/img3.jpg"];
       var headlinesArray = ["product 1", "product 2", "product 3"];
       var subTxtArray = ["lovely widgets", "smelly doo-dads", "purple whatchamacallits"];
       var linksArray = ["http://www.adobe.com", "http://www.adobe.co.uk", "http://www.adobe.net"];
    </script>
    <!--Adobe Edge Runtime-->
         <script type="text/javascript" charset="utf-8" src="index_edgePreload.js"></script>
    etc
    but this hasn't worked.
    i'm going to attempt the solution using
    AdobeEdge.bootstrapCallback(function(compId) { ....
    as found on http://forums.adobe.com/thread/1065343
    but this doesnt explain how to set up Stage level variables, rather than targeting a specific Edge property
    Anyone got any ideas? Or do I just scrap the project?
    IMHO : Adobe need to be careful of falling into the same mindset that most of the anti-flash brigade have.
    Please remember that Flash is used for WAY more than just adverts.
    At the moment, Edge will work great as a way to put a simple animation onto the page with REALLY basic interactivity - suitable for a basic advert - but we need our HTML5 animations and scripts to be fully dynamic, data-driven, and portable, and preferably using existing DOM elements.
    One last thing, any chance of a feature to say "my page already uses jQuery, don't import Edge's own outdated version"
    Message was edited by: j1mp

  • How to pass  JavaScript variable value throuh netui form ??

    Hi All,
    I have reqmnt,where in I need to pass the value from JavaScript function through
    Form submission.
    I could able to pass this through simple HTML form using SIMPLE HTML tags. How
    can i do the same thing using NETUI tag (NETUI form)??
    Can somebody throw some input on this??
    TIA,
    RAM.

    Excellent - Thats what I was also looking.
    RAM.
    Thomas Cook <[email protected]> wrote:
    >
    Here's an example of what I think you're trying to do:
    <netui:html>
    <body>
    <netui:form action="submitIt" tagId="myForm">
    <netui:button value="Submit It" onClick="return setFormValue()"/>
    <script>
    function setFormValue()
    var form = document.getElementById( getNetuiTagName( "myForm",
    this ) );
    var newVal = document.createElement( "input" );
    newVal.type = "hidden";
    newVal.name = "foo";
    newVal.value = "bar";
    form.appendChild( newVal );
    return true;
    </script>
    </netui:form>
    </body>
    </netui:html>
    Thomas
    RAMt wrote:
    Hi All,
    I have reqmnt,where in I need to pass the value from JavaScript functionthrough
    Form submission.
    I could able to pass this through simple HTML form using SIMPLE HTMLtags. How
    can i do the same thing using NETUI tag (NETUI form)??
    Can somebody throw some input on this??
    TIA,
    RAM.
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
    <title></title>
    </head>
    <body>
    Here's an example of what I think you're trying to do:<br>
    <br>
    <tt><nobr><netui:html></nobr><br>
    <nobr>  <body></nobr><br>
    <nobr>    <netui:form action="submitIt" tagId="myForm"></nobr><br>
    <nobr>    <netui:button value="Submit It" onClick="return
    setFormValue()"/></nobr><br>
    <nobr>    <script></nobr><br>
    <nobr>      function setFormValue()</nobr><br>
    <nobr>      {</nobr><br>
    <nobr>          var form
    = document.getElementById( getNetuiTagName(
    "myForm", this ) );</nobr><br>
    <nobr>          var newVal
    = document.createElement( "input" );</nobr><br>
    <nobr>          newVal.type
    = "hidden";</nobr><br>
    <nobr>          newVal.name
    = "foo";</nobr><br>
    <nobr>          newVal.value
    = "bar";</nobr><br>
    <nobr>          form.appendChild(
    newVal );</nobr><br>
    <nobr>          return true;</nobr><br>
    <nobr>      }</nobr><br>
    <nobr>    </script></nobr><br>
    <nobr>    </netui:form></nobr><br>
    <nobr>  </body></nobr><br>
    <nobr></netui:html></nobr></tt><br>
    <br>
    Thomas<br>
    <br>
    RAMt wrote:
    <blockquote cite="[email protected]" type="cite">
    <pre wrap="">Hi All,
    I have reqmnt,where in I need to pass the value from JavaScript function
    through
    Form submission.
    I could able to pass this through simple HTML form using SIMPLE HTML
    tags. How
    can i do the same thing using NETUI tag (NETUI form)??
    Can somebody throw some input on this??
    TIA,
    RAM.
    </pre>
    </blockquote>
    </body>
    </html>

  • Get javascript variable in JSP

    Hi all,
    can anybody tell me- how to get javascript variable in JSP,
    in the same file (JSP).
    Is this possible.
    I can use JavaScript to get the value,
    but then I have no way to get that to the JSP code.
    Please give the appripriate answer with code.
    Thanks
    amitindia

    Hi all,
    Thanks for your quick response.
    So u are right that we can not call javascript variable
    in the same JSP. and pass them to the bean class.
    So what I did --- I get java script variable in another JSP using
    request.getParameter(); and then redirected to previous JSP.
    and I have solve my problem.
    Actually I had to call bean class and pass varible to the bean
    method but I was getting the same problem that I disscussed but now it
    has been solved.
    Thanks again for participation
    amitindia

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

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

  • How to  pass a variable value into a custom planning function via a web

    Can some one tell me
    How to  pass a variable value into a custom planning function via a web template?
    What are the different types of Planning function parameters available and what is the difference between them?
    Thanks
    babu

    Hi Sutrtha,
    Yeah I got the pop up asking to select the variables used, I have selected ENTITY_ID that was used by the interfaces, but on execution of the package the Scenario did not work as the passeed variable #ENTITY_ID is set to 0 instead of the value I am passing.
    Am I missing something?
    Regards
    B

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

Maybe you are looking for