Jsp drop down

hi everyone,
i m using jsp and struts... n new to these technologies..
i want to populate a drop down menu on jsp... from the values in the action class...
i need to know..
1) whether this approach is correct.. bcoz i m reading values from a file in my action class... do u suggest to put it into some model layer ??
2) how can i achieve the functionality ie. populating the combo box from action class/model layer
need ur help guys..will b really thankful
Message was edited by:
aryan.kapoor

<html:select property ="fileVal" size="1" style="width: 250px">
<option value="" selected>Default</option>
<html:optionsCollection property="fileValues" value="id" label="name"/>
</html:select>     have corressponding getter/setters in action form class.
In your BO (model), process the file and have the data collection. You can have a Data Transfer Object (DTO) to store the data.
from your action (controller), call the BO and set the data for the drop-down.

Similar Messages

  • Execute option missing from JSP drop down menu

    I'm going through a Java Web Development class and trying to produce a small web app through Sun Java Studio Enterprise 7 2004Q4. I have two servlets, a couple of classes and two JSPs. At seemingly random times the "Execute" and "Execute (force reload)" options from the drop down menu you get when you right click a JSP fails to show up. It isn't grayed out, it just isn't there. Most of the time these options are there. And they can be there one time and then for the same project, same set of JSPs everything, they just disappear.
    Can anyone tell me what dumb thing I'm doing to cause this?
    And can anyone tell me how to fix it once I've done it?
    Thanks
    DR Crowley

    First of all thank you for all the time you are spending on this. Believe me I know how frustrating it can be to figure out what is happening when you can't reproduce the problem.
    On to your questions: I am running Windows XP Professional. I have checked and made sure that the extension is still .jsp and that it isn't changing. No I don't have the IDE set up to show extensions, however the icon beside the file is the jsp icon and when I go to Windows explorer (where I do have it set to show known extensions) it is a .jsp file and does not have the ever exasperating hidden extension that windows is infamous for. Sun Studio seems to recognize the file as a proper jsp (due to the icon).
    As to your further questions. I am executing it by right clicking on the jsp file itself. And the jsp file is in the documents folder not in the web/inf folder.
    At this point we are out of the class and it isn't nearly as important that I get an fix. We (our company) will probably not do jsp files and servlets thourgh Sun Java Studio Enterprsise. Instead we are looking at using Sun Java Studio Creater to do the view layer.
    Thanks for all your help and the time you took to try to figure this out.

  • Q: Another jsp drop-down menu problem+propeblem with savng button

    Well i have many problems:
    Starters i use eclipse with tomcat and postgres. I have to create a jsp page that shows some data directly from database.
    This is what i have so far:
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <%@ page import="property.core.Property"  %>
    <jsp:useBean id="PropertyDAO" scope="page" class="property.dao.PropertyDAO" />
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Vaata Vara</title>
    </head>
    <body>
    <script>
    function salvesta(){
    document.forms[0].mida_teha.value='salvestada' ; //salvesta=save and mida_teha=action
    document.forms[0].submit();
    </script>
    <input type='hidden' name='mida_teha' value='<%=request.getParameter("mida_teha") %>'>
    <form action='pg?mode=vaata_vara' method=POST>
    <input type='hidden' name='property' value='<%=request.getParameter("property") %>'>
    Valitud vara: <br>
    <% if((request.getParameter("property"))!=null){
    int property = Integer.valueOf(request.getParameter("property")).intValue();//
    String property_type="";
    String property_name ="";
    String property_created = "" ;
    String property_created_by ="" ;
    String property_updated = "" ;
    String property_updated_by ="" ;
    property.core.Property my_property ;
    if (request.getParameter("mida_teha") != null){
         my_property = PropertyDAO.GetProperty_fromDB(property);
         my_property.setProperty_name(request.getParameter("property_name"));
         my_property.setProperty_updated(request.getParameter("property_updated"));
         //my_property.getProperty_updated_by(request.getParameter("property_updated_by"));
         PropertyDAO.UpdateProperty_to_DB(my_property);
    out.println("<table border=1 cellpadding=0 cellspacing=0><tr><td><table"+
              "width=100% border=1 cellpadding=2 cellspacing=1>");
    if ((my_property = PropertyDAO.GetProperty_fromDB(property)) != null){
         property= my_property.getProperty() ;
        property_type = my_property.getProperty_type() ;
            property_name = my_property.getProperty_name() ;
        property_created = my_property.getProperty_created() ;
        property_created_by= my_property.getProperty_created_by() ;
        property_updated = my_property.getProperty_updated() ;
        property_updated_by= my_property.getProperty_updated_by() ;
         out.println("<TR BGCOLOR='#ffffff'><TD BGCOLOR='#cccccc' nowrap>ID</td><td> " + property + " </TD></tr>");
         out.println("<TR BGCOLOR='#ffffff'><TD BGCOLOR='#cccccc' nowrap>Tyyp</td><td> <SELECT ><OPTION value="+my_property.getProperty_name()+" 'name='property_type'>"+property_type+"</OPTION></SELECT> </TD></tr>");
         out.println("<TR BGCOLOR='#ffffff'><TD BGCOLOR='#cccccc' nowrap>Nimetus</td><td> <b><font color='#0000ff'><input type='text' value='"+ property_name + "' name='name'></font></b></TD></tr>");
         out.println("<TR BGCOLOR='#ffffff'><TD BGCOLOR='#cccccc' nowrap>Loodud</td><td> "+ property_created + " </TD></tr>");
         out.println("<TR BGCOLOR='#ffffff'><TD BGCOLOR='#cccccc' nowrap>Looja</td><td> " + property_created_by + " </TD></tr>");     
         out.println("<TR BGCOLOR='#ffffff'><TD BGCOLOR='#cccccc' nowrap>Uuendatud</td><td> <b><font color='#0000ff'><input type='text' value='"+ property_updated + "' name='updated'></font></b></TD></tr>");
         out.println("<TR BGCOLOR='#ffffff'><TD BGCOLOR='#cccccc' nowrap>Uuendaja</td><td> " + property_updated_by + " </TD></tr>");     
    out.println("</table></td></tr></table>");
    %>
    <input type="button" value="muuda vara" onClick="muuda_vara()">
    <input type="button" value="salvesta" onClick="salvesta()">
    </form>
    </body>
    </html>The problem is that i have no clue(allthough i have chekced the forums for help and experimented and i still could not make it work) how to make a dropdown menu for out.println("<TR BGCOLOR='#ffffff'><TD BGCOLOR='#cccccc' nowrap>Tyyp</td><td> <SELECT ><OPTION value="+my_property.getProperty_name()+" 'name='property_type'>"+property_type+"</OPTION></SELECT> </TD></tr>"); this. I have tryed http://forum.java.sun.com/thread.jspa?forumID=45&threadID=5241837 this page and that messes my "" up. If anyone can give me any tips how to integrate that code what is posted in the link to mine please let me know.
    Second problem is that when i push the save button, then i get a runtime error and a joyce to i want to debug or not. And as well in the example which i got from the teacher works just fine.
         //my_property.getProperty_updated_by(request.getParameter("property_updated_by")); this without the // get the not aplicable error as well(that in my other class file which is linked to this jsp the parameter is not aplicable). i managed to make in other jsp problem identical problem go away by adding a declaration of string and adding that string into the getParameter and this case everything should be okei, but it is not :(
    Anyway property.jsp uses property.java to get the getParameter and setParameter, PropertyDAO is the database stuff (connecting to database, getting data from the database).
    To be on the safe side i will add my propertyDAO.java
    package property.dao;
    import java.sql.* ;
    import property.core.Property ;
    import property.log.MyLogger ;
    import java.util.*;
    public class PropertyDAO {
        private int propertycount ;
        ResultSet VaraHulk ;
        String sql ;
        String url = "jdbc:postgresql://localhost/database";
        String usr = "";
        String pwd = "";
        Connection db ;     
        Statement  st ;
        Property [] VaraMassiiv  ;
        Property Current_Property ;
      public PropertyDAO(){
           try{
                   ResourceBundle bundle = ResourceBundle.getBundle("DBConnection");
                    this.url = bundle.getString("URL");
                    this.usr = bundle.getString("usr");
                    this.pwd = bundle.getString("pwd");
                    Class.forName(bundle.getString("Driver"));
           }catch(Exception ex){
                MyLogger MyLogger = new MyLogger();
               MyLogger.Log("dao.propertyDAO():",ex.getMessage());
           public Property [] getProperty_fromDB(){
                try{
                     this.db = DriverManager.getConnection(this.url, this.usr, this.pwd);
                     this.st = this.db.createStatement();
                    sql = "select count(*) as varade_arv from property" ;
                    VaraHulk = this.st.executeQuery(sql);
                    while(VaraHulk.next()){
                         this.propertycount = VaraHulk.getInt("varade_arv");
                    sql = "select property, property_type.name AS property_type, property.name AS property_name, " +
                              "property.created AS property_created, employee.first_name "+
                  "AS property_created_by, property.updated AS property_updated,employee.first_name AS property_updated_by" +
                  " from property, property_type, employee where property_type."+
                  "property_type=property.property_type and property.created_by=employee.employee ORDER by property" ;
                    VaraHulk = this.st.executeQuery(sql);
                    VaraMassiiv = new Property[this.propertycount];
                    int cnt = 0;
                    while(VaraHulk.next()){
                         Current_Property = new Property();   
                         Current_Property.setProperty(VaraHulk.getInt("property"));
                         Current_Property.setProperty_type(VaraHulk.getString("property_type"));
                      Current_Property.setProperty_name(VaraHulk.getString("property_name"));
                      System.out.println("getProperty_name:" + Current_Property.getProperty_name() );
                      Current_Property.setProperty_created(VaraHulk.getString("property_created"));
                      System.out.println("getProperty_created:" + Current_Property.getProperty_created() );
                      Current_Property.setProperty_created_by(VaraHulk.getString("property_created_by"));
                      System.out.println("getProperty_created_by:" + Current_Property.getProperty_created_by() );
                      Current_Property.setProperty_updated(VaraHulk.getString("property_updated"));
                      System.out.println("getProperty_updated:" + Current_Property.getProperty_updated() );
                      Current_Property.setProperty_updated_by(VaraHulk.getString("property_updated_by"));
                      System.out.println("getProperty_updated_by:" + Current_Property.getProperty_updated_by() );
                      VaraMassiiv[cnt] = Current_Property ;
                      cnt =  cnt + 1;
                       this.db.close();
                }catch(Exception ex){
                     MyLogger MyLogger = new MyLogger();
                    MyLogger.Log("property.getProperty_fromDB():",ex.getMessage());
                return VaraMassiiv;
           public Property GetProperty_fromDB(int property){
                try{
                     this.db = DriverManager.getConnection(this.url, this.usr, this.pwd);
                    this.propertycount = 0;
                    this.st = this.db.createStatement();
                    sql = "select property, property_type.name AS property_type, property.name AS property_name, property.created AS property_created, employee.first_name "+
                  "AS property_created_by,property.updated AS property_updated, employee.first_name AS property_updated_by" +
                  " from property, property_type, employee where property_type."+
                  "property_type=property.property_type and property.created_by=employee.employee and property.property =" + Integer.toString(property) ;
                    VaraHulk = this.st.executeQuery(sql);
                    while(VaraHulk.next()){
                         Current_Property = new Property();
                      Current_Property.setProperty(VaraHulk.getInt("property"));
                      Current_Property.setProperty_type(VaraHulk.getString("property_type"));
                      Current_Property.setProperty_name(VaraHulk.getString("property_name"));
                      System.out.println("getProperty_name:" + Current_Property.getProperty_name() );
                      Current_Property.setProperty_created(VaraHulk.getString("property_created"));
                      System.out.println("getProperty_created:" + Current_Property.getProperty_created() );
                      Current_Property.setProperty_created_by(VaraHulk.getString("property_created_by"));
                      System.out.println("getProperty_created_by:" + Current_Property.getProperty_created_by() );
                      Current_Property.setProperty_updated(VaraHulk.getString("property_updated"));
                      System.out.println("getProperty_updated:" + Current_Property.getProperty_updated() );
                      Current_Property.setProperty_updated_by(VaraHulk.getString("property_updated_by"));
                      System.out.println("getProperty_updated_by:" + Current_Property.getProperty_updated_by() );
                      this.propertycount =   this.propertycount + 1;
                    this.db.close();
                } catch(Exception ex){
                     MyLogger MyLogger = new MyLogger();
                    MyLogger.Log("PropertyDAO.GetProperty_fromDB():",ex.getMessage());
                return Current_Property ;
          public void UpdateProperty_to_DB (Property updated_property){
                try{
                     this.db = DriverManager.getConnection(this.url, this.usr, this.pwd);
                     this.st = this.db.createStatement();
                     int stmtInt = this.st.executeUpdate("update property set property_type='" + updated_property.getProperty_type() +
                               "',name=" +  updated_property.getProperty_name() + ",created=" + updated_property.getProperty_created() +
                               ",'created_by='" + updated_property.getProperty_created_by() +  ",updated="+updated_property.getProperty_updated()+
                               ",updated_by="+updated_property.getProperty_updated_by()+
                               "' where property=" + Integer.toString(updated_property.getProperty() ));
                     this.db.close(); 
                }catch(Exception ex){
                        MyLogger MyLogger = new MyLogger();
                        MyLogger.Log("PropertyDAO.UpdateProperty_to_DB():",ex.getMessage());
           public void finalize(){
                 try{
                   System.out.println("finalize");
                  }catch(Exception ex){ 
                    MyLogger MyLogger = new MyLogger();
                    MyLogger.Log("PropertyDAO.finalize():",ex.getMessage());
    }Property.java
    package property.core;
    import property.log.MyLogger ;
    public class Property {
        //private int propertycount ;
        private int property ;
        //private int current_property ;
        private String property_type ;
        private String property_name ;
        private String property_created ;
        private String property_created_by;
        private String property_updated_by;
        private String property_updated;
        public Property(){
             try{
             }catch(Exception ex){
                   MyLogger MyLogger = new MyLogger();
                   MyLogger.Log("core.Property():",ex.getMessage());
        public void setProperty (int property){
             this.property = property;
        public void setProperty_type (String property_type){
             this.property_type = property_type;
        public void setProperty_name (String property_name){
             this.property_name = property_name;
        public void setProperty_created ( String property_created){
             this.property_created = property_created;
        public void setProperty_created_by (String property_created_by){
             this.property_created_by = property_created_by;
        public void setProperty_updated ( String property_updated){
             this.property_updated = property_updated;
        public void setProperty_updated_by (String property_updated_by){
             this.property_updated_by = property_updated_by;
        public int getProperty () {
             return this.property ;
        public String getProperty_type () {
             return this.property_type ;
        public String getProperty_name () {
             return this.property_name ;
        public String getProperty_created () {
             return this.property_created;
        public String getProperty_created_by () {
             return this.property_created_by;
        public String getProperty_updated () {
             return this.property_updated;
        public String getProperty_updated_by () {
             return this.property_updated_by;
        public void finalize(){
             try{
                  System.out.println("finalize");
             }catch (Exception ex){
                   MyLogger MyLogger = new MyLogger();
                   MyLogger.Log("core.Property():",ex.getMessage());
    }(well it took me 3 days to get the code to work that much as it does anyways)
    hope someone here can help
    Edited by: kohuke on May 30, 2008 11:27 AM
    Added few codes that is connected with the current jsp page

    are you sure your stop() are in the right place??
    eg.. on the last frame of the onRollOver animation??
    also... why have you got on(releaseOutside); ???
    onRollOut will suffice.

  • JSP drop down problem; iam confused

    Hi All,
    can anybody help me out in creating this jsp page. Iam confused what to do and where to start building this page.
    Here is what i need to do :
    This new page will have two list boxes side by side and will have two arrows in between. In the left hand box will be a list of "Firm Divisions" that can be selected by using the mouse and arrow button. The user will be able to select one or more of the "Firm Divisions". After the desired "Firm Divisions" are selected the user will click on the SUBMIT button and a message will appear to confirm the request has been sent. The user will then click on the OK button and will be brought back to the previous screen( i.e Pop up a conformation box with a required OK button ).
    CAN ANYBODY HELP ME IN BUILDING THIS JSP PAGE. I can do the backend processes but iam stuck creating this jsp page.

    yes, put at least 2 buttons(or images with <a href>) one for remove and the other for add, and call a JavaScript function while clicked (onClick event)= onClick="javascript:removeFromList();"
    function addToList(){
    form=document.form;
    itemText=form.right_list.options[form.right_list.selectedIndex].text;
    itemValue=form.right_list.options[form.right_list.selectedIndex].value;
    form.right_list.options[form.left_list.selectedIndex]=new Option(itemText,itemValue);
    function removeFromList(){
    form=document.form;
    if (form.left_list.selectedIndex!=-1){
    form.left_list.options[form.left_list.selectedIndex]=null;
    got the idea?
    Nelson.

  • JSP HTML parameter form to call report - Dependent  drop down list

    I have a report parameter form developed using HTML & JSP to call oracle reports6i.
    First parameter "STATES", Second Parameter "CITY"
    I have a master-detail relation betwen STATE & CITY table.
    I want the parameter form drop down lists dependant. ie if the user chang STATE value in the first drop down, the second drop down list CITY shoud
    change automatically.
    Please help
    Thanks
    Vimal

    Vimal,
    This is not functionality that's available in the Reports generated parameter form. In order to do this you'll need to build the parameter form yourself as a true HTML form and code the javascript to link the fields.
    Hope this helps,
    Danny

  • Getting problem in hiding drop down list in jsp pages

    Hi All,
    I have a jsp in which i created a tabbed panel & put 3 forms .
    1 of the form contains 3 drop dwom list & few text boxes.
    All 3 forms are inside <div> tags .
    Clicking on any one of the tab corresponding form is getting displayed with all its form fields hiding other 2 form fields.
    but problem is coming with 1 form having drop down list.
    all its field get hidden except these drop down list.
    i am using following script to hide other forms
    function showit(tab){
        if(tab == "tab1stuff"){
            document.getElementById('tab1stuff').style.zIndex="2";
            document.getElementById('tab2stuff').style.zIndex="1";
            document.getElementById('tab3stuff').style.zIndex="1";
              document.getElementById('tab4stuff').style.zIndex="1";
        else if(tab == "tab2stuff"){
            document.getElementById('tab2stuff').style.zIndex="2";
            document.getElementById('tab1stuff').style.zIndex="1";
            document.getElementById('tab3stuff').style.zIndex="1";
              document.getElementById('tab4stuff').style.zIndex="1";
        else if(tab == "tab3stuff"){
            document.getElementById('tab3stuff').style.zIndex="2";
            document.getElementById('tab1stuff').style.zIndex="1";
            document.getElementById('tab2stuff').style.zIndex="1";
              document.getElementById('tab4stuff').style.zIndex="1";
    }Plz help me in this regard.
    I used style.visible="false" but that is not working here.
    Thanks in advance.

    Thanks you very much.
    Now I am using javascript
    if(tab == "tab1stuff"){
            document.getElementById('tab1stuff').style.visibility="visible";
            document.getElementById('tab2stuff').style.visibility="hidden";
            document.getElementById('tab3stuff').style.visibility="hidden";
            document.getElementById('tab4stuff').style.visibility="hidden";
        } Its working ..Earliar it was PHP script.

  • Dynamically create drop down box with JSP

    Hi,
    I hope this is not a repeat post, I have search the forum and a posting has not jumped out at me. I am making a jsp that dynamically constructs a custom SQL query.
    I have a number of text boxes with an id, my jsp page calls a servlet, the servlet reads the contorl id and the value to build the query - this works great. However, there's a large text input box which receives a number of extra conditions - this text box receives the input in the following format:
    searchAttributeName1,searchAttributeValue1;searchAttributeName2,searchAttributeValue2
    This is functional, however, it's a bit rubbish as the user has to know the special recognised attributeNames. What I would like to have is some sort of criteria control. This would consist of a drop down box populated from the servlet, a text input for the value and a button to add another criteria control. so the user could build up the number of query criteria. The drop down box ensures they cannot select the wrong keyword, pressing the add criteria button adds a new drop down box and text box pair to the screen.
    An example of this I recently saw was at Intel's jobs search web site https://jobs.intel.com/jobs/jobs.iccw - see that for example.
    Has anyone got any ideas on how to achieve this? I initially thought use jsp scripting (there is no restriction against this) but I need to use javascript I'm guessing as the button click triggers adding a new combo box. Another idea was to use styles and tables to hide the other drop down boxes but this seems like a real hack that I'd like to avoid. I can do with with .NET i hope java can deliver!
    Any ideas are much appreciated - I am a novice with java web development so please, any examples thoroughly explain (no need to explain populating the drop down box - there seem to be plenty of posts on this).
    Thanks for any help or ideas on this issue -

    Gina,
    Here is some sample code for using a ComboBox in a JSP from an EditCurrentRecord bean. This particular example uses a query, you can also populate combo boxes, list boxes, radio buttons and checkboxes from a static list. See the JavaDocs for the EditCurrentRecord bean.
    <jsp:useBean id="RowEditor" class="oracle.jbo.html.databeans.EditCurrentRecord" scope="request">
    <%
    RowEditor.initialize(application, session , request, response, out, "wt_bc_WT_bcModule.WalkthroughEngineSlidesView");
    RowEditor.setTargetUrl("WalkthroughEngineSlidesView_SubmitInsertForm.jsp");
    RowEditor.createNewRow();
    RowEditor.setReleaseApplicationResources(true);
    RowEditor.useComboBox("Presname","select pres_name,pres_name from wt_info","PRES_NAME","PRES_NAME");
    RowEditor.render();
    %>
    </jsp:useBean>
    null

  • Problem in sending drop down list value to jsp page showing  null value

    i am trying to send a drop down list value from client side to a jsp page but getting null value
    this is first page where i have accessed data from database and putted it in a drop down list
    <select name="sub">
         <%
         while(rs2.next())
         cat=rs2.getString(1);
         %><option value="<%=cat%>"><%=cat%></option><%
         }%></select>
    <input type="submit" value="Go"></input>
    now on submit i am going to another page
    where i want the selected value from drop down list to be printed
    i have used there
    <%
    String subject= request.getParameter( "sub.value" );
    out.println(subject);
    %>
    but it is printing null here what is the problem that i m facing
    thanx & reagrds
    sweety

    how to generate dynamically names for text boxes
    i am generating text boxes in while loop when selecting data from database
    while(rs1.next())
    name=rs1.getString(1);%>
    <tr>
    <td>1</td>
    <td><%out.println(name);
    //i am printing here stud_id a unique key and want to update records from following text boxes to particular stud_id
    %></td>
    <td><input type="text" name="????"></input></td>
    <td><input type="text" name="????"></input></td>
    <td><input type="text" name="????"></input></td>
    <td><input type="text" name="????"></input></td>
    </tr><%
    the structure is like
    stud_id | attended theory | conducted theory | ateended practical | conducted practical
    where attended theory, conducted theory............. are to be inputed manually for all students and then update in database
    so i am facing problem in generating names for textboxes how to do that
    so that those can be updated in database for particular student
    Thanx & Regards
    sweety

  • Loading data in a drop down menu using jsp

    hello everyone...
    I'm very new to JSP programming....i'm facing a problem regarding loading the data in a drop down menu at the button click.....
    what i'm doing is...i'v taken a button and at the button click the data from "Sql Server 2000" shd load in a drop down menu....here's the code which i think will make my point clear....
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <%
              Connection con=null;
              ResultSet rs=null;
              try
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   con=DriverManager.getConnection("jdbc:odbc:p_portal");
                   Statement stat=con.createStatement();
                   String sql="select * from message_box where name='anindo'";
                   rs=stat.executeQuery(sql);
                   %>
    <script language="javascript">
    function check()
         var show=document.getElementById("mydivtag");
         show.innerHTML = "<label><select name=select><% while(rs.next()){%><option><%= rs.getString(1) %></option><option><%= rs.getString(2) %></option><option><%= rs.getString(3).substring(0,10) %></option></select></label><%}}catch(Exception ex){out.print("Exception is:- "+ex);}%>";
    </script>
    </head>
    <body>
    <form id="form1" name="form1" method="post" action="">
      <label></label>
      <p>       
        <input type="submit" name="Submit" value="Submit" onclick="check()" />
           </p>
      <p>       
       </p>
      <div id="mydivtag" ></div>
      <p> </p>
    </form>
    </body>
    </html>

    yep Ajax is d right way 2 do so.
    So can use DWR(ajax tech.) for dis/
    To implement dis dere r simple steps u hav 2 follow
    1. entry for <dwr> tag in web.xml
    2. entry for <onverter>in web.xml
    3. In jsp u write
    <script type="text/javascript" src="<%=appName%>/dwr/engine.js"></script>
    <script type="text/javascript" src="<%=appName%>/dwr/util.js"></script>
    <script type="text/javascript"src="<%=appName%>/dwr/interface/ClassService.js"></script>
    were ClassService is ur class whose method u want 2 call.
    4.
    In jsp under <script> u can simply write
    ClassService.Methodname(param1,param2,....,CallBackFunction);
    5.CallBackFunction(data)
    /// do wt u want
    For more details u can find it on google.

  • Drop-down in JSP using a bean as back-end

    Hi everyone,
    I like to create a dynamic drop-down (reading from a database) using JSP but accessing a bean. My code on the bean is:
    public void DepartmentName() {
    try
    stmt1 = tConnection.createStatement();
    rs1 = stmt1.executeQuery ("select DEPT_NAME from DEPARTMENT");
    while ( rs1.next() )
    String DptName = rs1.getString("DEPT_NAME");
    System.out.println(DptName);
    Can anybody tell me how to call this DepartmentName bean in JSP? So far my JSP looks like this...
    <table width="100%"><tr>
    <form action="next.jsp" method="POST">
    <input type="hidden" name="type" value="listemp">
    <td width="100">
    <b>Department</b></td>
    <td wifth="100">
    <SELECT name=cust multiple size=4>
    <option>??????? HELP ???????????</option>
    </SELECT>
    </td>
    <td><input type="submit" value="Submit" name="dept">
    </td></tr></table>
    Many thanks.

    First you need to modify your bean to return some sort of data structure of String objects. How about a Vector? Then you could call Vector.elements() on the return statement of the DepartmentName() method, like this...
    public Enumeration DepartmentName()
      Vector myVector = new Vector(0);
      while(rs.next())
        myVector.add(rs.getString(1));
      return myVector.elements();
    }Then in your JSP you'll need to use the JSP useBean tag
    <jsp:useBean id="myBean" class="com.myco.myapp.MyBean" scope="page|request|session|application" />And before the option tag call the bean and get the enumeration of String objects, then loop through them like this:
    while(enum.hasMoreElements())
      out.println(((String) enum.nextElement()));
    }

  • JSP problem - drop down combo boxes

    Hi,
    I want to load a database table value into my HTML form's dropdown combo box.
    Actually I want to do this. I need to change employee information. To do this there is a form to enter empNo. Then it will display a .jsp page with the relevant fields of that employee. In this .jsp page, it has a drop down combo box for title. In my db the required title of that employee is Miss.
    But how could I display this value in this dropdown combo box. Then the user can change it as she wish.
    I try it like this way, but it isn't work.
    <select size="1" name="title" style="border: 1px solid #0000FF">
           <jsp:getProperty name="candidate" property="title" />
    </select>     Can anybody tell me hoe to solve this?
    Thanks.

    Hi,
    Thanks for your help.
    I have change that code, as follows.
    <select size="1" name="title" style="border: 1px solid #0000FF">
    <option value="" ><jsp:getProperty name="candidate" property="title" /></option>
    </select> Now it displays the correct title. But how can I display the other 2 options below this? that is Mr. and Mrs. Because the user must have the facility to select Miss. or Mrs. if there any changes she wish to apply.
    Note:
    If a user has a title - Mr. , then the other 2 titles (Miss,Mrs) should be display below it.
    How to solve this?
    Thanks

  • How to display information from database using drop down list in JSP?

    Hi all.
    Like the tile above suggest, I'm having difficulty in obtaining the data as well as displaying them in a drop down list.
    For example: If i were to have the following in my database:
    SerialNo Food
    1 Bread
    2 Milk
    3 Butter
    The drop down list should look like the following:
    [Bread][\/]
    [Milk]
    [Butter]
    How do i go around coding it in JSP?
    Thanks in advance.
    C.K

    Hai Please try the following code
    You have to make some changes according to your system i am using
    MSSqlserver Driver change the class name and the connection string
    for your need
    <HTML>
    <HEAD>
    <%@ page language="java" import="java.sql.*"%>
    <LINK href="../theme/Master.css" rel="stylesheet" type="text/css">
    <TITLE>ListDrop.jsp</TITLE>
    <%!Connection con;
         %>
    </HEAD>
    <BODY>
    <select>
         <%
              try {
                   Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");\\Here you specify the Class Nale
                   con = DriverManager
                             .getConnection(
                                       "jdbc:microsoft:sqlserver://javaserver:1433;DatabaseName=karthi",
                                       "sa", "sa");\\here Connection string
                   ResultSet rs;
                   Statement st = con.createStatement();
                   rs = st.executeQuery("select SerialNo,Food from Foods");
                   while (rs.next()) {
    %>
         <option value='<%= rs.getString("SerialNo") %>'><%= rs.getString("Food")%></option>
         <%
              } catch (Exception e) {
                   e.printStackTrace();
    %>
    </select>
    </BODY>
    </HTML>

  • Drop Down list issues in jsp

    Hi,
    I am facing an issue with drop down list in jsp pages on page postback. Let me explain in detail. I have a client.jsp page which has a drop down list and a text box. The drop down list is populated from an Action class (lets say testAction.java). In the client action form class there is a validation which requires the user to enter some value in the text box.
    So here is the problem, when the client.jsp page loads, the drop down list is populated perfectly, but then the user clicks submit button without entering anything in the textbox, the page loads again with an error message ("Please enter some value in the textbox"). At this point the drop down list does not contain any value. Any ideas what could I do?
    I am posting the code here for individual pieces,
    Struts-config.xml_
    <action path="/client" type="com.myapp.struts.testAction" scope="session">
    <forward name="success" path="/createClient.jsp"/>
    </action>
    <action input="/createClient.jsp" name="ClientActionForm" path="/createClient" scope="session" type="com.myapp.struts.ClientAction">
    <set-property property="cancellable" value="true" />
    <forward name="success" path="/loginSuccessful.jsp"/>
    <forward name="cancel" path="/Welcome.do"/>
    </action>
    index.jsp_
    <h5><html:link action="/client" styleClass="purplelink">Create a new client</html:link></h5>
    testAction.java_
    public ActionForward execute(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response)
    throws Exception {
    ArrayList<String> arrList = new ArrayList<String>();
    arrList.add("sports");
    arrList.add("music");
    arrList.add("test 1");
    arrList.add("test2");
    request.setAttribute("mylist", arrList);
    return mapping.findForward(SUCCESS);
    createClient.jsp_
    <select name="droplist">
    <c:forEach var="itemName" items="${mylist}">
    <option><c:out value="${itemName}" /></option>
    </c:forEach>
    </select>
    <html:text property="clientName" />
    ClientActionForm_
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
    ActionErrors errors = new ActionErrors();
    if (getclientName() == null || getclientName().length() < 1) {
    errors.add("name", new ActionMessage("error.name.required"));
    return errors;
    Here is the process/page flow.
    index.jsp is the first page which is loaded.
    Link on index.jsp calls action="/client"
    This pulls mapping from struts-config and calls testAction.java
    This populates the arraylist and returns to the createClient.jsp page (mapping from struts-config.xml)
    Now createClient.jsp page has two fields (dropdown list and textfield=clientName) and a submit button
    if user clicks submit, clientActionForm is called and does not enter anything into clientName text field, error message is returned.
    At this point, the drop down list in createClient.jsp is not populated and is returned as empty, even though the scope=session in struts-config.xml
    Please provide some inputs on how can I handle this issue.
    Thanks
    Ashish

    I think one solution would be instead of putting the list in the request, but it in your ActionForm.
    Add a field to the ClientActionForm with getters and setters.
    Then change your action.
    ArrayList<String> arrList = new ArrayList<String>();
    arrList.add("sports");
    arrList.add("music");
    arrList.add("test 1");
    arrList.add("test2");
    ClientActionForm frm = (ClientActionForm)form;
    frm.setMyList(arrList);
    return mapping.findForward(SUCCESS);

  • Java/JSP app to List Directories in a Drop Down

    Hi all! I'm a Java Newbie and have an application that was written in VB / ASP that I need to convert to Java / JSP. The app is relatively simple, however my understanding of Java is even more basic. :(
    Here's what I need... The app needs to be able to read a directory structure on the web server and populated a drop down box on a JSP with the directory names. Then when one of the directories that are in the drop down are selected, the files within that directory are listed as HTML links to the actual files.
    How do I get started?? Any sample code from people who have done this??
    Thanks!
    Teresa

    Basically what you want to do is build a vector of objects that represent directories, and each "directory" object contains a vector of files as an attribute. This is done on the server side in a Servlet.
    Then store all these objects in your session. Dynamically build your dropdown box to have an element for each directory. Use the JavaScript onSelect method to invoke another JSP that takes the number of the element selected, and displays all html links for the number that was passed in from the previous servlet.
    For some about $150 I would write the whole thing for you, but here would be the server side code that builds a recursive directory list.
    import java.io.*;
    import java.util.*;
    public class RecursiveDirectoryList {
         Vector Directories = new Vector();
         Vector Files = new Vector();
    public RecursiveDirectoryList() {
         super();
    public static void main(String[] args) {
    String directoryName; // Directory name entered by the user.
    File directory; // File object referring to the
    //directory.
    //TextIO.put("Enter a directory name: ");
    directoryName = "C:\\docs";
    directory = new File(directoryName);
    if (directory.isDirectory() == false) {
    // Program needs a directory name. Print an error message.
    if (directory.exists() == false)
    System.out.println("There is no such directory!");
    else
    System.out.println("That file is not a directory.");
    else {
    // List the contents of directory, with no indentation
    // at the top level.
    listContents( directory, "" );
    } // end main()
    static void listContents(File dir, String indent) {
    // A recursive subroutine that lists the contents of
    // the directory dir, including the contents of its
    // subdirectories to any level of nesting. It is assumed
    // that dir is in fact a directory. The indent parameter
    // is a string of blanks that is prepended to each item in
    // the listing. It grows in length with each increase in
    // the level of directory nesting.
    String[] files; // List of names of files in the directory.
    System.out.println("Directory: " + dir.getAbsolutePath());
    indent += " "; // Increase the indentation for listing the contents.
    files = dir.list();
    for (int i = 0; i < files.length; i++) {
    // If the file is a directory, list its contents
    // recursively. Otherwise, just print its name.
    File f = new File(dir, files);
    if (f.isDirectory())
    listContents(f, indent);
    else
    System.out.println("File: " + dir.getAbsolutePath() + "\\" + files[i]);
    } // end listContents()

  • Creating drop down menus in JSP using custom tags

    Hi, i am working on a JSP which has custom tags for displaying menubar and menus, now i want to have these menus converted into drop down menus, and the submenus displayed onmouseover event. I am getting solutions with pure html page calling javascript functions.But i dont need this, i want the work done by my TagHandler class which sends the output to output stream, which in turn is transformed in to actual HTML by a XSLT embedded in my JSP.
    Please help as i am new to custom tags, and desperately in need of help.
    If possible give some sample code or useful links.
    I will be highly grateful.
    Thankx in advance

    that's fine, but the tag has to, ultimately, generate the HTML/Javascript stuff like you've already seen.

Maybe you are looking for

  • Finder crashes when accessing hard drive

    Everything was working fine until I installed Font Doctor and started using it to examine my fonts. It would crashed when I hit this one folder. I tried it again and identified the exact font folder that was causing the problem (or so I thought). I r

  • Dump analysis

    The computer has rebooted from a bugcheck.  The bugcheck was: 0x0000001e (0xffffffffc0000005, 0xfffff88005d86410, 0x0000000000000000, 0x0000000000000000). A dump was saved in: C:\Windows\MEMORY.DMP. Report Id: 031915-16005-01.

  • Replacement speaker for g7-1150US?

    Where can I find a replacement left-hand speaker for a Pavilion g7-1150US? This question was solved. View Solution.

  • Utl_http.request

    Hello every one i m using oracle 10g database and simply try to use this utility utl_http.request so i put the command in sql plus SELECT utl_http.request('http://www.google.com') FROM dual but this showing error ERROR at line 1: ORA-29273: HTTP requ

  • Photo numbering in the IOS7

    Hello, i have the memory of my iphone 5 full. If I cancel all the foto from my iphone, the photo numbering resume from the last foto or will be IMG_0001? thank you