How to display the values stored in the database in the combobox on load?

I am develping one application where in
I wanted to display the values in the combobox which I am taking from the database and in the same form passing that value in same form after selecting it,My program is running fine for the first time but next time it is giving me NullPointerException.
So can anyone tell me please how I should develop the this application to avoid this exception?
Thank You
Praddy

Thanx a lot for showing interest in answering my query.I am pasting my code for ur reference.Please try to reply ASAP.
Thank You,
Praddy.
CODE:
======
<html>
<head>
     <script language="javascript">
          function submitthisform(thisForm)
               thisForm.submit();                    
     </script>
</head>
<body>
<form method=post name=samepgm>
Select City:     <select name=city onChange='submitthisform(samepgm)'><br><br><br>
<option value=''></option>
<option value='All'>All</option>
<%@ page language="java" import="java.sql.*" %>
<%
          String scity = request.getParameter("city");
          System.out.println(scity);
          Connection con = null;
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          con = DriverManager.getConnection("jdbc:odbc:property","","");
          Statement st = con.createStatement();          
          ResultSet rs1 = st.executeQuery("select distinct hcity from housefinance");
          while(rs1.next())
               //String ohname = rs1.getString("hname");     
               String     ocity = rs1.getString("hcity");     
               //out.println(ohname +"<br>");
               out.println(ocity +"<br>");
%>
<br><br><br><option value='<%=ocity%>'><%=ocity%></option><br>
<%               }
               rs1.close();
          if(scity.equals("All"))
          ResultSet rs2 = st.executeQuery("select * from housefinance");      
          while(rs2.next())
               String     ohname = rs2.getString("hname");     
               String     ohadd1 = rs2.getString("hadd1");
               //String ohadd2 = rs2.getString("hadd2");
               String     ohcity = rs2.getString("hcity");
               String     ohpcode = rs2.getString("hpcode");
               String     ohtelno = rs2.getString("htelno");
               String     ohfaxno = rs2.getString("hfaxno");
               String     ohemail = rs2.getString("hemail");
               String     ohmobile = rs2.getString("hmobile");     
%>
<pre>
<tr>
<td><p>Company          :     <%=ohname%> </p></td>
<td><p>Address          :     <%=ohadd1%></p></td>
<td><p>City          :     <%=ohcity%> </p></td>
<td><p>Pin          :     <%=ohpcode%></p></td>
<td><p>Telphone          :     <%=ohtelno%></p></td>
<td><p>Fax No:          :     <%=ohfaxno%></p></td>
<td><p>Email          :     <%=ohemail%></p></td>
<td><p>Mobile No.     :     <%=ohmobile%></p></td>
</tr>
</pre>
<%
          else
ResultSet rs = st.executeQuery("select * from housefinance where hcity like '%"+scity+"%'");
          while(rs.next())
               String     ohname = rs.getString("hname");     
               String     ohadd1 = rs.getString("hadd1");
               //String ohadd2 = rs.getString("hadd2");
               String     ohcity = rs.getString("hcity");
               String     ohpcode = rs.getString("hpcode");
               String     ohtelno = rs.getString("htelno");
               String     ohfaxno = rs.getString("hfaxno");
               String     ohemail = rs.getString("hemail");
               String     ohmobile = rs.getString("hmobile");     
%>
<tr>
<td><p>Company          :     <%=ohname%> </p></td>
<td><p>Address          :     <%=ohadd1%></p></td>
<td><p>City          :     <%=ohcity%> </p></td>
<td><p>Pin          :     <%=ohpcode%></p></td>
<td><p>Telphone          :     <%=ohtelno%></p></td>
<td><p>Fax No:          :     <%=ohfaxno%></p></td>
<td><p>Email          :     <%=ohemail%></p></td>
<td><p>Mobile No.     :     <%=ohmobile%></p></td>
</tr>
<hr>
<%               }
%>
</select>
</form>
</body>
</html>

Similar Messages

  • How to display text value in the header data (Header text) of credit memo

    Hi...
    I need to display the text value of the text field in the header text of the header data in credit memo.
    The text values are stored in a ztable and i need to display it based on the billing document stored in vbrk (zfield) that was inserted during the creation of credit request..
    Appreciate your help on how to do this...
    Thansk and will surely reward the points..
    Kanthi..

    Hi kanthi ,
                   Read the value from Z Table and during the creation of cedit memo check out for some exit where u the value from The zTABLE AND use function module SAVE_TEXT with object and id in the header text .
    Please award if useful.

  • How to find out the type of the value stored in a string variable?

    Hi,
    How do i find out the type of the value stored in a string variable?
    for example,
    I have a string variable str, in which the following type of values wil be stored
    1) Intger
    2) Long
    3) boolean
    4) Char
    Is there any method to find out the type of the value, anything like str.getType()?. Please kindly help me. Thanks in advance.

    Hi All, i'm sorry for the double posting, by mistake it occured.
    Thanks for your replies, i have a string variable str, in which the value is stored and i have another string variable type, in which the type of the value is stored.
    For example,
    String str = "15";
    String type = "Integer";
    Is there any way to verify whether the value stroed in str is of type stored in the variable 'type'. I want to write a method of type boolean, it will throw true of the value stored in str is of type 'type'. Thanks

  • How can i get the value stored in the session object using its sessionid

    how can i get the value stored in the session object using its sessionid by running stand alone java application

    myforum wrote:
    how can i get the value stored in the session object using its sessionid by running stand alone java applicationThis does not seem to make sense! You need at least to give a lot more detail of what you are doing.

  • How to compare the values stored in the list

    Hi,
    I am having the requirement that i want to compare the values stored in the list.How to store the values in the list and compare the list values stored inside it.
    Regards,
    Ahamad

    http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collections.html#sort(java.util.List)
    http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collections.html#sort(java.util.List,%20java.util.Comparator)
    http://java.sun.com/j2se/1.5.0/docs/api/java/util/Comparator.html
    http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Comparable.html

  • How to display success message when data is changed in the custom tab in MM

    Hi,
    I have added a new custom data tab in the MM01/MM02/MM03 transactions. Whenever I do changes to fields in the custom tab in MM02 transaction, and no changes in the standard tabs, I will get a message stating "No Changes Made".
    But if I do changes in the standard tabs, it works as usual with display of message "Changes to particular material has been done.
    Please let me know, if anyone of you know, how to display the success message if the changes to the custom tab is done.
    Thanks in advance,
    sudhanva

    Hi Sudhanva,
    The exit EXIT_SAPLMGMU_0001 is a function exit that you can use for custom validation but not to add custom tab/screen.
    But the message issued by SAP is not related to this Function Exit.
    If you have used a Screen Exit, then there must be some Function Exits also in the same Enhancement using which you can assign the value of custom fields to/from the standard structure. Thus when the value of any custom field is changed the system can understand that the some changes have been changed and will  not issue the message.
    In case you have used a BADI, there can be other methods in the BADi using whcih you can assign the value of custom fields to/from the standard structure. This might also prevent the message from being displayed.
    I could try giving you further details if you can provide the name of the Enhancement/BADi that you used to add the additional tab.
    Hope this helps.
    Regards,
    Abhisek.

  • I need to add the values stored in the session object into the html textbox

    Dear Sir,
    i have been trying to create an edit employee details page
    What i have done till now is as follow:
    1. Got employee id from HTML page.
    2. Compared it with the id stored in the database.
    3. If the id is correct then pulled the record of the corresponding employee and stored it in the session object.
    4. Dispatched the session values to another servlet EditEmpDetails2.java
    what i need to do now
    5. Now i need to set the session values in the text field of the html form
    6. I also need to be able to edit those vales and store the edited values in the database.
    Please help me as i have tried doing it for 1 week without any clues
    i have tried to create a html page which is something like this:
    <html>
    <head>
    <title>Edit Employee Details Page</title>
    <body BGCOLOR="red" text="black">
    <h1 ><font color="black">Edit Employee Details Page</font></h1>
    <form action = "EditEmpDetails" method="Get">
    <table width="50% align="center"
    <tr><td>Employee ID: </td>
    <td><INPUT TYPE="TEXT" name="employeeid"<br></td></tr>
    <tr><td><center><input type="submit" value="submit"></center></td></tr>
    <tr><td><center><input type="reset" value="reset" ></center></td></tr>
    </table>
    </form>
    </body>
    </html>
    design of my servlet EditEmpDetails.java
    public void EditEmpDetails1 extends HttpServlet
    public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException
    PrintWriter out = response.getWriter();
    response.setContentType("text/html");
    HttpSession session = request.getSession();
    String employeeid;
    String X = request.getParameter("employeeid");
    System.out.println("Employee iD:" + X);
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:murphy");
    String query = "Select * from users where employeeid=?";
    PreparedStatement stat = con.prepareStatement(query);
    System.out.println(stat);
    stat.setString(1,X);
    ResultSet rs = stat.executeQuery();
    while(rs.next())
    String Z = rs.getString(password);
    if(Z.equals(X))
    String A = rs.getString(1);
    session.setAttribute("employeeid", A);
    String B = rs.getString(2);
    session.setAttribute("firstname", B);
    String C = rs.getString(3);
    session.setAttribute("lastname", C);
    String D = rs.getString(4);
    session.setAttribute("gender", D);
    String E = rs.getString(5);
    session.setAttribute("dateofbirth", E);
    String F = rs.getString(6);
    session.setAttribute("address", F);
    String G = rs.getString(7);
    session.setAttribute("postalcode", G);
    String H = rs.getString(8);
    session.setAttribute("phone", H);
    String I = rs.getString(9);
    session.setAttribute("mobile", I);
    String J = rs.getString(10);
    String url = "/EditEmpDetao;s.java";
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url)
    dispatcher.forward(request,response);
    catch (Exception e)
    system.out.println(e)
    I do not know how to put the values stored in the session object into the html text box

    3. If the id is correct then pulled the record of the corresponding employee and stored it in the session object.do you really need to store this in session object?
    5. Now i need to set the session values in the text field of the html form which form? in a new html/jsp page? i suggest go for a JSP
    In your JSP page use JSP expression tags to put the session attributes.
    it's something like : <input type='text' name='employeeid' value='<%= session.getAttribute("employeeid") %>' >and you need to generateanother servlet for saving the details/modifications to the database.
    I think i m clear enough.
    if you need more clarifications. just try it and then post your problem.
    Diablo

  • How do I insert the value of an email field in the submit mailto: argument?

    I want to create a button that will redirect a PDF form to an email address entered as a field in the form.  In other words, a "return to sender" function.  The button function has a submit to URL where you can use "mailto:[email protected]".  How can I substitute the value from an email field in the form itself for the "[email protected]" value?

    You'll need to use JavaScript, and the mailDoc method in particular: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.505.html
    Get the value of the field that contains the email address and use it as the value of the cTo property. See the following for a sample script: http://forums.adobe.com/message/3553628?tstart=-1

  • How to display query variable in text element and format the text element

    Hi All,
    I want to display the value of the value of variable against fiscper3 and the value of the variable against 0fiscyear in the web application template from the query in the text element in the web template in BI 7 Web application designer.
    Also, in the web application designer I need to format the text element in the web application designer to set the text element to center the display change the size and make it bold. I am bit lost I cannot find these properties in the web application designer against the text element.
    Appreciate if you could kindly help.
    Thanks
    Karen

    Hi
    hope below tags would help you
    Re: Search by text on a variable
    Re: Need to display text part of TEXT variable in query designer
    regards
    nag

  • Finding the average of all the values stored in a two dimentional array

    public int avg(int[][] numbers2){
        int sum = 0;
        float avg = 0;
        for(int r = 0; r < numbers2.length; r++)
          for(int c = 0; c < numbers2[r].length; c++){
              sum += numbers2[r][c];
          }So I have this code that of course finds the sum of all the values stored in the array int[][] numbers. What I am having an issue with is finding the average of the numbers. When I attempt to use:
    avg = sum / numbers2.length; I get the sum / 3 because my array looks like:
    int[][] numbers2 = {{1, 2, 3},
                                {4, 5, 6},
                                {7, 8, 9}
                                          };Any ideas on what I should do or where I could find information on this process?

    2 dimensional arrays have 2 lengths:
    myArray.length and myArray[0].length
    The first one I believe is fixed, the second one may vary from row to row. But if you know that it won't vary, then you can just use the [0] row length.

  • How can get the value of a HtmlInputText (created in the bean)

    Hi All,
    I have created a HtmlInputText object in the Backing Bean (the getter and setter are in another Bean used to manage the data, getEditableInputText and setEditableInputText)
    //getter and setter in Bean
    public HtmlInputText getEditableInputText() {
    return this.editableInputText;}
    public void setEditableInputText(HtmlInputText editableInputText) {
    this.editableInputText = editableInputText;
    I set the value in the Backin Bean
    The HtmlInputText is bound in the xml in this way:
    <h:inputText id="test" binding="#{Bean.editableInputText}"></h:inputText>
    When I load the page I can see the TextField with the value that I set previously (in the backin bean).
    The problem is when I try to change the value of the texField:
    I change the value, then I click on a button (its action is to call a method to get the value of the field).
    In debug mode I see that the value is allways the first set instead of the new value inserted.
    I tried with getValue and similar but it does not work.
    I tried also to put HtmlInputText in a panel (using a similar logic) and then to get it using getChildren() method but also this does not work.
    Any idea?
    Thanks in advance

    Ok (now I understand)
    I have used bean.getEditedInputText() and it is not null.(I got the HtmlInputTextObject)
    But bean.getEditedInputText().getValue has allways the first value set.
    If I don't set previously the value (in the backin bean) the getValue() is allways null.
    So my problem is that I can set but I cannot get the Value when I change it.
    Edited by: LucaMane on Nov 16, 2008 5:13 AM

  • How to upload a Flat file into sap database if the file is in Appl'n Server

    Hello Sap Experts , Can you tel me
    " How to upload a Flat file into sap database if the file is in Application Server.
    what is Path for that ?
    Plz Tel Me its Urgent
    Thanks for all

    Hi,
    ABAP code for uploading a TAB delimited file into an internal table. See code below for structures.
    *& Report  ZUPLOADTAB                                                  *
    *& Example of Uploading tab delimited file                             *
    REPORT  zuploadtab                    .
    PARAMETERS: p_infile  LIKE rlgrap-filename
                            OBLIGATORY DEFAULT  '/usr/sap/'..
    DATA: ld_file LIKE rlgrap-filename.
    *Internal tabe to store upload data
    TYPES: BEGIN OF t_record,
        name1 like pa0002-VORNA,
        name2 like pa0002-name2,
        age   type i,
        END OF t_record.
    DATA: it_record TYPE STANDARD TABLE OF t_record INITIAL SIZE 0,
          wa_record TYPE t_record.
    *Text version of data table
    TYPES: begin of t_uploadtxt,
      name1(10) type c,
      name2(15) type c,
      age(5)  type c,
    end of t_uploadtxt.
    DATA: wa_uploadtxt TYPE t_uploadtxt.
    *String value to data in initially.
    DATA: wa_string(255) type c.
    constants: con_tab TYPE x VALUE '09'.
    *If you have Unicode check active in program attributes then you will
    *need to declare constants as follows:
    *class cl_abap_char_utilities definition load.
    *constants:
    *    con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB.
    *START-OF-SELECTION
    START-OF-SELECTION.
    ld_file = p_infile.
    OPEN DATASET ld_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    IF sy-subrc NE 0.
    ELSE.
      DO.
        CLEAR: wa_string, wa_uploadtxt.
        READ DATASET ld_file INTO wa_string.
        IF sy-subrc NE 0.
          EXIT.
        ELSE.
          SPLIT wa_string AT con_tab INTO wa_uploadtxt-name1
                                          wa_uploadtxt-name2
                                          wa_uploadtxt-age.
          MOVE-CORRESPONDING wa_uploadtxt TO wa_upload.
          APPEND wa_upload TO it_record.
        ENDIF.
      ENDDO.
      CLOSE DATASET ld_file.
    ENDIF.
    *END-OF-SELECTION
    END-OF-SELECTION.
    *!! Text data is now contained within the internal table IT_RECORD
    * Display report data for illustration purposes
      loop at it_record into wa_record.
        write:/     sy-vline,
               (10) wa_record-name1, sy-vline,
               (10) wa_record-name2, sy-vline,
               (10) wa_record-age, sy-vline.
      endloop.

  • How to display 7 values of  single field in row wise.

    hi,
    how to display 7 values of  single field in row wise.
    thankx in advance.

    hi ,
    do it like this :
    1 Place ur UI element in tranparent container with Layout as Row Data and Layout Data as Row Head Data
    2 Ur first  UI , which contains the first value as Row Head Data ,
    3 Others as Row Data
    u can do it with Matrix Data as well
    if u want to give space , u can use HORIZONTAL GUTTER and set its width to medium / large / Xlarge
    also there is a UI element "INVISIBLE ELEMENT" ,
    1 u can use this UI element to provide space between ur other UI elements in the view
    2 u can insert a text element as well , and in the Text property of the element press ALT + 0160.
    u can give the space bw UIs as desired.
    regards,
    amit

  • How to display filter values in analyzer

    Hi expert,
          I want to add filter into analyzer, above data table, I insert a few rows, and add text to hold filters, but after quit from design mode, inserted rows for filters dispear, and its spaces are taken by data table. could you please tell how to display filter values .
    Many Thanks,

    It is looking like you are saving them as workbooks. It will be possible to maintain fliters if you save with the filters given by workbook properties, not by manual feeding.
    let us know with clear expectation if you are not clear with it.

  • How to display negative values in a screen field of a screen

    Hi All,
    Please let me know how to display negative values in a screen field of a screen.
    thanks

    Hi Kishore,
    You can do this method. In the screen , create a text field of CHAR instead fo creating an INT4 field.
    I have created a field of CHAR of name say TEXT.
    In the main program,
    declare a variable of the same name ie. TEXT.
    data: TEXT(5) TYPE C.
    In PBO, just assign the negative values.
    It will work.Since there is automatic conversion between character and integer data types, it will work for positive values as well.
    Regards,
    Sylendra.

  • DB2Exception - The value of a host variable in the EXECUTE or OPEN statemen

    I want to store a XML file into database.
    To undersdande my problem, please see the code below:
    java.sql.Connection conn = null ;
    PreparedStatement ps;
    // Here I'm calling a function to get Database Connection.
    String sXmlFile = "" ; // This variable stores a XML file as String
    String sSQL = "INSERT INTO Crs_x_xml (XML_TRAN_ID,XML_MESSAGE,SUSPENDED_FLAG ) VALUES(?,?,?)";
    try {
         ps = conn.prepareStatement(sSQL);
         ps.setLong(1,1);
         ps.setBytes(2, sXmlFile.getBytes());
         ps.setString(3,"A");
         ps.executeUpdate();
         conn.close();
    } catch (Exception e) {
         e.printStackTrace();
    The Problem:
    The table Crs_x_xml that I used has three columns, the first is a int, the second is a BLOB and third is Char(1) and its in DB2 running on AIX.
    Sometimes it execute very well. But sometimes gives following error :=
    COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/AIX64] SQL0302N The value of a host variable in the EXECUTE or OPEN statement is too large for its corresponding use. SQLSTATE=22001
    I dont know whats going wrong. Plz help....
    ~Abhijeet

    Hi,
    I am using a CMP query in websphere, in which i am trying to execute a select query.
    The query is as follows:
    SELECT OBJECT(o) FROM HrTmmbrAct o WHERE o.tmmbrActC IN ( 1,2,3 ) AND o.effD BETWEEN '2000-02-11' AND '2008-02-22'
    The tmmbrActC is defined as a string in the Websphere CMP fields. I am not sure now to pass the value to it. Do we need to pass it as objects. pls help.
    Thanks
    - Giri

Maybe you are looking for

  • How to Print Check in Batches?

    Hi All, I am looking for functionality of printing check in Batches. I am trying with this from Collaboration Window. I tried with Menu>>Setting>>General >>Printer.but there is no Printer came up.I don't know how to get printer option over here. Can

  • OS X and OS 9.2.2 aren't playing nicely with each other

    Hi! Im'm having a problem with OS X and OS 9.2.2 cohabitating on my computer. Here's what I've done so far: I have 5 drives on my computer: 1) Dedicated to OS 9.2.2; 2) Backup for OS 9.2.2 (cannot boot from this drive; it has replaced the Zip drive o

  • Flash to Photoshop - colour help

    Hello, A friend and I have designed an image in Flash that we'd like to print at A1 size. As Flash won't export to this height and width, we're pulling together the different bits of the Flash image as .ai files inside Photoshop Elements 7. The only

  • Turning sound off on camera shutter?

    completely new to Droid here.  I have looked every where for something that will turn the shutter sound off of the camera when taking pictures.  Anyone have a clue?

  • Name of WP trace file

    Hi all, In my system I can see that my WP trace files are named like dev_w + number, but I have found function module GWY_READ_WP_FILE which is using hardcoded value dev_wp + number. My question is, is it an error in this FM or have these files in pa