Dynamic checkboxes with jsp

Hi,
I need to create dynamic checkboxes in my jsp page from the values retrived from the database(oracle).help me with the code.My oracle queries are in my Java bean coding.pls its very very urgent.help me out.

hi,
This is my bean coding.can u pls tell me how to store the resultset values in a arraylist.help me out.
package campaign;
//Imports
import java.io.*;
import javax.sql.DataSource;
import javax.naming.*;
import com.ibm.ws.sdo.mediator.jdbc.Create;
import java.sql.*;
* @author n48edf
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
public class AgentDao extends java.lang.Object implements UnsubscribeConstants
protected int indivID = 0;
protected Connection _conn;
protected DataSource ds = null;
protected ResultSet rs = null;
private String driver = null;
//need to code
public void agentLoad(IndvId) throws IOException
String driver = ORACLE_DRIVER;
String dataSource= ORACLE_DATA_SOURCE;
try
//Establish database connection
if (_conn == null)
try
Context context = new InitialContext();
// JDBC JNDI lookup
ds = (DataSource)context.lookup(dataSource);
context.close();
// Get a connection
_conn = ds.getConnection();
catch (Exception exp)
throw exp;
// Create a connection statement
Statement stmt = _conn.createStatement();
rs = stmt.executeQuery("SELECT DISTINCT busn_org_nm "+
"FROM BUSN_ORG bo,AGYLOCINDV_RESP_BUSORG ab "+
"WHERE ab.busn_org_cd=bo.busn_org_cd AND ab.indvid=p_IndvId");
String array[]=rs;
stmt.close();
cleanUp();
catch ( SQLException sqe )
System.out.println ("AgentDao.java - SQL Exception: " + sqe.toString());
sqe.printStackTrace();
catch ( Exception e )
System.out.println ("AgentDao.java - Exception: " + e.toString());
e.printStackTrace();
finally
if(_conn != null|| rs != null)
cleanUp();
public void cleanUp()
try
//close resultset
if (rs != null)
rs.close();
rs = null;
//close connection
if(_conn != null)
_conn.close();
_conn = null;
catch (SQLException sqe)
System.out.println("SQL Exception occurred in cleanUp() of AgentDAO");
sqe.printStackTrace();
catch (Exception e)
System.out.println("Error occurred in cleanUp() of AgentDAO");
e.printStackTrace();
}

Similar Messages

  • Dynamic Queries with JSP

    I am developing a search page which should first bring the results sorted by some particular field & then the user should have the option of sorting the results by other field names which are provided in a form list.
    For generating dynamic requests, ? is used in place of parameter. But for some reason it is not working with Order by. Other dynamic queries are working fine. Please let me know the right way to handle it.
    And also if someone can advise a good reference book for dynamic SQL statements in accordance with JSP.
    Thanks for your time.

    Never mind my previous solution. Some success was not perfect, therefore not acceptable. I used a scriplet and the problem is solved!
      <!-- Dynamically build the query -->
        <%
          String sql = "select * from issue_list_view";
          String where = null;
          String param = null;
          // Status
          param = (String)pageContext.getAttribute("status");
          if(param != null && param.compareTo("")!=0)
            where = "status='"+param+"'";
          else
            where = "status not in ('Closed','Duplicate')";
          // Assigned To
          param = (String)pageContext.getAttribute("assign");
          if(param != null && param.compareTo("")!=0)
            if(where.length()>0) {where += " and ";}
            where = "category='"+param+"'";
          // Category
          param = (String)pageContext.getAttribute("category");
          if(param != null && param.compareTo("")!=0)
            if(where.length()>0) {where += " and ";}
            where = "category='"+param+"'";
          // Type
          param = (String)pageContext.getAttribute("type");
          if(param != null && param.compareTo("")!=0)
            if(where.length()>0) {where += " and ";}
            where += "issue_type='"+param+"'";
          // Id
          param = (String)pageContext.getAttribute("id");
          if(param != null && param.compareTo("")!=0)
            if(where.length()>0) {where += " and ";}
            where += "issue_id="+param;
          // Add where clause if needed
          if(where != null) { sql += " where " + where; }
        %>
        <!-- Do the query -->
        <sql:query var="issues" sql="<%=sql%>"/>

  • Dynamic images with JSP

    Hello,
    I am using NetBeans to make a WebApp. I have an image to display on Page3.jsp that is generated during the navigation from the previous page, Page2.jsp. This image is a png file, and is unique graph generated for each visitor. Is there a simple way to display dynamically created images? I have searched for tutorials and asked my good pal Google but to no avail.
    (FYI: At present, I am saving the images in a folder I have created beneath the 'web' folder, called 'web/images'. Netbeans asks me if I want to reload the image only after the previous, old image has been sent out by the server. I am producing and creating the image with the button_action method of Page2.jsp that then sends the user to Page3.jsp, where the image is to be displayed. Once the image is reloaded, I can refresh the web page and the correct image appears.)
    Any help would be greatly appreciated.
    Thanks,
    Taivo

    Although I have never implemented this, I know it is possible and I can point you in the right direction. If you already have the code to create the .png image, it shouldn't be too difficult to modify the image code into a servlet to serve nothing but the image (and leave rest of the html in place). Just as the page is writen to an output stream from the request for page.jsp (by the servlet created by the jsp parser), a request for an image can be handled by a servlet.
    //this is in page3.jsp as plain HTML
    <img src="/servlet/graph?user=aUser" />This servlet (graph.class) draws ths image, but instead of writing it to a file, writes it to the response stream.
    Hope this helps,
    Bamkin

  • Dynamic dropdown with jsp

    Hi,
    can someone suggest me how to implement following concept in JSP (only through jsp)
    i have one dropdown list box,which is holding source values, on selecting source the second dropdown list box should display destination values from database.
    i have some sample code snippet, but not sure what to put in "onchange". can anyone tell me, pls let me know if there are any easy ways to do this.
    Source <select name="source" onchange="">
    <option value="">Select Source</option>
    <option value="jfk">JFK</option>
    <option  value="heathrow">Heathrow</option>
    <option  value="cst">Mumbai</option>
    <option  value="chennai">Chennai</option>
    </select>
    Destination <select name="destination" >
    <%
    while(rs.next())
                   String destination = rs.getString("destination");
                   out.println("<option value="+destination+">"+destination+"</option>");
    %>
    </select>

    Here is my try which I done with [html tutorial|http://phpforms.net/tutorial/tutorial.html]. You can try to use it.
    <html>
    <head>
    <script language="javascript" type="text/javascript" >
    <!-- hide
    function jumpto(x){
    if (document.form1.jumpmenu.value != "null") {
    document.location.href = x
    // end hide -->
    </script>
    </head>
    <body>
    <select name="source" onchange="">
    <option value="">Select Source</option>
    <option value="jfk">JFK</option>
    <option  value="heathrow">Heathrow</option>
    <option  value="cst">Mumbai</option>
    <option  value="chennai">Chennai</option>
    </select>
    Destination <select name="destination" >
    <%
    while(rs.next())
                   String destination = rs.getString("destination");
                   out.println("<option value="+destination+">"+destination+"</option>");
    %>
    </select>
    </body>
    </html>This is just simple example. You can customize it as you like.

  • Dynamic Labels with JSP/BC4J

    Is it possible to have the labels on a JSP dynamically change as the input changes? IE. If country chosen is canada the label becomes postal code instead of zip code.
    Thanks,
    Natalie

    You can setup control hints per locale. If you setup hints for both locales, the JSP runtime will automatically select the appropriate label based on the browser's language settings.

  • How to Controll Dynamic Checkbox Groups

    i want to create checkbox groups dynamically. Each group will have at least one child checkbox. if i select parent check box all child checkboxes should be checked.if i uncheck parent checkbox all child checkboxes should be unchecked.
    that check box group name also coming dynamically. i am trying to pass group name dynamically but it's not recognizing that name in javascript.
    pls help me on this how to controll dynamic checkbox groups.

    recognizing that name in javascript.Are you dynamically creating checkboxes with JSP?

  • Single Dynamic Checkbox record

    Hi,
    I am displaying 1 record with dynamic checkbox with the below
    statement
    select empno, ename, job,wwv_flow_item.checkbox(1, rownum) pr from emp where rownum = 1
    When i hit the Save button i am using onMouseDown event and calling
    the javascript function to make sure the checkbox is checked, and then i am submitting the Page.
    For SAVE button in the button attributes i have this code: onMouseDown="Members_Selected();".
    The below code is used in HTML HEADER:
    <script language="JavaScript">
    function Members_Selected(){
    var bflag;
    bflag = false;
    alert('total count of check boxes:'+document.forms[0].f01.length);
    for (var i=0; i<document.forms[0].f01.length; i++)
    if (document.forms[0].f01.checked == true )
    bflag = true;
    if (!bflag)
    alert("Please select Atleast 1 Member.");
    return false;
    if (confirm("Are you sure you want to assign the selected members !!"))
    doSubmit('SAVE');
    else
    return false;
    return true;
    }</script>
    Below is the problem i see When i HIT the SAVE BUTTON, by Selecting* the checkbox :*_
    I see the java script alert : total count is shown as "undefined"
    and another javascript alert : 'Please select Atleast 1 Member',
    and the page is not submitted.
    Have anyone encountered this problem, i have tested in apex workspace too, i see the same problem.
    Any help or suggestion is appreciated
    Thanks

    Hello:
    Check if this modified JS works for you function Members_Selected(){
    var bflag;
    bflag = false;
    var arr=new Array();
    obj=document.forms[0].f01;
    if (obj.length)
        arr=obj;
    else
        arr[0]=obj.value;
    alert('total count of check boxes:'+arr.length);
    for (var i=0; i<arr.length; i++)
    if (arr.checked == true )
    bflag = true;
    if (!bflag)
    alert("Please select Atleast 1 Member.");
    return false;
    if (confirm("Are you sure you want to assign the selected members !!"))
    doSubmit('SAVE');
    else
    return false;
    return true;
    varad                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to handle dynamically created checkboxes in JSP???

    Hello everybody,
    In a JSP page I would like to create checkbox dynamically on every
    result line (detail line), then check in some of them and finally pass the checked lines to a JSP bean which will handle them on a submit button press.
    The problem are:
    - how to index every checkbox in jsp result line in jsp page in order to avoid solutions like this:
    <input type=checkbox" name="value1">
    <input type=checkbox" name="value2">
    etc
    - how to read every checkbox to find the checked ones
    Is there anobody who has any experience from case like this?
    Please, help me.
    Best regards,
    Danny

    Hi, first off, no need to determine what has been checked or not. If the checkbox is checked, on the post, the value will be submitted as part of the request. If the checkbox is not checked, it will not be submitted (it's value will be null). Depending on what you need, I have approached this a number of different ways. One way is to name all checkboxes the same name. If you need to distinguish between two rows in the form, then in the value field for the checkbox, use some type of distinguishing factor, for example,
    <input type=checkbox name=chkName value="1:abc">
    <input type=checkbox name=chkName value="1:def">
    Now, you only have to make one call on the Servlet/JSP receiving the form post, request.getParameterValues("chkName") which will return an array of the non-null Strings that were checked.

  • Dynamic Page with Multiple Checkboxes

    I am trying to get a dynamic page to pass the checked value of multiple checkboxes to the submit proceedure. Can anyone tell me what I am doing wrong?
    Thanks in advance,
    Pam -------------------------------------------------------------------------
    Dynamic Page:
    <HTML>
    <FORM action="scott.brsubmit" method="POST">
    <TABLE border CELLPADDING=0 CELLSPACING=0>
    <ORACLE>begin
    for c1 in (SELECT rowid,ename, job, bonus from scott.bonus_approval where approved is null)
    loop
    htp.p('<tr><td><FONT FACE= ARIAL SIZE=1>');
    htp.p(c1.ename);
    htp.p('</TD><td><FONT FACE= ARIAL SIZE=1>');
    htp.p(c1.job);
    htp.p('</TD><td><FONT FACE= ARIAL SIZE=1>');
    htp.p(c1.bonus);
    htp.p('</TD><td><FONT FACE= ARIAL SIZE=1><B>');
    htp.p('<input type="hidden" name="p_ename" value='||c1.ename||'>');
    htp.p('<input type="checkbox" name="p_cb" value="Y">');
    htp.p('</TD><td><FONT FACE= ARIAL SIZE=1><B>');
    htp.p('<input type="checkbox" name="p_cb2" value="N">');
    htp.p('</td></tr>');
    htp.p('<br>');
    htp.p('
    end loop;
    HTP.P('</table>');
    htp.p('<p>');
    htp.p('<input type=submit value="Save" name="p_action" >');
    end;
    </ORACLE>
    </form>
    </BODY>
    </HTML>
    Procedure:
    (p_ename in portal.wwv_utl_api_types.vc_arr, p_cb in portal.wwv_utl_api_types.vc_arr, p_cb2 in portal.wwv_utl_api_types.vc_arr, p_action varchar2)
    as
    begin
    if p_action = 'Save' then
    for i in 1..p_ename.count loop
    if (p_cb(i) = 'Y') then
    update scott.bonus_approval set approved = p_cb(i) where ename = p_ename(i);
    COMMIT;
    else
    if (p_cb2(i) = 'N') then
    update scott.bonus_approval set approved = p_cb2(i) where ename = p_ename(i);
    COMMIT;
    END IF;
    end if;
    end loop;
    end if;
    htp.print('<script language="JavaScript">');
    htp.print('function display() {
    var msg = "\nRecord Saved Successfully\n";
    alert(msg)');          
    htp.print('}');
    htp.print('display()');
    htp.print('</script>');
    exception
    when others then
    htp.print('<script language="JavaScript">');
    htp.print('function display2() {
    var msg = "\nRecord Not Saved.\n";
    alert(msg)');          
    htp.print('}');
    htp.print('display2()');
    htp.p('Not saved');
    htp.print('</script>');
    end;

    Hi.
    I have a dynamic page, with a bind variable :v_day. On the customization screen the user can select one or more days of the week, or all days. I use this also in a report and then it works ok. In the where clause i use:
    and rtrim((to_char(date_time,'DAY'))) IN :v_day
    Date_time is a tablecolumn (date).
    When i add this line in the select script from the dynamic page, i get error:
    : ORA-06550: line 1, column 2443:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    The symbol "(" was substituted for "" to continue.
    ORA-06550: line 1, column 2606:
    PLS-00103: Encountered the symbol ";" when expecting one of the following:
    . ( ) , * @ % & - + / at mod rem <an exponent (**)> and or ||
    The symbol ")" was substituted for ";" to continue.
    ORA-06550: line 1, column 3236:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    The symbol (WWV-11230)
    Critical Error in wwerr_api_error.get_errors! SQL Error Message: ORA-06502: PL/SQL: numeric or value error: character string buffer too small (WWV-)
    Thanks.

  • Using dynamic captions with checkboxes

    Hello.
    I want to create a list of checkboxes, according to a table I get from the context, meaning there would be as much checkboxes as the lines in the table, and their caption would be one of the table's fields.
    I turned on Show Dynamic Properties.
    First I tried it with one checkbox, with it's caption related directly to the table's field, and it worked - but with only one checkbox displaying the first line's value, of course.
    Next I put the checkbox in a subform. The subform is related to the table line, and is repeated for every row, and now the caption is only bound to the field's name, relatively.
    So the subform is repeated, but the caption doesn't change at all.
    How can it be done?
    And can I set the checkbox's caption by code? I tried, but it didn't work.
    Best regards,
    Udi.

    Hi,
    try using table control (supported in ALC 8.0) and add the checkboxe in the row.
    You can then map your data node (structure) with the table.
    Ashutosh

  • Can't create dynamic html elements with jsp????? important

    Hi All,
    I am having problem creating dynamic html elements with jsp tags, i have tried to use EL and java scriplet, both of them don't work.
    i am trying to create dynamic menu in my "rightMenu.jspf", based on, if user has logged in or not.
    some like this!
    <jsp:if test ="${validUser == null}">
    some simple text menu here
    </jsp:if>
    but it is not working. it simply loading all and images with in statement, regardless of whether user has logged in or not. i think some how if statement is not working properly.
    "validUser" is a session bean, which is not creating at this point, it will created when user will log in successfully. and also this session bean does not exist at the page, where i am trying to check that .
    Is there any way to create dynamic values in jsp. It is really important, is there any body who help me in this matter. i would be really grateful.
    zaman

    hi jaspre,
    thanks for replying me. you know what, is it not something wrong with web.xml file. i remember once, i deleted some from there, a property with "*.jsp". i can't remember what exactly was it though.
    all if statements works on files ending with extension ".jsp" but don't work only on with extension ".jspf". there must be to do with this.
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <servlet>
    <servlet-name>ValidateServlet</servlet-name>
    <servlet-class>ValidateServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>ValidateServlet</servlet-name>
    <url-pattern>/ValidateServlet</url-pattern>
    </servlet-mapping>
    <servlet>
    <servlet-name>dwr-invoker</servlet-name>
    <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
    <init-param>
    <param-name>debug</param-name>
    <param-value>true</param-value>
    </init-param>
    <init-param>
    <param-name>pollAndCometEnabled</param-name>
    <param-value>true</param-value>
    </init-param>
    </servlet>
    <servlet-mapping>
    <servlet-name>dwr-invoker</servlet-name>
    <url-pattern>/dwr/*</url-pattern>
    </servlet-mapping>
    <session-config>
    <session-timeout>
    30
    </session-timeout>
    </session-config>
    <welcome-file-list>
         <welcome-file>
    main.jsp
    </welcome-file>
    </welcome-file-list>
    </web-app>
    if any one can figure it out. i would be grateful.
    zaman

  • Servlet with no dynamic code inside jsp pages

    Hello,
              I saw that a servlet is created even if there is no dynamic code inside jsp pages (scriplets & tags). Is it possible to avoid it on bea side ? (I am using portal 8).
              By the way, do you know if is it possible to define apache in order to avoid to send to bea the jsp which have no dynamic code inside ?
              thank you !

    JSP's always generate a servlet on all web containers. Apache/Tomcat is no
              different. If you have static content, make it an HTML page.
              Bill
              "hournon jc" <[email protected]> wrote in message
              news:22255787.1103297053148.JavaMail.root@jserv5...
              > Hello,
              >
              > I saw that a servlet is created even if there is no dynamic code inside
              jsp pages (scriplets & tags). Is it possible to avoid it on bea side ? (I am
              using portal 8).
              >
              > By the way, do you know if is it possible to define apache in order to
              avoid to send to bea the jsp which have no dynamic code inside ?
              >
              > thank you !
              

  • Dynamic HTML elements with JSP?

    I need to have a row in a HTML page which contains of a combox and two text fields.
    Depending on what I select in the combox I have to insert another row (which contains another combox and two text fields) or I have to remove one or both text fields from the current row.
    Is that possible with JSP?
    Many thanks

    You can certainly accomplish what you're asking for in a jsp. One of the tricks you can use to solve your problem would be to pass variables back into the page using the Get method and catching the values using the request.getParameter() technique. One quick tip, you should wrap any request.getParameter() elements with a try catch, if you try to grab a parameter that hasn't been defined yet (and this is perfectly acceptable) you'll get a null returned.
    I hope this helps

  • Help with dynamic checkbox from database results

    Hi,
    I am creating some dynamic checkboxes from the results of a database read to sqlite.  I am able to get the data and the correct number of checkboxes is being created but I'm having a problem populating the labels for the checkboxes.  Here is the section of code that gets the results from the database and creates the checkboxes.
                    var result:Array = stmt.getResult().data;
                    for each( var obj:Object in result )
                        var cb:CheckBox = new CheckBox();
                        cb.label = obj.toString();
                        cb.setStyle("color", 0x00593B);
                        cb.setStyle("symbolColor", 0x000000);
                        container.contentGroup.addElement(cb);                   
    Neil

    This was answered on another forum for me.
    The line cb.label = obj.toString();
    needed to be changed to the data.
    cb.label=obj.myDatabaseFieldName;
    myDatabaseFieldName would be whatever column you are pulling the data in from and should be the actual name in the table.
    Neil

  • Dynamic Table with two columns

    Hi!
    i have to create a Dynamic Table with two columns having 5-5 links each with some text...... three links r based on certain conditions....they r visible only if condition is true...
    if the links r not visible in this case another links take it's place & fill the cell.
    links/text is coming from database.
    i am using Struts with JSP IDE netbeans
    Please help me
    BuntyIndia

    i wanna do something like this
    <div class="box_d box_margin_right">
              <ul class="anchor-bullet">
              <c:forEach items="${data.faqList}" var="item" varStatus="status"
                        begin="0" end="${data.faqListSize/2-1}">
                        <li>${item}</li>
                   </c:forEach>
              </ul>
              </div>
              <div class="box_d">
              <ul class="anchor-bullet">
              <c:forEach items="${data.faqList}" var="item" varStatus="status"
                        begin="${data.faqListSize/2}" end="${data.faqListSize}">
                        <li>${item}</li>
                   </c:forEach>
              </ul>
              </div>
    wanna divide table in two columns....if one link got off due to condition other one take it's position...
    I have created a textorderedlist
    Bunty

Maybe you are looking for