Javascript to JSP question...Can javascript function set session attributes

hello,
i have a web app that, on one of its pages, displays "tabbed pane" as an image map at the top (a la amazon.com). my problem is this: each "logical" page contains separate forms that all use the same javabean. in other words, imagine that the tabs represent an account maintenance web ui for an on-line record store. the first tab might be labeled "General," the second "Contact info," the third "Shipping Info." Each uses the same account bean and displays portions of its properties relevant to the tab at hand. what i want to do is allow a user to enter the account maintenance ui, update info on the first tab, click on tab two and have the request with the changes sent to a processing jsp. yet, since each "tab" is actually a separate URL to another page, how do i get the updated info on the first tabe without adding some sort of "SAVE" button on each tab. ive considered using javascript, but dont know how to get the request params out of the first tab whn i click on another tab. is it possible to include an "onClick" function in each URL that "grabs" the updated form fields off the preceeding tab? can a javacript function set session attributes in jsp?

hello there,
wow, you've created one big mammy-jammy tool.
first, javascript cannot access, set values to the session, without having to post to another JSP. javascript is great for manipulating objects, layers, form values, etc.
you have 2 issues [if i understand correctly]:
1) you need to able to save user info for a specific tab without having to reloading the page.
---you can create a form for EACH of your tabs and POST all the information to a hidden IFRAME or LAYER for NN4. that hidden IFRAME / LAYER will load a JSP page which with all the parameters you posted to it. or you can build a FRAMESET and target that document["frame-name"].src with that same JSP.
2) handling when the SAVE INFO action should happen: hence some javascript event handler: onMouseOver, onClick, etc
---i don't know the dynamics of your tabs, but if store which tab was clicked on last, then if the user clicks on some other tab, javascript can submit that FORM to a JSP [see condition above]
you have an interesting tool. can i see?
i hope i wasn't too confusing, but your problem is sooo interesting. =)
-WJP

Similar Messages

  • How to set session attributes in a bean?

    How do I set a session attribute in a server-side bean?
    I'm not sure if I asked the question the right way. What I meant is, while it's easy to set session attributes in a JSP page (session.setAttribute("sessionname", "sessionvalue")), I'd want to set such an attribute within a server-side bean defined in this web application. But what is the syntax for doing it?

    Here a simple bean that stores something in the session and retrieves something from it.
    import javax.servlet.http.HttpSession;
    public class TestBean {
      private String value;
      public void doSomething(HttpSession session, int a, int b) {
        if (a+b > 0) {
          session.setAttribute("ab",Boolean.TRUE);
        } else {
          session.setAttribute("ab",Boolean.FALSE);
      public void init(HttpSession session) {
        if (session != null) {
          Boolean b = (Boolean)session.getAttribute("ab");
          if (b == Boolean.TRUE) {
            value = "a + b is greater than zero";
          } else {
            value = "a + b is not greater than zero";
        } else {
          value = "no session";
      public String getValue() {
        return value;
    }In your JSP, use something along the lines of :
    <%
      TestBean bean = new TestBean();
      bean.init(session);
      bean.doSomething(session,1,2);
    %>If your bean only lives during one request, you can pass the session to the constructor, which stores it in a private variable. This saves passing the session each time.
    Hope this helps,
    --Arnout                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How can I flag HTTP session attributes to not be replicated ?

              WLS 5.1 SP8 - In memory replication of a stateful servlet. Is
              there any way to flag data that has been, or is being, loaded into
              a HTTP session so as to not be replicated ? It's a long story,
              but we have some data loaded into a hashtable, more specifically
              a Properties object, stored in our session. With the hastable
              already loaded into the HTTP session, weblogic does not detect
              when we add values to the table, and therefore does not replicate
              the changes. Which is ok since WLS is working as designed. To
              get around this we load the hashtable back into the session everytime
              we add a value to the hashtable. Yup, I know that's ugly. Anyway,
              what I'm trying to find out if is there is an attribute that we
              can set to indicate, to not replicate this data or that data.
              Something along the lines of a attribute on a per hastable value
              basis. For example, I load value A into my hashtable, then I
              need to put my hashtable into the session to get it replicated.
              Next I load value B into the hastable, and again to get it replicated
              I have to load the entire hashtable back into the session. The
              problem here is that the entire table gets replciated. Does anyone
              know if I can set an attribute on value A, when I'm adding value
              B, so as to not replicate value A when I reload the table ? Of
              course all goal is to not store so much data in the session, but
              I'm trying to find a work around until that is completed.
              Thanks,
              David
              

              Where can I find documentation on the details of how Weblogic decides what will
              be replicated in the HTTPSession object (for example, it only replicates attributes
              which are set or updated using "setAttribute()"?
              Prasad Peddada <[email protected]> wrote:
              >Robert,
              >
              > It is true that we replicate only when you call setAttribute in case
              >of servlets.
              >
              >In case of EJB it is slightly different. EJB sends diff's across the
              >wire. It doesn't
              >replicate the entire state with every request.
              >
              >-- Prasad
              >
              >Chris Palmer wrote:
              >
              >> I think Viresh was referring to modifying part of one attribute causing
              >the whole
              >> of that attribute (i.e. the hashtable) to be replicated.
              >>
              >> Is it actually true though that the behaviour would be different in
              >a stateful
              >> session EJB? I had assumed that the WHOLE ejb state would be replicated
              >each time
              >> (i.e. after each invocation), without even the benefit of having a
              >mechanism such
              >> as setAttribute() to flag the attributes that had changed...
              >>
              >> Chris
              >>
              >> Robert Patrick wrote:
              >>
              >> ? Huh? Since when does it always replicate the entire HttpSession?
              > We were
              >> ? told that it uses a hook in the setAttribute() call to determine
              >which
              >> ? attributes have changed and only replicates those attributes. I
              >know this to
              >> ? be the case because if I retrieve a previously stored attribute from
              >the
              >> ? HttpSession and modify it, my changes do not get replicated unless
              >I call
              >> ? setAttribute again...
              >> ?
              >> ? Robert
              >> ?
              >> ? Viresh Garg wrote:
              >> ?
              >> ? ? Servlet sessions don't work on diffs, so no matter what you do,
              >entire
              >> ? ? Hashtable will be replicated. If you want the optimization for
              >only
              >> ? ? replicating the diff ( the stuff that has changed between 2 updates)
              >,
              >> ? ? consider using stateful session bean and having hashtable part
              >of
              >> ? ? conversational state of stateful session bean.
              >> ? ?
              >> ? ? The solution that you suggested on your own for your problem is
              >not ugly
              >> ? ? as the same solution is used by many customers that I know of.
              >This is
              >> ? ? particularly a problem for people that use Java Beans and use the
              >set
              >> ? ? Property directive of Java Bean in JSP. There also in our auto
              >generated
              >> ? ? code, we put the JavaBean back in HTTP Session, when a setter is
              >called to
              >> ? ? enforce replication.
              >> ? ?
              >> ? ? Keep in mind that whatever we do for replication, we want to support
              >it
              >> ? ? using ONLY standard servlet API and we don't want to introduce
              >any WLS
              >> ? ? specific API to achieve this, and so putting value back in session
              >is the
              >> ? ? only way.
              >> ? ?
              >> ? ? Viresh Garg
              >> ? ? Principal Developer Relations Engineer
              >> ? ? BEA Systems
              >> ? ?
              >> ? ? Dave Javu wrote:
              >> ? ?
              >> ? ? ? WLS 5.1 SP8 - In memory replication of a stateful servlet.
              >Is
              >> ? ? ? there any way to flag data that has been, or is being, loaded
              >into
              >> ? ? ? a HTTP session so as to not be replicated ? It's a long story,
              >> ? ? ? but we have some data loaded into a hashtable, more specifically
              >> ? ? ? a Properties object, stored in our session. With the hastable
              >> ? ? ? already loaded into the HTTP session, weblogic does not detect
              >> ? ? ? when we add values to the table, and therefore does not replicate
              >> ? ? ? the changes. Which is ok since WLS is working as designed.
              >To
              >> ? ? ? get around this we load the hashtable back into the session everytime
              >> ? ? ? we add a value to the hashtable. Yup, I know that's ugly.
              >Anyway,
              >> ? ? ? what I'm trying to find out if is there is an attribute that
              >we
              >> ? ? ? can set to indicate, to not replicate this data or that data.
              >> ? ? ? Something along the lines of a attribute on a per hastable value
              >> ? ? ? basis. For example, I load value A into my hashtable, then
              >I
              >> ? ? ? need to put my hashtable into the session to get it replicated.
              >> ? ? ? Next I load value B into the hastable, and again to get it replicated
              >> ? ? ? I have to load the entire hashtable back into the session. The
              >> ? ? ? problem here is that the entire table gets replciated. Does
              >anyone
              >> ? ? ? know if I can set an attribute on value A, when I'm adding value
              >> ? ? ? B, so as to not replicate value A when I reload the table ?
              >Of
              >> ? ? ? course all goal is to not store so much data in the session,
              >but
              >> ? ? ? I'm trying to find a work around until that is completed.
              >> ? ? ? Thanks,
              >> ? ? ? David
              >
              

  • How can I pass the session attributes to other applications?

    I need to pass a value across the web application. Is it possible?
    I use Forward to redirect the page in JPF. Before redirection, I set some attribute/value in session. In new application, I found the atttribute value is null. Is there a way to pass the value between web applications.
    Thanks in advance.

    Hi,
    Two different Webapps doesn't share the same session , they have two different. So as far as i known you have to use something like a db to pass variables or another common way. Maybe when you redirect you can store an atribute to the HttpRequest and get it in your other app.Something very simple is to fix the url like that
    http://www.mydomain.com/manager.jsp?passingAttribute=passingValue
    Hope that helps
    BR

  • Unable set session attribute with certain types.

    Hello I was surprise that when I execute HttpSession.setAttribute("somekey", new HashMap()), "somekey" will not be stored in the Session. I can replace HashMap with HashSet and it's okay.
              Out of curiosity, I create a Java class like below :
              public class abc implements Serializable {
              public String def = "def";
              And I have the same issue with HashMap and it will not get stored in the Session attribute. Does anyone know what kind of valid object and what makes the object storable into the Session's attribute? Any inputs are appreciated. Thanks.
              yien

    Actually never mind. It have something to do with BEA's Portal Ad services. I will post this into the appropriate forum.

  • Setting session attributes at the Role level

    I am running AM7.1 in Legacy mode and I am trying to create a role and assign session attributes at this role level. I followed the instructions for doing this but it does not seem to be working. I created the role and added the session service to it. I then went in an changed the attributes (Max Idle, Max Session, etc.) to the values I need for the role. I then assigned the role to a user. However when I log in as this user and look at the Active Sessions panel all of the values are still saying they are set at the defaults. It is not picking up the new values for the user. Am I missing something? Help! -Jeff

    Reply i was also getting this problem in relam mode but 7.0..........but when i specify in the url?role=rolename..........i see the session info applied but i wanted it to be dyanmically applied(without specifiying the role in the url).......i have raised an SR but that is for 7.0 .........please do it for 7.1 i think you might get some response.

  • Accessing session attribute in output jsp page

    Hi i am not getting any output in jsp page...
    i am getting just heading
    i think some problem with Session attribute..
    if so how to access session been in jsp page
    my code is here
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%--
    The taglib directive below imports the JSTL library. If you uncomment it,
    you must also add the JSTL library to the project. The Add Library... action
    on Libraries node in Projects view can be used to add the JSTL 1.1 library.
    --%>
    <%--
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    --%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Tauvex Search Output</title>
    </head>
    <body>
    Tauvex Search Output
    <table>
    <c:forEach items="${myDataList}" var="myData">
    <tr>
    <td>${myData.Fitsfilename}</td>
    <td>${myData.RA_START}</td>
    <td>${myData.RA_END}</td>
    <td>${myData.DEC_START}</td>
    <td>${myData.DEC_END}</td>
    <td>${myData.telescope}</td>
    <td>${myData.STARTOBS}</td>
    <td>${myData.ENDOBS}</td>
    <td>${myData.FILTER}</td>
    </tr>
    </c:forEach>
    </table>
    <%--
    This example uses JSTL, uncomment the taglib directive above.
    To test, display the page like this: index.jsp?sayHello=true&name=Murphy
    --%>
    <%--
    <c:if test="${param.sayHello}">
    <!-- Let's welcome the user ${param.name} -->
    Hello ${param.name}!
    </c:if>
    --%>
    </body>
    </html>
    plz reply soon
    thanks a lot

    this is what i set in servlet
    request.setAttribute("myDataList", myDataList);
    request.getRequestDispatcher("someJspFile.jsp").forward(request, response);
    how can i access that session attribute in jsp

  • Set OU Attribute via Script

    Is it possible to set the "ou" attribute of a computer object in AD via script?  That attribute is not listed as an option in Set-ADComputer and it doesn't auto-populate based on the OU the object is in.  How can I programatically set
    the attribute rather than modifying each individual object manually?

    You can populate it with Set-ADComputer.
    Set-ADcomputer -Identity xxx -add @{ou="yyy"}
    This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.
    Get Active Directory User Last Logon
    Create an Active Directory test domain similar to the production one
    Management of test accounts in an Active Directory production domain - Part I
    Management of test accounts in an Active Directory production domain - Part II
    Management of test accounts in an Active Directory production domain - Part III
    Reset Active Directory user password

  • Set jsp variable in javascript

    I have a simple question.
    I have a section in jsp as below
    <%!
    String initial = "true";
    %>
    Can I set the "initial" parameter in javascript function in the same jsp like below?
    function init() {
    <%! initial = "true"; %>
    If not, would you please give me the syntax to do it?
    Thanks in advance,
    Mustafa

    the jsp scriptlet code, everything in between your <% ... %> marks, is compiled on the server.
    the javascript code is run on the client.
    therefore, you can NOT edit the scriptlet code from javascript. it cannot be done.
    you CAN however edit your javascript code with the jsp scriplet. see the below example, which shows me setting a javascript variable based on some scriplet code...
    <% String name = "Joe Schmoe"; %>
    <script>
    function doSomething() {
    var something = '<%= name %>';
    </script>
    When that page is rendered it will look like this...
    <script>
    function doSomething() {
    var something = 'Joe Schmoe';
    </script>

  • Calling jsp file from javascript function

    How can i call a jsp file itself from javascript function written in it?

    I do not think you can invoke the current jsp directly using javascript.
    If the effect you are trying to achieve is to reload the page, then you could execute the servlet / code which called the current jsp.

  • Calling function of JavaScript from  jsp code

    I ve to call one jsp page from other so I need to call another page
    I m trying to do by writing a javascript code for submitting the page

    while redirecting the page when I am using
    request.getParameter of hidden objects in the
    previous page its not giving the correct valuesA redirect is different from a submit, in the sense that it will create a new Request object.
    If you want to pass parameters to the next page, you will have to pass them as part of the url:
    response.sendRedirect("http://myserver/mypage.jsp?param1=value1&param2=value2");And then in mypage.jsp, you can do:
    String value1 = request.getParameter("param1");

  • Can JavaScript access JSP variable?

    Could we do this? Or, how could we have JavaScript access JSP variable?
    <%
    String fooBar = request.getParameter(......
    %>
    <script language="JavaScript">
    <!--
    if (fooBar  == ...) {
    -->
    </script>

    To access the variable in Javascript you'll have to
    write it out from the JSP. You'll need to do something
    like:
    <%
    String fooBar = request.getParameter(......
    %>
    <script language="JavaScript">
    <!--
    var fooBar = '<%=encodeQuotes(fooBar)%>';
    if (fooBar  == ...) {
    -->
    </script>You'll need to either make sure fooBar doesn't contain
    any quotes or write a function to replace each ' with
    \'.Thanks!
    That works perfectly, without encodeQuote() method in my current case.
    Thanks again. You ar a saviour.

  • Passing parameter from Servlet to javascript in JSP. Very Urgent - 5 jukes!

    Well my servlet will retrieve questions from database.
    Then the player will answer the question in the JSP and submit the answer to the servlet to process.
    Each time an answer is submitted, or a "Next Question" button is clicked, the countdown time will restart.
    And will reload the page with a new question.
    So how can i do that?
    This is my servlet, JSP, javascript
    =====================================================================
    * Interacts with the player depending on his types of selection and output them
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    public class GameQuestionServlet extends HttpServlet
         String sSQL = null;
         String sCategory = null;
         String paramName = null;
         User userObject = null;
         Questions gameQsObj = new Questions();
         HttpSession session;
         int cnt = -1;
         int score = 0;
         boolean connected = false;
         public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
              session = request.getSession(false);
              //System.out.println("Testing Score:" + score);
              if(connected == true)
                   Questions object = (Questions)gameQsObj.getQsList().elementAt(cnt);
                   System.out.println("\n" + object.sAns1);
                   System.out.println(object.sAns2);
                   System.out.println(object.sAns3 + "\n");
                   Enumeration enum = request.getParameterNames();
                   while(enum.hasMoreElements())
                        paramName = (String)enum.nextElement();
                        if(paramName.equals("mcq"))
                             System.out.println(request.getParameter("mcq"));
                             score = Integer.parseInt(userObject.score.trim());
                             System.out.println("Player old score: " + score);
                             //Check to see if the selected answer matches the correct answer
                             if((object.sCorrect).equals(request.getParameter("mcq")))
                                  score = score + 10;
                             else
                                  if((object.sCorrect).equals(request.getParameter("mcq")))
                                       score = score + 10;     
                                  else
                                       if((object.sCorrect).equals(request.getParameter("mcq")))
                                            score = score + 10;     
                                       else
                                            score = score - 10;     
              System.out.println("Player current score: " + score);
              else     //will only go into this once
                   userObject = (User)session.getAttribute("user");
                   System.out.println("\n"+userObject.nric);
                   System.out.println(userObject.name);
                   System.out.println(userObject.password);
                   System.out.println(userObject.email);
                   System.out.println(userObject.score+"\n");
                   //depending on user selection
                   sCategory = request.getParameter("qsCategory");
                   sSQL = "SELECT * FROM " + sCategory;
                   gameQsObj.getQuestions(sSQL, sCategory);
                   score = Integer.parseInt(userObject.score);
                   connected = true;
              System.out.println("Connected:" + connected);
              System.out.println("Before:" + userObject.score);
              cnt = cnt + 1; //increment to retrieve next question
              userObject.score = Integer.toString(score);     
              System.out.println("After:" + userObject.score);
              if(cnt < 3) //setting for the number of questions per game.
                   //request.setAttribute("qsCnt", cnt); //count of the question number
                   request.setAttribute("aQs", gameQsObj.getQsList().elementAt(cnt));
                   System.out.println(request.getAttribute("aQs"));
                   System.out.println("This is question number: "+ cnt);
                   getServletConfig().getServletContext().getRequestDispatcher("/JSP/PlayGame.jsp").forward(request, response);
              else
                   //forward to the result page     
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
              doPost(request, response);
    <%@ page import="Questions" %>
    <HTML>
         <HEAD>
              <TITLE>Play Game</TITLE>
              <SCRIPT LANGUAGE="JavaScript">
                   var refreshinterval=10
                   var displaycountdown="yes"
                   var starttime
                   var nowtime
                   var reloadseconds=0
                   var secondssinceloaded=0
                   function starttime() {
                        starttime=new Date()
                        starttime=starttime.getTime()
                        countdown()
                   function countdown() {
                        nowtime= new Date()
                        nowtime=nowtime.getTime()
                        secondssinceloaded=(nowtime-starttime)/1000
                        reloadseconds=Math.round(refreshinterval-secondssinceloaded)
                        if (refreshinterval>=secondssinceloaded) {
                   var timer=setTimeout("countdown()",1000)
                             if (displaycountdown=="yes") {
                                  window.status="You have "+reloadseconds+ " second before timeout"
                   else {
                        hide();
                   clearTimeout(timer)
                             //window.location.reload(true)
                   function hide() {
                        //hidelayer
                        if(gameLayers.style.visibility == "visible"){
                             gameLayers.style.visibility = "hidden"
                             oops.style.visibility = "show"
                   window.onload=starttime
              </SCRIPT>
         </HEAD>
         <BODY>
              <FORM METHOD="post" ACTION="http://localhost:8080/Java_Assignment2/servlet/GameQuestionServlet">
                   <DIV ID="oops" STYLE="position:absolute; left:300px; top:30px; width:120px; height:150px; z-index:2; visibility:hidden">
                        Oops! 30 seconds time up!!! <BR><BR>
                        <INPUT TYPE="submit" VALUE="Next Question">
                        <INPUT TYPE="hidden" NAME="nextQs" VALUE="Next Question">
                   </DIV>
                   <DIV ID="gameLayers" STYLE="position:absolute; left:300px; top:30px; width:120px; height:150px; z-index:3; visibility:show">
                   <TABLE BORDER="0">
                        <TR>
                             <TH><BIG>Questions:</BIG></TH>
                        </TR>
    <%
                        Questions aQsObj = (Questions)request.getAttribute("aQs");
                        String aQsBody = aQsObj.sQs;
                        String aQsAns1 = aQsObj.sAns1;
                        String aQsAns2 = aQsObj.sAns2;
                        String aQsAns3 = aQsObj.sAns3;
    %>
                        <TR>
                             <TD><B><%= aQsBody%></B></TD>
                        </TR>
                        <TR>
                             <TD>
                                  <SELECT SIZE="3" NAME="mcq">
                                       <OPTION SELECTED><%= aQsAns1 %></OPTION>
                                       <OPTION><%= aQsAns2 %></OPTION>
                                       <OPTION><%= aQsAns3 %></OPTION>
                                  </SELECT><BR><BR>
                             </TD>
                        </TR>
                        <TR>
                             <TD>
                                  <INPUT TYPE="submit" VALUE="Submit Your Answer">
                                  <INPUT TYPE="hidden" NAME="submitAns" VALUE="Submit Your Answer">
                             </TD>
                        </TR>
                   </TABLE>
                   </DIV>
              </FORM>
         </BODY>
    </HTML>
    This must be answered before 28th of september.
    Please help. It is indeed very urgent.

    this is just a skeleton code.. alot of stuff is not here..
    <FORM name = "form1" action="../servlet/wateverSevlet>
    <input type="text" name="searchStr" size="40">
    <INPUT type="hidden" id=answer name=answer size=7>
    <input type="button" name="button" value="Submit Answer" onClick="javascript:submitCheck(document.form1.searchStr.value);">
    <input type="button" name="button" value="Skip Question" onClick="javascript:submitCheck('skip');">
    </form>
    <SCRIPT LANGUAGE="JavaScript">
    function submitCheck(str)
      form1.answer.value = str
      form1.submit()
    </script>i assuming you are submitting it to the same servlet regardless of whether the user clicks the skip question or the submit question button.

  • How to pass a jsp variable into javascript??

    <p><%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
    <p><%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
    <p><html>
    <p><c:set var="binrmapi" value="http://localhost/paas-api/bingorooms.action;jsessionid=XXXXXX?userId=TEST2&sessionId=1&key=1" />
    <p><c:import var="testbinrm" url="${fn:replace(binrmapi, 'XXXXXX', jsessionid)}"/>
    <p><c:set var="tuples" value="${fn:split(testbinrm, '><')}" />
    <p>Time until next game
    <p><c:forEach var="tuple" items="${tuples}">
    <p><c:if test="${fn:contains(tuple, 'row ')}">
    <p> <p><code>
    <p> <c:set var="values" value="${fn:split(tuple, '=\"')}" />
    <p> <font color="blue">
    <p> <c:out value="${values[17]}" />
    <p><c:set var="remainingtime" value="${values[17]}" />
    <p> </font>
    <p> </code>
    <p></c:if>
    <p></c:forEach>
    <p><form name="counter"><input type="text" size="8" name="d2"></form>
    <p><script>
    <p>var milisec=0
    <p>var seconds=eval("document.myForm.remaining").value;
    <p>function display(){
    <p> if (milisec<=0){
    <p> milisec=9
    <p> seconds-=1
    <p>}
    <p>if (seconds<=-1){
    <p> milisec=0
    <p> seconds+=1
    <p> }
    <br>else
    <p> milisec-=1
    <p> document.counter.d2.value=seconds+"."+milisec
    setTimeout("display()",100)
    <p>}
    <p>display()
    <p></script>
    <p></body>
    <p></html>
    <p>This is my code that i was working on, in the jsp part of the script, i get a api call and save a value of time in the variable remainingtime.. and in the javascript, i try to have a countdown clock counting down the remaining time.. but i guess it doesnt work.. how can i get that working? thanks alot
    Message was edited by:
    hamham3001
    Message was edited by:
    hamham3001
    Message was edited by:
    hamham3001
    Message was edited by:
    hamham3001

    Re: How to pass a jsp variable into javascript??Here is the sameple one, hope it will solves your problem.
    <html>
    <body>
    <form name=f>
    <%!
    String str = "A String"
    %>
    <script>
    var avariable = <%=str%>
    <script>
    </form>
    </body>
    </html>
    Let me know if you face any problem

  • Parameters b/w javascript and JSp

    how i can pass values between javascript and jsp .
    ( java script varaible in the JSP part & jsp object in the javascript code )

    Since Java script is on the client side , to get the value of a java script variable into jsp, u have to set some form field variable and submit it to the server again. So, it can be something like:
    <script>
    function submit()
         var scriptVar = 12;
         document.form1.formVariable.value=scriptVar;
         document.form1.submit();
    </script>
    <%
    System.out.println("Script variable value = " +request.getParameter("formVariable"));
    %>
    <form name="form1" method="post">
    <input type="hidden" name="formVariable" value=""/>
    <input type="button" name="bSubmit" value="Submit" onclick="javascript:submit()" />
    </form>
    The first time this jsp is called, the value of formVariable will be null.
    The next time, when u click on submit button, the value will be 12.
    I have not tested this. There might be some syntax errors. Just try it out. Also, make sure that u don't end up submitting the form in an infinite loop by using the submit() generally in the script. Hope this helps.

Maybe you are looking for

  • EC-PCA :the open items in Dummy PC

    Dear all, In our company, the profit center accounting is activated after SAP going live. So, a lots AR/AP open items will be posted to dummy pc after F,5D and 1KEK. My question is how to repost these open items into proper profit center. Maybe we ca

  • Referencing Global Variable in Forms DDL (Form Personalization R12)

    Team, I'm saving a profile option in a Global variable GLOBAL.FLINV_PROFILE_VALUE when a form opens. Then I am clearing the variable using Forms DDL and calling FND_PROFILE.SAVE function. I need to then reset the profile option with a second call to

  • I can't uninstall Bonjour when I try uninstall

    I got a message that a newer version of iTunes was available. It did not install correctly.  I followed the directions on the Apple support website to try to unistall iTunes (so I can reinstall it) but I keep getting error messages that both Bonjour

  • ODS reports Vs Cube reports

    Hi, Pl let me know the advantages or disadvantages of reporting on ODS Vs Cube. Which one will be better option and why. Pl explain. Thanks & Regards, Vijaya

  • Set up Windows and Parallels on Mac Pro

    Can someone please give me step by step directions to best set up Windows and Parallels on my Mac Pro? Right now I am running Lion but will upgrade to Mountain Lion soon. I want to mostly use Parallels to see how my website runs on PCs. I have been a