Assigning a jstl variable to java Script variable

Hai All,
I created one jsp page with java script with JSTL.
I retrive arrayList from simple java bean in jsp page with help of JSTL .
Now i want assign the ArrayList value through JSTL to Java Script Array.
How to convert JSTL to Java Script.
Please give me details asp.
thanks ,
Bala

You can do this:
<% request.setAttribute("x", "hello"); %>
<c:out value="${x}"/>or if you want to go from JSTL to scriplet you can:
<c:set var="testvar" value="hello" scope="request"/>
<%= request.getAttribute("testvar") %>Both of these will output "hello"
<c:set> defaults to the page scope, so you could substitute pageContext for request and get the same results (remove scope="request" first though).
Karl

Similar Messages

  • How to access a JAVA Script variable in JSP Code

    How to access a JAVA Script variable in JSP Code. I have been unable todo this.
    Plz Suggest a way.
    Thanks
    Soumya

    try to do this code
    String s=request.getParameter("javascriptvariablename");

  • Returning/passing Java script variable/value to PL/SQL environment

    Hi,
    Can someone give me a sample code about how to return a Java script variable to PLSQL environment?
    for example, I have a javascript function that returns timestamp in milisecond, I then want to write PLSQL code to call this java script function and save its value in a number-typed plsql variable for further calculation, I dont know how the two scripting language communicate.
    Thank you very much
    Binh
    null

    This is quite simple.
    I assume that you are able to define html form side through pl/sql. Suppose your new pl/sql value is v_time then in the procedure that you write include one more statement
    htp.p('<Input type=hidden name="v_time" value="">');
    and also in the form invocation,
    htp.p('<form name=app method=post action="time_handler" onSubmit="return false;">');
    and to the end you must be having a submit
    to it attach a onClick function that calls
    simply our validate function..
    eg htp.p('<Input type=submit value="process"
    onClick="validate();">');
    Include in the head portion
    the following script using htp.p procedure
    function validate()
    app.v_time.value=<calculated value>;
    return app.submit();
    Hope this helps.
    Nat
    null

  • Passing importing parameter in  ABAP to  java script variable

    Hi Experts,
    I am calling a ABAP function module in javascript.Now how can I take importing parameter in  ABAP to java script variable. Because I need to give alert using the improting Paramter value...
    Thanks in advance..
    RR

    to pass ABAP variable value to javascript variable the syntax is
    var myjsvariable = "<%=abapvariable%>";
    Edited by: Durairaj Athavan Raja on Jul 29, 2009 2:39 PM

  • Using JSP variable inside Java Script's alert function.

    Hi Gurus,
    We are trying to use alert function with one of the string variables populated inside JSP code, but its not working.
    Here is the code snippet, please advice.
         <%
         oracle.apps.qot.util.RequestCtx.log("qotcustom.jsp",AOLMessageManager.getMessageSt(QotUtil.QOT_APPS_CODE, "XDPYY_DISC"));
         %>
         var alert_text="<%=AOLMessageManager.getMessageSt(QotUtil.QOT_APPS_CODE, "XDPYY_DISC")%>";
         alert(alert_text);
         Here in the first line we are using API to get text message defined in database, the line is getting executed properly and we could see output text message in debug log file, after this in the 4th line, we are assiging this string output of API to java script variable alert_text and further using alert function with the variable alert_text as argument. But alert function is failing, no errors are thown in debug log file.
    Please advice whether we are doing any thing wrong.
    Thanks in advance.

    What pgeuens means is that you can't mix javascript and jsp/java code in this way.
    ALL of the jsp/java code gets executed at the server end.
    This produces an HTML page (with embedded javascript) which gets sent to the client.
    The client then runs javascript code in response to events (onLoad, onClick, onChange etc etc)
    So in this case, the jsp:forward will always be executed, because as far as the server is concerned, the javascript is just template text.
    If you WANT to do a conditional forwarding on the server side you do it in java ie (horribly using scriptlet)
    <%
    if (testCondition){
    %>
      <jsp:forward>
    %<
    %>Or if you want to test what the client has entered client side, all you can do is submit the form, or navigate to a URL
    <script>
    function test()
    if(document.f.htemp.value=="true")
    alert("jus");
    else
    var s=document.f.htemp.value;
    alert(s);
    document.f1.action="success.jsp";
    document.f.submit();
    </script>You cannot run JSP code based on your javascript code.
    Java. Javascript. Not the same thing.
    Hope this helps,
    evnafets

  • How to assign java script variable to a hidden parameter in JSP?

    Hi All,
    I want to assign the variable in the Jscript to a hidden parameter in JSP page.
    <select name="sortingOption" class="sortingOptions" onchange="changeSortOption(this)">
    <c:forEach var="sortingOption" items="${sortingOptionList}">
    <c:set var="sortingOptionValue" value="${sortingOption}" target="java.lang.String"/>
    <c:choose>
    <c:when test="${sortingOptionValue == sortingOptionValueFromRequest}">
    <option value="${sortingOptionValue}" selected="selected">${sortingOptionValue}</option>
    <input type="hidden" name="srchType" value="none"/>
    </c:when>
    <c:otherwise>
    <option value="${sortingOptionValue}">${sortingOptionValue}</option>
    </c:otherwise>
    </c:choose>
    </c:forEach>
    </select>
    In changeSortOption script,they capture the value selected by the user and then they submit the form.I want to assign that value to a hidden parameter in JSP,can someone tell me how to do that?
    I dont have the Jscript code with me right now to post here.

    To the point: just by accessing/manipulating the HTML DOM using JS. Learn JS and HTML DOM. There are basic tutorials at w3schools.com. Besides, your code syntax is still invalid. The input hidden elemend doesn't belong in a select element. Learn HTML. There's a basic tutorial at w3schools.com as well.
    For future HTML/JS problems please consult the appropriate forums. This has not much to do with JSP. There are ones at webdeveloper.com.

  • How to pass a java script variable to a JSP page

    How to assign a javascript variable value to a jsp variabe
    <script>
    var scroll="100"
    </script>
    <%
    String age=[ here i need to set the value of "scroll" ]
    %>
    is it possible ,
    thanks

    assign this scroll to a hidden field in a form
    and pass via form to server this may be one way or
    set attribute scroll and then access to server side
    may this help you
    --yogeshb                                                                                                                                                                                                                                                                                                                                                                           

  • Use a Java Script variable's value in some other  jsp ....how?

    Please help me.................
    <%@ page import="java.util.*" %>
    <%@ page language = "java" import="java.sql.*,javax.servlet.*,javax.servlet.http.*,java.util.*" session = "true" %>
    <HTML>
    <HEAD>
    <TITLE>Create Employee</TITLE>
    </HEAD>
    <BODY>
    <%
         Connection conn = null;
         Statement stmt = null;
         ResultSet rs = null;
         try {
              Class.forName("com.mysql.jdbc.Driver");
    conn = DriverManager.getConnection("jdbc:mysql://10.203.143.55:3306/bdaymgr" ,"root","mysql");
              stmt = conn.createStatement();
              rs = stmt.executeQuery("Select emp_id,emp_name From employee_info ");
              System.out.println("rs " + rs);
    %>
    <script language="JavaScript">
         function OnSubmitForm(){
         var box = document.form2.UserList;
         var where_to = box.options[box.options.selectedIndex].value;
         if(where_to =="")
    {document.write("Please select something");}
         else {Dont know what to do here }
         </script>
    </script>
    <center>
    <FORM NAME = "form2" onSubmit="OnSubmitForm();">
    <table>
    <TR>
         <TD width="11%">User ID : </TD>
         <TD width="180%"><select name="UserList" size="1">
         <option>-- Select A User ID --<option>
         <% while (rs.next()) {
         %>
         <option value='<%= rs.getString("EMP_ID")%>' ><%=rs.getString("EMP_ID") %></option>
         <% } %>
         </select>
         <input type="hidden" name="score" value="">
         <INPUT TYPE="SUBMIT" name="Submit" VALUE="Submit">
         </TD></TR>
    </TABLE>
    </FORM>
    </Center>
    <%
              stmt.close();
                   rs.close();
              catch(Exception e){
                   System.out.println("Error : "+ e);
                   response.sendRedirect("errorcreateSession.jsp");
    %>
    </BODY>
    </HTML>
    As u can see i have extracted emp_id from the employee_info table and populated it in my drop down list
    In the javascript i have used a variable "where_to" which keeps track of what the user has selected in the drop down list
    I want to use this value of "where_to" in some other other jsp(say Admin.jsp) to carry out an insert query
    how can i retrieve this value of "where_to" from Admin.jsp so that i can carry out my insert query
    Thanx in advance i certainly hope that u will help me

    I made these changes in my Guest.jsp page(as u mentioned):
    <FORM NAME = "form2" onSubmit="return OnSubmitForm();" action="Admin.jsp">
    <select name="UserList" size="1">
         <option>-- Select A User ID --<option>
    </select>
         <INPUT TYPE="SUBMIT" name="Submit" VALUE="Submit">
    <script language="JavaScript">
         function OnSubmitForm(){
         var box = document.form2.UserList;
         var where_to = box.options[box.options.selectedIndex].value;
         if(where_to =="")
    document.write("Please select something");
    return false;
    else
    return true;
    </script>
    Now have a look at my Admin.jsp page:
    <%@ page import="java.util.*" %>
    <%@ page language = "java" import="java.sql.*,javax.servlet.*,javax.servlet.http.*,java.util.*" session = "true" %>
    <HTML>
    <HEAD>
    <TITLE>Create Employee</TITLE>
    </HEAD>
    <BODY>
    <%
         Connection conn = null;
         Statement stmt = null;
         ResultSet rs = null;
         PreparedStatement ps = null;
         try {
              Class.forName("com.mysql.jdbc.Driver");
    conn = DriverManager.getConnection("jdbc:mysql://10.203.143.55:3306/bdaymgr" ,"root","mysql");
              String s=request.getParameter("UserList");
              String m=request.getParameter("month");
              String y=request.getParameter("year");
              String a=request.getParameter("amount");
              String sql="insert into contribution_info values(?,?,?,?)";
              ps=conn.prepareStatement(sql);
              ps.setString(1,s);
              ps.setString(2,m);
              ps.setString(3,y);
              ps.setString(4,a);
              ps.executeUpdate();
              System.out.print("Values Entered");
              %>
    <center>
    <FORM NAME = "form3" action="canBeAnyPage.jsp">
    Month :<br><input type=\"text\" name="month"><br>
    Year :<br><input type=\"text\" name="year"><br>
    Amount Paid :<br><input type=\"text\" name="amount"><br>
    <INPUT TYPE="SUBMIT" name="Submit" VALUE="Submit">
    </FORM>
    </center>
    <% stmt.close();
                   rs.close();
              catch(SQLException e){
                   System.out.println("Error : "+ e);
                   //response.sendRedirect("errorcreateSession.jsp");
    %>
    </BODY>
    </HTML>
    I dont know why but when i select one of the emp_id from the drop down list and press submit it does not show anything
    I can see the value of "UserList" in the url which is correct
    Probably there is some problem in my Admin.jsp page
    Please find time to have a look at my code
    Help would be really appreciated
    thanx

  • Pass value of Java script variable to ABAP variable (in BSP)

    Hi,
    I have a Javascript variable declared in the SCRIPT tag of BSP layout page.
    I want to pass its value to ABAP variable, so that later I can do some computations using the ABAP variable.
    (ABAP variable is also declared in the same SCRIPT tag of BSP page)
    Would request to post a sample code, if possible.
    Would appreciate quick replies.
    Thanks & Regards,
    Nisha Vengal.

    just check this
    https://forums.sdn.sap.com/click.jspa?searchID=16240444&messageID=1191305

  • Passing javascript variable to java bean

    Hi all,
    Is there any way to pass a java script variable to a java bean. i'm trying hard but in vain. please suggest a way how to do it...

    The variable u want to pass declare that in a dataobject class i.e consisting of getter and setters ...... when you will use the jsp:useBean tab and the setProperty tag along with the class name it will set the value of the variables ...... use form method = get to set the variables.

  • Combine JSP with Java Script!

    Hi,
    I am writing a .jsp file. I am able to put value of jsp into my java script code like..
    var i = <%= k %>
    but, now my requirement is reverse. I need to put the value of java script variable i into jsp variable k.
    Someone told me that it is possible using eval function.
    Now, using eval function , I can do the following ...
    function xyz() //java script function
    eval(<% int k = 5; %>);
    but, I need to put the value of java script variable i into k.
    I tried eval(<% int k = %> + i);
    but it is not working that way.
    Can anyone tell me how can I achieve this? Please reply as soon as possible.
    Thanks

    Just came across this, and even though it's old, I thought Id add something to it since I know a lot got problems combining javascript and jsp; and that most usually don't provide enough info to get someone started.
    To be able to "use" Java variables inside a javascript, you need to pass them in the function call:
    <%
        String aVariableToPass = "tadaaaaa";
    %>
    <form onSubmit="myFunction(this,'<%=aVariableToPass %>')" method="post" name="myForm" action="">
       <table>
         <tr>
              <td>
                   <input type="submit" value=HitMe" name="submit"/>
              </td>
         </tr>
       </table>
    </form>The function:
    function myFunction(form, theVariablePassedIn)
             var accessToTheVariable = theVariablePassedIn;
    }Now use accessToTheVariable inside the javascript, or theVariablePassedIn directly if you please.
    Cincerely. P

  • Problem- Accessing java script code in java

    i want to access java script variable in java code.
    Is it possible through any method or function?
    help me.

    Stick to your old thread.
    http://forum.java.sun.com/thread.jspa?threadID=777985

  • Passing Java Script to Java.

    Hi everyone,
    How can I pass a Java Script variable to a Java code ?
    Thanks a lot.
    Regards.

    David,
    You whant to pass JS variable
    from:
    1. Script running on client (in HTML page)
    2. Script running on server (via some JS interpreter in Java, like Rhino or FESI)
    to:
    1. Applet on page
    2. Server-side code (servlet)
    Please clarify
    VS

  • How to pass values to variables in WAD 7.0 using java script

    Hi.,
    My requirement is based on WAD 7.0.
    The sales value has to displayed in WAD using graph with various chart types.
    I have created variables for plant and material group in a query.
    I have created drop down box for plant with all plants in it, check box for material group and a Submit button in WAD in FORM tag of HTML coding.
    Once all the values are set in drop down box, checkbox and if the user clicks on submit button, the values has to captured by the variables for which I have created and the graph has to be aligned to the new values in variables.
    Kindly help me how to use java script to get the values from FORM and pass it to variables.
    Regards,
    Selva

    Hi Selva,
    You do not need to use Javascript for this. Instead you can achieve this by using API Commands in WAD 7.0.
    Please configure Action on the ButtonGroup webitem to use 'Commands'.
    ->Choose Command 'Set Variables Values / SET_VARIABLES_STATE' under Commands for Web Templates
    ->Set Display Variable Screen setting to OFF
    ->Choose Query Variable for Plant, Select Variable Type as 'Binding Type', Binding Type as 'Data Provider Selection', Data Provider as the one you have assigned to the Dropdown webitem, Characteristic as 0PLANT or as that assigned to the Dropdown webitem
    ->Repeat above steps for Query Variable Material Group
    Now when you make a selection from the Dropdown webitems, the Chart output will change accordingly. Let me know if this helps.
    --Priya

  • OBIEE variables in custom java script

    Hello all
    Can I use OBIEE variables like presentation and session variables in my custom java script code that I am writing in text view on a dashboard page. Is it possible to do that. please me soon if somebody knows the solution to do that.
    Thanks in Advance

    Hi john
    Thanks for reply, I am able to generate javascript using text view on a dashboard page.
    But I want to access OBIEE variables in javascript. How I can do that in narrative view. Can u explain me or give me any link.
    Thanks

Maybe you are looking for

  • LR 4.1 cannot EDIT IN PS6

    Just upgraded to LR4.1 and CS6 the creative suite, which includes PHotoshop CS6. I work in Win 7 64 bit After Upgrading, if I try to edit a file from LR into PS, Photoshop opens a blank window, then puts a tab with the name of the file I am trying to

  • Open popup in dynamic region once region changes flows

    I need to open a popup in a flow if boolean is set to true in the pageFlowScope bean of the dynamic flow bean used in a dynamic region. The parent page/flow is configured in the adfc-config.xml and is controlled by a session bean. So the scenario is

  • Mac Mini 10.6 Server startup disk size increase problem.

    Mac Mini 10.6 Server shows system startup disk sized 50GB with 20GB free. Disk utility shows partition sized 500GB with 470GB free. How can I increase size of startup volume without complete reinstall?

  • Assignment of vendor to purchasing organization

    Hi All, We are on SRM 5.0, classic scenario. In our test system, I replicated vendors some time ago. Now the backend has changed and I replicated some new vendors. Now, during shopping cart creation when when I try to assign source of supply, only fe

  • Screen dims randomly with Mac Pro - NOT a Macbook

    After upgrading to Mountain Lion, my screen will dim randomly when watching movies or YouTube.  This is on my early 2008 Mac Pro - not a Macbook Pro which seems to have this problem commonly.  I've searched and searched and lots of people have this p