How to pass a java variable to a JSP custom action?

I am trying the following code to display a list of 5 choices. But it shows me choices as <%= i %> and not the actual values of i as 0,1,2,3,4.
what's going wrong?
<body>
<form>
<test:SearchList name="testList" listSize="5" listWidth="300" multiple="Y" >
<% for(int i=0; i< 5; i++){%>
<test:SearchListOption label="<%= i %>" value="<%= i %>" />
<%}%>
</test:SearchList>
</form>
</body>
</html>
thanks-
ksg

Hi,
Thanks for reply.
Oh I guess by mistake I sent part of code for the jsp file which in full is as :
<%@ taglib uri="/WEB-INF/tlds/taglib.tld" prefix="test"%>
<html>
<body>
<form>
<test:SearchList name="testList" listSize="5" listWidth="300" multiple="Y" selectList="" >
<% for(int i=0; i< 5; i++){%>
<test:SearchListOption label="<%= i %>" value="<%= i %>" />
<%}%>
</test:SearchList>
</form>
</body>
</html>
and here is the taglib.tld code.
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib.tld>
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>test</shortname>
<tag>
<name>SearchList</name>
<tagclass>customTags.SearchList</tagclass>
<bodycontent>jsp</bodycontent>
<attribute>
<name>name</name>
</attribute>
<attribute>
<name>listSize</name>
</attribute>
<attribute>
<name>listWidth</name>
</attribute>
<attribute>
<name>multiple</name>
</attribute>
<attribute>
<name>fontSize</name>
</attribute>
<attribute>
<name>selectList</name>
</attribute>
<attribute>
<name>searchSize</name>
</attribute>
</tag>
<tag>
<name>SearchListOption</name>
<tagclass>customTags.SearchListOption</tagclass>
<bodycontent>empty</bodycontent>
<attribute>
<name>value</name>
</attribute>
<attribute>
<name>label</name>
</attribute>
</tag>
</taglib></taglib.tld>
Help is greatly appreciated.
-Kirti

Similar Messages

  • How to pass a JavaScript variable into a java method

    I would like to know how to pass a JavaScript variable into a java method with in a <% %> tag inside a JSP file like so:
    <%@ page contentType="text/html;charset=windows-1252"%>
    <html>
    <head>
    <script LANGUAGE="JavaScript">
    myValue = someDynamicValue;
    <% System.out.println(myValue)%>
    </script>
    </head>
    <body>
    </body>
    </html>
    obviously "System.out.println(myValue)" will not work because myValue is seen as a java variable and not a JavaScript variable.
    I would like to know how to let the jsp file, that I wrote in the above code, see myValue as a JavaScript variable and not a java variable so that I can pass it to a java method.
    NOTE: the java method does not have to be a println() method, it can be any method of my choice.
    NOTE: someDynamicValue is a JavaScript value that can dynamically change

    I don't believe you can. JSPs are really just elaborate templates that an engine such as Tomcat parses and generates an HTML page based on. That page is then displayed to the user. By the time you want to use some function in Javascript, the JSP has already been parsed and generated.
    Basically, Javascript and JSPs can't talk to each other. One's server-side and the other is client-side.

  • XSLT - How to pass a Java object to the xslt file ?

    Hi ,
    I need help in , How to pass a java object to xslt file.
    I am using javax.xml.transform.Tranformer class to for the xsl tranformation. I need to pass a java object eg
    Class Employee {
    private String name;
    private int empId;
    public String getName() {
    return this.name;
    public String getEmpId() {
    return this.empId;
    public String setName(String name) {
    this.name = name;
    public String setEmpId(int empId){
    this.empId = empId;
    How can i access this complete object in the xsl file ? is there any way i can pass custom objects to xsl using Transformer class ?

    This is elementary. Did you ask google ? http://www.google.com/search?q=calling+java+from+xsl
    ram.

  • Passing a variable from Javascript to java variable in a JSP.

    Here is simple test Ive been messing around with.
    How do I assign the value that was selected in the radio button to a java variable in my JSP here. Javascript being client side and JSPs being serverside makes this difficult.
    <html>
    <head>
    <SCRIPT LANGUAGE="JavaScript">
    function valbutton(thisform)
         myOption = -1;
         for (i=0; i<thisform.myradiobutton.length; i++)
              if (thisform.myradiobutton.checked)
                   myOption = i;
         if (myOption == -1)
              alert("You must select a radio button");
              return false;
         alert("You selected button number " + myOption + " which has a value of " + thisform.myradiobutton[myOption].value);
         thisform.submit();
    </SCRIPT>
    <title>CreateCategoryContent</title>
    </head>
    <body>
    <BR>
    <center>
    <%
         for(int i = 0; i < 10; i++)
    %>
    <form name="myform">
    <table border="1" bordercolor="#C0C0C0" width="50%" cellpadding="0" cellspacing="0" bgcolor="white">
         <tr>
         <td><%=i%><input type="radio" VALUE="<%=i%>" name="myradiobutton"></td>
         </tr>
    <%
    %>
    </form>
    <input type="submit" name="submitit" onclick="valbutton(myform);return false;" value="Validate" />
    </table>
    </center>
    <!--//T2-->
    </body>
    </html>
    Thanks dudes.

    Please excuse me for appearing dim but my JSP skills are rather weak.
    I dynamically create rows in a table from an Iterator. If the mainTopic is news then I need a third column to appear with radio buttons. I have all this done. When a radio button is selected and the UPLOAD button is selected I need to know which of the values in the table was selected.
    When I ran the test below the selected value was null. Can you help me?
    Thanks.
    <%@ page session="false" %>
    // imports etc
    <%@ page errorPage="../com/digisoft/common/Error.jsp" %>
    <html>
    <head>
    <SCRIPT LANGUAGE="JavaScript">
    function valbutton(thisform)
         myOption = -1;
         for (i=0; i<thisform.myradiobutton.length; i++)
              if (thisform.myradiobutton.checked)
                   myOption = i;
         if (myOption == -1)
              alert("You must select a radio button");
              return false;
         alert("You selected button number " + myOption + " which has a value of " + thisform.myradiobutton[myOption].value);
    thisform.selected.value=thisform.myradiobutton[myOption].value;
         thisform.submit();
    </SCRIPT>
    <title>CreateCategoryContent</title>
    <LINK REL="stylesheet" HREF="<%=request.getContextPath() + "/stylesheets/digihostnews.css"%>" TYPE="text/css">
    <%
    HttpSession session = request.getSession(false);
    String mainTopic = request.getParameter("mainTopic");
    String subCategory = request.getParameter("subCategory");
    String subCategoryId = request.getParameter("subCategoryId");
    String subCategoryToBeDeleted = request.getParameter("subCategoryToBeDeleted");
    String selection = request.getParameter("selection");
    // other initializations etc
    %>
    </head>
    <body>
    <BR>
    <!--Another table-->
    <center>
    <table border="1" bordercolor="#C0C0C0" width="90%" cellpadding="0" cellspacing="0" bgcolor="white">
         <tr>
              <td class="blue">Select Topic</td>
         </tr>
         <tr>
         <td class="insidebox2">
         <BR>
              <form action="NewsUpdate.jsp" method=post>
              Select Topic
              <select NAME="mainTopic" class="dropdown">
              <%
                   Iterator menuItems = myLombardiaMgr.getMainCategories();
                   while(menuItems.hasNext())
                        MainCategory aMenuItemCategory = (MainCategory)menuItems.next();
                        String menuItem = aMenuItemCategory.getMainCategory();     
                        if(!menuItem.equalsIgnoreCase(mainTopic))
              %>
                        <option VALUE="<%= menuItem %>" ><%= menuItem %></option>
              <%
                        else
              %>
                        <option SELECTED VALUE="<%= menuItem %>" ><%= menuItem %></option>
              <%
              %>
         </select>
         <INPUT type=submit class="newsbutton" value="LOAD" name=Submit>
    </form>
    <form action="AddCategoryDescription.jsp" method=post>
    <INPUT TYPE=HIDDEN NAME="mainTopic" VALUE="<%=mainTopic%>">
    <INPUT type=submit class="newsbuttonlong" value="EDIT DESCRIPTION" name=Submit>
    </form>
    </td>
    </tr>
    </table>
    </center>
    <!--//Another table-->
    <!--T2-->
    <center>
    <table border="1" bordercolor="#C0C0C0" width="90%" cellpadding="0" cellspacing="0" bgcolor="white">
         <tr><td class="blue">Categories</td></tr>
         <tr>
              <td class="insidebox2">
              <BR>
              <form action="NewsUpdate.jsp" method=post>
                   Add Category
                   <input type="text" name="subCategory" class="dropdown" id="catId" value=""/>
                   <INPUT TYPE=HIDDEN NAME="mainTopic" VALUE="<%=mainTopic%>">
                   <%      
                   if (mainTopic != null)
                        %>
                        <INPUT type=submit class="newsbutton" value="ADD" name=Submit>
                   <%
                   else
              %>
                   <INPUT type=submit class="newsbutton" value="ADD" name=Submit disabled>
                   <%
                   %>
              </form>
                   <!--T3-->
         <table id="categoryTable" border="1" bordercolor="#035C98" width="60%" height="60%" cellpadding="0" cellspacing="0" bgcolor="white">
         <tr>
         <td colspan="1" class="result"><b>Category Name</b></td>
         <td colspan="1" class="result"><b></b></td>
         </tr>
    <%
              if(myApplicationDetails != null)
                   myApplicationDetails = myLombardiaMgr.getAllApplicationDetails();
                   Iterator myMainCategories = myApplicationDetails.getMainCategories();
              while(myMainCategories.hasNext())
                   MainCategory aMainCategory = (MainCategory) myMainCategories.next();
                   if(aMainCategory.getMainCategory().equalsIgnoreCase(mainTopic))
                        Iterator subTopics = aMainCategory.getSubTopics();
                        while(subTopics.hasNext())
                             SubTopic aSubTopic = (SubTopic) subTopics.next();
                   %>
                        <form action="NewsUpdate.jsp" method=post>
                             <tr>
                             <td class="result"><%=aSubTopic%></td>
                             <td class="result">
                                  <INPUT type=submit class="newsbutton" value="REMOVE" name=Submit>
                                  <INPUT TYPE=HIDDEN NAME="subCategoryId" VALUE="<%=aSubTopic.getId()%>">
                                  <INPUT TYPE=HIDDEN NAME="subCategoryToBeDeleted" VALUE="<%=aSubTopic%>">
                                  <INPUT TYPE=HIDDEN NAME="mainTopic" VALUE="<%=mainTopic%>">
                                  <INPUT TYPE=HIDDEN NAME="subCategory" VALUE="<%=aSubTopic%>">
                             </form>
                        <form action="EditStoryItem.jsp" method=post>
                             <INPUT TYPE=HIDDEN NAME="subCategory" VALUE="<%=aSubTopic%>">
                                  <INPUT TYPE=HIDDEN NAME="subCategoryId" VALUE="<%=aSubTopic.getId()%>">
                                  <INPUT TYPE=HIDDEN NAME="mainTopic" VALUE="<%=mainTopic%>">
                                  <INPUT type=submit class="newsbutton" value="EDIT" name=Submit>
                             </form>
                             <%
                                  if(mainTopic.equalsIgnoreCase("News"))
                             %>
                                  <td class="result">
                                       <INPUT type="radio" name="newsitem" VALUE="<%=aSubTopic%>" >
                                       <INPUT TYPE=HIDDEN onclick="valbutton(myform);return false;" NAME="selection" >
                                  </td>
                             <%
                             %>
                   </td>
                             </DL>
                                  </tr>
                        <%
                             } // end of if
                        %>
         </table>
         <table border="0" bordercolor="#C0C0C0" width="60%" cellpadding="0" cellspacing="0" bgcolor="white">
         <tr><td align="right">
         <form action="../../../../../../servlet/UploadXmlFiles" method=post>
         <% if(myApplicationDetails == null )
         System.out.println("******************* selection "+selection);
    %>
              <INPUT type=submit class="newsbutton" value="UPLOAD" name=Submit disabled>
    <%
         else
    %>
    <INPUT type=submit class="newsbutton" value="UPLOAD" name=Submit>
    <%
         System.out.println("******************* selection "+selection);
    %>
         </form>
         </td>
         </tr>
         </table>
         <!--//T3-->
         </td>
         </tr>
    </table>
    </center>
    <!--//T2-->
    </body>
    </html>

  • How can we  use java variable in javascript code on JSP page?

    How can we use java variable in javascript code on JSP page?
    Pls help

    Think about it:
    JSP/Java is executed on the Server and produces HTML+JavaScript.
    Then that HTML+JavaScript is transfered to the client. The client now interpretes the HTML+JavaScript.
    Obviously there's no way to access a Java variable directly from JavaScript.
    What you can do, however, is write out some JavaScript that creates a JavaScript variable containing the value of your Java variable.

  • How to pass the USER variable to RPD in 11g?

    I am trying to figure out how to pass the USER variable to the RPD in 11g.
    In 10g, I had define an intializtion block to store the USER variable and pass it to a statement that has to be executed before the query is executed.
    We use the Oracle VPD technology that allows to restrict data access. This is the statement that has to be executed before a query can run.
    select vpd_adwh.setclnvpdcontext_fnc('VALUEOF(NQ_SESSION.cuser)', UPPER(:USER))) from dual
    That is the 10g version and it works fine.
    In 11g, I tried to use
    select vpd_adwh.setclnvpdcontext_fnc('VALUEOF(NQ_SESSION.cuser)', UPPER('VALUEOF(NQ_SESSION.USER)')) from dual
    but this is not working.
    Any help?

    any ideas?

  • How to pass Unix environment variable to a SQL procedure or SQL * Plus

    Can any body suggest me how to ,
    How to pass Unix environment variable to a SQL procedure or SQL * Plus file..
    I am trying to invoke a SQL Procedure from Unix
    by passing the value of a Unix environment variable.
    Is it possible..?
    Thanks in advance.
    Regards,
    Srinivas Jaltaru

    Within your shell script you can use what is known as a "here document" which is basically a way of wrapping a call to Oracle. The following call to Oracle loops and writes rows to files with numerically increasing file names. Two unix shell variables are used, one in a select statement and one in a spool command :
    <pre>
    #!/bin/bash
    export ORACLE_SID=DEV05
    FILENO=1007351
    while [ ${FILENO} -le 1008400 ]
    do
    FILENAME=farm_${FILENO}.txt
    DUMMY=`sqlplus -s user20/user20 <<SQLSTOP
    set lines 73
    set pages 0
    set head off
    set termout off
    set echo off
    set feedback off
    select rpad(searchx, 8)
    from blastx@PRODUCTION
    where searchx = ${FILENO} ### here's a shell variable
    spool /export/home/user20/sql/psiblast/BACKUP2_D/${FILENAME} ### here's a shell variable
    spool off
    SQLSTOP`
    FILENO=`expr ${FILENO} + 1`
    done
    exit 0
    </pre>

  • How to Generate a Java file for a JSP Page

    Hi ,
    I am using weblogic11 .
    I am working on a JSP page which nearly consists of 4000 lines of code.
    I need to debug the file , but weblogic server is not generating the java file for the JSP pages .
    Please let me know how can i genertae Java file for the jsp pages ??

    JSPs are compiled into servlets automatically and those classes are stored in WEB-INF/classes folder. Servlet engine handles servlets.

  • 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

  • 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                                                                                                                                                                                                                                                                                                                                                                           

  • How to pass Applet form variables without showing it on top ?

    I am running one applet with some form variables. After submit I want to pass those to .asp file to store into database.
    If I use URL method then all are getting displayed on URL location of browser which I do not want. I want to pass many form variables to another .asp file, so it may not be good also.
    What is the best way of doing it ? Need urgent help about it.

    Well If you create a POST request instead as a GET request the variables will not show up in the URL.
    On tips how to do that you can either check out this thread:
    http://forums.java.sun.com/thread.jsp?forum=31&thread=56388
    or one of these:
    http://search.java.sun.com/Search/java?qt=applet+GET+POST+variables&col=javafrm&rf=0
    Sjur

  • How to pass table type variable into function from SQL*PLUS ?

    How to pass a table type variable from sql*plus prompt into a function ?
    Thanx in advance.

    Krishna,
    Do you mean like this?SQL> DECLARE
      2      TYPE t_tbl IS TABLE OF VARCHAR2(20);
      3      l_sample_tbl           t_tbl;
      4
      5      FUNCTION print_contents ( p_tbl IN t_tbl )
      6      RETURN VARCHAR2
      7      IS
      8          l_string            VARCHAR2(1000);
      9      BEGIN
    10          FOR i IN 1..p_tbl.COUNT LOOP
    11              IF (i = 1) THEN
    12                  l_string := p_tbl(i);
    13              ELSE
    14                  l_string := l_string || ', ' || p_tbl(i);
    15              END IF;
    16          END LOOP;
    17          RETURN (l_string);
    18      END print_contents;
    19
    20  BEGIN
    21      l_sample_tbl := t_tbl();
    22      l_sample_tbl.EXTEND;
    23      l_sample_tbl(1) := 'one';
    24      l_sample_tbl.EXTEND;
    25      l_sample_tbl(2) := 'two';
    26      l_sample_tbl.EXTEND;
    27      l_sample_tbl(3) := 'three';
    28      l_sample_tbl.EXTEND;
    29      l_sample_tbl(4) := 'four';
    30      l_sample_tbl.EXTEND;
    31      l_sample_tbl(5) := 'five';
    32      DBMS_OUTPUT.PUT_LINE(print_contents(l_sample_tbl));
    33  END;
    34  /
    one, two, three, four, five
    PL/SQL procedure successfully completed.
    SQL> HTH,
    T.

  • How To pass a period variable

    Hi experts!
    I have a model in visual composer that calls a query which has a filter on the characteristic 0FISPER, when I execute this query in the query Designer, the period of fiscal year is asked in the format "009.2007 - 008.2008".
    The problem is that I don't know how to pass this value in VC, because if I indicate the static text "009.2007 - 008.2008" in the field "Fiscal year period" in the connector between the inputform and the query, when I execute the VC model the following error appears:
    "Nested Exception. Failure to execute native function. Nested Exception.
    INVALID_VARIABLE_VALUES"
    Do you have any idea how to pass the values of the period to the variable of the query??
    Thnks in advance!!!

    Hi Roberto,
    the solution is available in the WIKI:
    <a href="https://www.sdn.sap.com/irj/sdn/wiki?path=/display/vc/howtoselectranges&">https://www.sdn.sap.com/irj/sdn/wiki?path=/display/vc/howtoselectranges&</a>
    Best Regards,
    Marcel Salein

  • How to pass a shell variable to rman scripts

    I want to backup datafile to different directory
    depending on the current time,and I can do this to
    pass a shell variable to rman scripts,and this
    variable will used as part of format ,like this:
    backup incremental level=0
    tag rman_inc0_bck
    filesperset 5
    format '$(DIR)/rman_fulldb_%u_%s_%p_%d'
    (database include current controlfile)
    and $(DIR) is shell variable ,but rman will not
    recognize this ,how to achieve this?

    You could send your script to rman thru a pipe | or <<
    echo "backup incremental level=0
    tag rman_inc0_bck
    filesperset 5
    format '$(DIR)/rman_fulldb_%u_%s_%p_%d'
    (database include current controlfile);" | rman target /You could also create a "temp script" and then use it from rman with cmdfile
    sed "s,XXXDIR,$(DIR)," yourtemplate > /tmp/rmanscript.$$
    rman target / cmdfile /tmp/rmanscript.$$
    rm /tmp/rmanscript.$$

  • How to pass a javascript variable to a query in BEx?

    Hi All,
    We're using BEx SAP BW 3.x
    I'm using portal eventing to pass a variable to a BW template.  While I can pick up this value using javascript, I do not know how to pass it to the query.
    Let me just say, I am new to BEx, so any guidance you could give me would be most welcome.
    Thanks in advance,
    Liz.

    Hi,
    Perhaps this JavaScript can help?
    document.appletName.getQueryObject().setParam(1, param value);
    Call this peice of code on some event, for example the click event of a Button.
    There are many more examples on this forum, search for more.
    Regards,
    Michael

Maybe you are looking for

  • Why can't I print out the body of my emails,they come out with the right missing.

    When ever I try to print out my emails(gmail) everything under the Mail column prints,but the right side is missing. I have tried everything I know and nothing works. I can't move it over and I can use the print selection. Also I can't print out the

  • Can't mount Digital 8 Camcorder in FCP 6? (TRV120)

    Any ideas?  Have tried all the standards stuff.. VIEW>Refresh AV device Start up FCP with and without digital 8 camcorder plugged into Mac's Firewire 400 port "Firewire basic", "non-controllable device" Re-opening log & capture window too many times

  • Repeating frames...simple problem

    I am new to Oracle Reports and have run into a simple issue which I am not able to fix. Suppose that I’ve a table Numbers as shown below: SQL> desc numbers Name Null? Type COL1 NUMBER SQL> select * from numbers; COL1 1 2 3 4 5 Now I want to build a r

  • After upgrade from TFS 2010 users cannot view source control

    I recently did a in place of upgrade of TFS 2010 to TFS 2013.   All of my users permissions stayed in tact. The users (contributors) cannot view any of the source control in either in VS 2010 or 2013.  Since I am the administrator I see everything an

  • Read out current date on mobile devices?

    Hello there, how can I read out the current date in a mobile Flex-App?