Populating Listbox in JSP!

Hi folks,
Im new to JSP and have been trying to figure out how to populate a listbox using JSP code.
I was hoping to get names from a database and add these names to the listbox.
Any help or suggestions would be greatly appreciated.
Thanks in Advance..

The FormattedDataSet can easily do this with a couple lines of code. Check out the java docs and live demo with sample code at http://www.fdsapi.com

Similar Messages

  • Dynamic listBox in JSP

    {noformat}Hi Everyone
    I am having one listbox in jsp its contain some data like(one,two,three,four), i want
    to drag and drop action in list box.
    Example:-
    one
    two
    three
    four
    if i drag one to four (after drag and drop action) it'll display
    two
    three
    four
    one
    now if i drag three to four (after drag and drop action) it'll display
    two
    four
    three
    one
    please give me some sample code.
    thanks in advance,
    A.Nayak
    (don't use Swing and Applet)
    {noformat}

    Javascript is not the same as Java. Try here: [http://www.webdeveloper.com].
    Asking for code without showing any effort from your side is not so smart. Not here and also not at other coding forums. This way you only show how lazy and dumb you are. Rather ask technical questions, you will likely get better help sooner. If you really need someone else to develop for you, better try here: [http://www.rentacoder.com] or [http://www.freelancers.net]. Or if you want help for free, then try to [ask questions the smart way|http://www.catb.org/~esr/faqs/smart-questions.html].

  • Populating combobox in jsp page from javabean using jsp:getProperty tag

    hi,
    i am new to jsp, so i don;t know how to populate a combobox in jsp page with productid attribute from a javabean called Bid . i want to have a code to automatically populating combobox using the attribute value from javabean.
    please reply me.
    <jsp:useBean id="bidpageid" class="RFPSOFTWARE.Bid" scope="session" />
    <jsp:setProperty name="bidpageid" property="*"/>
      <table  width="50%" align="center" border="0">
       <tr>
        <td  width="30%" align="left"><h4><b><label>Date (dd/mm/yyyy) </label></b></h4> </td>
        <td><input type="text" name="date" size="11" maxlength="10" readonly="readonly" value="<jsp:getProperty name="bidpageid" property="date"/>"  > </td>
      </tr>
      <tr> <td > </td> </tr>
      <tr>
        <td  width="30%" align="left"><h4><b><label>ProductId </label></b></h4> </td>
        <td><select name="productid" tabindex="1" size="1" >
          <option  value="<jsp:getProperty name=bidpageid" />Sachin</option>
          <option value="Hello">Vishal</option>
        </select></td>
      </tr>  and the javabean for Bid is as follow :
    import java.util.Date;
    import RFPSOFTWARE.Product;
    public class Bid{
    private Product product;
    private Integer bid_id;
    private String description;
    private Date date= new Date();
    public Integer getBid_id() {
    return bid_id;
    public Date getDate() {
    return date;
    public String getDescription() {
    return description;
    public Product getProduct() {
    return product;
    public void setBid_id(Integer bid_id) {
    this.bid_id = bid_id;
    public void setDate(Date date) {
    this.date = date;
    public void setDescription(String description) {
    this.description = description;
    public void setProduct(Product product) {
    this.product = product;
    }

    No Sir,
    I think I did not explained clearly.what I try to say is I dont want to use JSTL.I am using only Scriptlets only.I can able to receive the values from the database to the resultset.But I could not populate it in Combobox.
    My code is :
    <tr>
    <td width="22%"><font color="#000000"><strong>Assign To Engineer</strong></font></td>          
    <td width="78%">
         <select NAME="Name" size="1">
    <option><%=Username%></option>
    </select> </td>
    </tr>
    in HTML
    and in Scriptlets:
    ps1 = con.prepareStatement
              ("SELECT Username FROM Users");
              rs2=ps1.executeQuery();
              System.out.println("SECOND Succesfully Executed");
              while(rs2.next())
                   System.out.println("Coming inside rs2.next loop to process");
                   Username=rs2.getString("Username");
                   System.out.println("Success");
                   System.out.println("The value retrieved from UsersTable Username is:"+Username);
    In the server(Jboss console) I can able to display the username but I could not populate it in the Combobox .
    Can you now suggest some changes in my code,Please..
    Thanks a lot
    With kind Regds
    Satheesh

  • Display of dynamic data in Listbox in jsp usin Struts

    Hi,
    I am trying to display a List in a jsp in Struts.
    I have written a Action form and am populating a Arraylist in a DAO(java class file).
    ArrayList.add(rs.getString(1),rs.getSTring(2));
    But I do not know how to display the arraylist in JSP using the struts tag libraries.
    Please let me know how this can be done.
    Thanks in advance.
    Sri

    Use logic:iterate or nested:iterate.
    You can refer to:
    http://forum.java.sun.com/thread.jspa?threadID=5164152&messageID=9629275#9629275
    http://struts.apache.org/1.x/struts-taglib/tlddoc/index.html
    SirG

  • Copy listbox between jsp pages

    Trying to have an action that will copy the entire listbox from 1 jsp page to another, not just the selected items.

    You can achieve it in the following ways:
              <b>1. Put the List Box values in Session context</b>
              <b>2. Put the List Box values in application context</b>
              You cant use Struts action to achieve this.
              Thanks and regards,
              Paz

  • Creating Windows like ListBox with JSP/Java

    I know I might be going out on a limb here, but I have a client that would like us to build a HTML Select tag that would act like the ListBox in Windows. For example, if I have a Select list of Last Names + First Names. If the user starts to type in "SMI" the select box will go to the "SMITHS". This will help narrow the users search. Now, I have seen an example of this done in VBScript, but we are running Apache/Tomcat on Solaris boxes so that won't work for us. I would appreciate to hear any comments suggestions on a solution for this. I am really curious that a 3rd party component builder hasn't already designed a component like this for JSP/Servlets.
    Thanks,
    Dave Hatz

    I have tried looking through the JavaScript forums, I have had no luck at all....

  • Populating values in jsp without submitting the form

    Hi,
    I have a jsp page in which i have 2 select boxes. The values to these select boxes should come from database. When i change the selection of select box, the corresponding values from database should be displayed in the other select box without submitting the form.
    How to accomplish that.
    Any one having any idea about how to implement this stuff, please reply.
    Thanks in advance,
    Joby.

    You should devide the JSP into two frames and make one frame size to 0 so it should not be visible to the use ,and put one jsp in this frame ,tht will work as the hidden jsp.
    now in other frame put ur main jsp and on the change event of th select call a java script function and in this function pass the parametr to the hidden jsp like
    parent.frames["hiddenframename"].document.location="hiddenJspName.jsp?parameter1=value1
    and now in hodden jsp populate the data frm database based on passed parameter and after getting the data fillup the select on the second frame.
    try it and if not work thn write me...
    Bye.

  • Dynamicaly populating textbox in same same jsp page

    hi,
    i have a list box like
    <select name="ss">
    <option value="1">one
    <option value="2">two
    <option value="3">three
    </select>
    if i select "one" from list box than two text should be populated in same jsp page.
    please tell me how to achive this.

    It isn't a disturbance, it just looked different then what it is.
    My favorite way of doing this is to create the three text boxes, but hide two of them (and disable them). Then use the javascript function to show and enable them... like this:
    <html>
    <head>
    <script type="text/javascript">
      function showBoxes() {
        selectElem = document.getElementById("ss");
        selectedValue = selectElem.options[selectElem.selectedIndex].value;
        text2 = document.getElementById("text2");
        text3 = document.getElementById("text3");
        if (selectedValue==1) {
          text2.style.display = "none";
          text2.disabled = "disabled";
          text3.style.display = "none";
          text3.disabled = "disabled";
        if (selectedValue==2) {
          text2.style.display = "inline";
          text2.disabled = null;
          text3.style.display = "none";
          text3.disabled = "disabled";
        if (selectedValue==3) {
          text2.style.display = "inline";
          text2.disabled = null;
          text3.style.display = "inline";
          text3.disabled = null;
    </script>
    </head>
    <body>
    <form>
    <select name="ss" id="ss" onchange="showBoxes();">
      <option value="1" selected="selected">One</option>
      <option value="2">Two</option>
      <option value="3">Three</option>
    </select><br/>
    <input type="text" name="text1" id="text1" style="display:inline;"/>
    <input type="text" name="text2" id="text2" style="display:none;" disabled="disabled"/>
    <input type="text" name="text3" id="text3" style="display:none;" disabled="disabled"/><br/>
    <input type="submit"/>
    </form>
    </body>
    </html>

  • Populating JSF ListBox from DataBase

    Hi,
    im new to JSF and i have a problem populating Listboxes with database values.
    i have 3 listboxes and the 3 are populated from tables in my database.
    I would like to filter the returned(from database) values in the 2nd listbox depending on the value selected in the 1st listox.
    I dont know how to do this.
    BTW i'm usis Ibatis Abator to map the database.
    tnx

    Here is what I think you are wanting to do:
    1. Have the list box show values from a database table.
    2. Have the user make selections. Should the user return to that page later in the session, have the previous selection still selected.
    Normally, you would bind the listbox to the database table, as is shown in http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/databoundcomponents.html. The only reason I can think of for not binding directly to the database table is if there is a possiblity that the database table can change (additions, updates, deletes) during the user's session.
    Are you able to emulate the above tutorial using the Postgress database? It might be good to pinpoint whether the problem is with the Postgress driver or with the code you are writing.
    By the way, if you use a data provider to access the database, as shown in the tutorial, here is how you iterate through the data
            try {
                myDataProvider.cursorFirst();
                do {
                    [build your options list here]
                } while (myDataProvider.cursorNext());
            } catch (Exception ex) {
                error("put your message here" +
                        ex.getMessage());
                log("put your message here: " +
                        ex.getMessage(), ex);
            }You are correct to bind the selected property to a session bean property in order to perserve the user selecitons through the user's s session.

  • JSP Listbox  delete  user interface

    I have requirement on a web application where I need to develop an user interface to show the list of itmes on the list box and allow the user to remove the items from the list box on a JSP page. The information shown on the list box is retrieved from the HTTPSession object.
    I am not sure how do I capture user events on listbox on JSP. I think 'Javascript' can be used to capture the user interaction with the list box but I am not sure how do I communicate the from Java script to JSP.
    I would appreciate feedback and suggestions.
    Thanks
    Nathan

    All the user interaction on a JSP page is done with JavaScript.
    You will use JavaScript to capture the events and manipulate
    your list box.
    Communication with a JSP (or servlet) would be done by submitting
    the form which contains the listbox. Example:
    <form action='yourJsp.jsp' method='post'>
    <select name='list' size='1'>
    <option value='1'>one
    <option value='2>two
    </select>
    </form>

  • Select all in listbox

    Hi guys,
    I have a question.
    I have a from xml populated listbox and want to select by pushing a button all populated items in the list.
    this is my code.
    the interesting thing is, that this code works before I import xml data, but as soon as i import xml data, it doesnt work anymore.
    Do you have any idea, what the problem is and how can I fix it?
    and second question. Is it possible deselect single items, when all are selected?
    var temp1 = "";
    for (i=0;i< PAGE3.ListBox1.length.rawValue;i++){
        temp1 = temp1 + ListBox1.getDisplayItem(i) + "\n";
    ListBox1.rawValue = temp1
    Thank you in advance for any help!!
    Diana

    The code should work as long as you set "Allow Multiple Selection" at design time.
    However I will suggest small change to your code...try the following...
    var temp1 = "";
    for (i=0;i< PAGE3.ListBox1.length;i++){
        temp1 = temp1 + ListBox1.getDisplayItem(i) + "\n";
    ListBox1.rawValue = temp1
    Hold "Ctrl" btn for deselcting from the list.

  • Display selected item from Listbox

    hi,
    i get <h:selectOneListbox> value from database, now i want to know which item is selected in the listbox
    my JSP code is
    <h:selectOneListbox binding="#{DynamicListBean.std_list_lbx}" id="std_list_lbx" immediate="true"
                                onchange="common_timeoutSubmitForm(this.form, 'std_list_lbx');" required="true" size="5"
                                style="height: 312px; left: 168px; top: 192px; position: absolute; width: 216px" value="#{DynamicListBean.selectedCategory1}" valueChangeListener="#{DynamicListBean.std_list_lbx_processValueChange}">
                                <f:selectItems id="listbox1SelectItems1" value="#{DynamicListBean.items1}"/>
                            </h:selectOneListbox>Java code is public String getSelectedCategory1() {    
            return selectedCategory1;
        public void setSelectedCategory1(String selectedCategory1) {
            this.selectedCategory1 = selectedCategory1;
    public void std_list_lbx_processValueChange(ValueChangeEvent vce) {
            connection();
            int n1 = 0;
            String a = "";
            if (con != null) {
                try {
                    stmt = con.createStatement();
                    String query = "select std_id, std_name from std_detail";
                    rs = stmt.executeQuery(query);
                    String iddata = "";
                    if (rs != null) {
                        while (rs.next()) {
                            iddata = rs.getString("std_id");
                      //      System.out.println(rs.getInt("std_id"));
                            stmt1 = con.createStatement();
                            String query1 = "select chpt_detail from chapter_detail right outer join std_detail on chapter_detail.std_id = std_detail.std_id where chapter_detail.std_id = " + iddata + " ";
                            String data3 = "";
                            rs1 = stmt1.executeQuery(query1);
                            if (rs1 != null) {
                                while (rs1.next()) {
                                    data3 = rs1.getString("chpt_detail");
                                    chpt_lst_lbx.setValue(data3);
                                    dList2.add(data3);
                                stmt1.close();
                                rs1.close();
                                List selectItems = new ArrayList();
                                Iterator it = dList2.listIterator();
                                while (it.hasNext()) {
                                    String label = (String) it.next();
                                    chpt_lst_lbx.setValue(label);
                                    selectItems.add(new SelectItem(label));
                                items2 = (SelectItem[]) selectItems.toArray(new SelectItem[0]);
                        stmt.close();
                        rs.close();
                        con.close();
                } catch (Exception e) {
                    System.out.println("Sorry failed to display values from the database table. " + e.getMessage());
                    System.out.println(e);
        }any idea or suggestion tell me

    You usually use the property behind value="#{DynamicListBean.selectedCategory1}" for that. But in your case you'll need the vce.getNewValue() as the valueChangeListener is been invoked before the property is been set.
    Having said that, your code is terrible. Please read on about the DAO pattern. Further on, did you know that you can also just use List<SelectItem> instead of SelectItem[] as f:selectItems value?
    If you want to populate child menu's, you may find this article useful to avoid future and painful problems: [http://balusc.blogspot.com/2007/10/populate-child-menus.html].

  • How to access a variable from a dynamically included JSP page

    I have a jsp (say main.jsp) using the following in its code :
    <jsp:include page="menu.jsp" flush="true" />
    I have a variable in menu.jsp which I would like to use in my main.jsp.
    How do I get the value of the variable defined in menu.jsp ?
    I called this variable in menu.jsp, Public, but this didnot help me use the value of that variable in main.jsp
    Any help is highly appreciated.. thnks a lot

    I do notice the variable var1 has the value populated - in menu.jsp - (from View -->
    Source in the browser) but for some reason not able to use it in main.jspI'm not quite sure of the way your jsps are structured from your code snippet but I think there is something to be aware of here that may be part of your problem, namely the difference between the include directive and the include action.
    You are currently using the include action, this treats the included resource as a dynamic object - i.e. a request is sent to that resource and the resulting response is included in your page. So when you think of what there is no java variable actually included - you'll just get the resulting HTML that is generated by menu.jsp
    The include directive, as in <%@include file=�menu.jsp � %>, on the other hand treats the resource as a static object. This means the actual bytes in the included resource are inserted into the including jsp and then the result of that is compiled and processed, effectively you are cutting and pasting the menu.jsp into your calling jsp. In this case the variable would be available to the calling jsp.
    However this approach does bring other difficulties that may break your current code, you'll just have to try it and see what happens.
    Hope that's relevant to your problem,
    Matt

  • Passing struts-tag value to java / javascript variable in JSP

    Hello all,
    Im trying to pass the value got from the struts-tag to the java variable in the Jsp. However Im not able to get the o/p. Can u guys help me on this pls...
    <logic:notEmpty name="TreeBean" property="list">
        <logic:iterate id="Type" name="TreeBean" property="list" indexId="i">
         <br/><bean:write name="Type" />
        </logic:iterate>
    </logic:notEmpty>Here the list can be populated in the jsp page. However i want the values into jsp list. Im not able to populate the same..
    <% List jspList = null;
    %> I want the values into the jspList variable for further processing. Can u guz pls help me on this....

    Which do you want it in?
    A java variable for use in <% scriptlet code %> or a javascript variable for use on the client end?
    scriptlet:
    <jsp:useBean id="TreeBean" type="java.util.List" class="java.util.ArrayList" scope="?????" />
    Having scriptlet code on the page is considered bad coding style.
    What is it you are trying to accomplish by making the value accessible?
    What are you trying to do in java / javascript that can't be done with JSP tags?

  • Custom filed at line item level in order.jsp

    Hi,
    I want to add a custom material number field at the line item level that will search for the item related to the customer material number and populate the order.jsp.
    similar to the below mentioned Standard functionality:-
    In order.jsp when we enter a valid item no in the item text box
    and press enter then the related data of the item is populated in order.jsp.
    Is this possible ??
    If yes please let me know how can we achiese this.

    Satish,
    the problem with product search is that ....
    custommaterial number will be mapped with the item number for different customers in a separate table. so if i place the searc in proucts search tab it will fetch form product master.
    so I was think of extending the process flow and from jsp capture the value entered and trigger action from there make a item search following the standard process.
    but my problem is that I am not able to capture the value entered in the custom field when refresh is clicked?
    can you tell me how is the item search done when we enter the item number and press enter?
    please suggest

Maybe you are looking for

  • Problem opening Form based PDF via Safari browser with Adobe Reader 9.3 on MAC

    Hi, I'm mentioning below the problem that we are facing when we open a form based PDF created using a licensed version of Adobe Livecycle Designer ES (Version 8.2.1.4029.1.523496) on a MAC machine through a Safari Browser. We tested this PDF form on

  • MS NLB with ASA and Static NAT from PUP to NLB IP

    Hi all, I am trying to get MS NLB up and running.  It is almost all working.  Below is my physical setup. ASA 5510 > Cat 3750X >2x ESXi 5.1 Hosts > vSwitch > Windows 2012 NLB Guest VMs. I have two VMs runing on two different ESXi hosts.  They have tw

  • Performance Issue with ver. 1.1.1

    Hello - I have also recently downloaded the latest iPhone software and now apprear to be experiencing performnace issues on my iPhone. It frequently does not recognize an action. For example, when I SLIDE to turn it on, sometimes I have to do it 3 or

  • Trying to go wireless on my G 3 B

    Trying to configure wireless connection to my G 3 B&W  tower...any ideas

  • Duplication of JE

    Hi All,          My Clients Requirment is that,Duplication of JE should not occur for if i am putting REF 1. field twice i.e if for the first time once the JE is done for suppose Ref.1= 2020.Now if i am posting the JE for the same REf. No. 2020 it sh