Remove null values from string array

Hi ,
I have a string array in a jsp page which I save some values inside. After I store the values I want to print only those who are not null. How can I do this? Is there a way to delete the null values?

Thank you but because I am new in programming what do you mean to use continue. Can you explain it a little bit further?<%
//go through the array to check all the values
for(int i=0; i<array.length();i++) {
//If array is null, nothing happen
if(array==null){
//leave here blank; instead use continue like:
//this will skip the statements next to it, and increments the value of i in for loop and continues to execute the body of for loop.
//The same will be repeated till the last iteration.
continue;
//If array not null, then print value in a new line
else{
out.print(array+"<br>"); //don't change the logic here
%>

Similar Messages

  • Removing a value from an array

    I have searched the forums, and found many post about this, but with different variances.
    i have an array, where if a user passes an argument that already exists in the array, it will remove that value from the array. when i run the code below i get a boolean exception. i "think" my thinking is correct, but i cannot seem to put it into code terms (HAH! thats a first eh?).
    what exactly be the difference to setting the position to 0 or to null?
    public void remove(int lessNum) throws NotFoundException {
       for( int i=0;i<this.occupied.length;i++) {
            if(occupied.equals(lessNum)
         occupied[i] = null;
         else
         throw new NotFoundException();
    }//end for
    }//end remove
    this is the exception i get: boolean cannot be dereferenced
                        if(occupied[i].equals(lessNum)
    ^
    Thanks,
    J

    Hi.
    (You have a few typos in your code, but I'm assuming that's because you typed it in again when you sent your posting rather than copying and pasting it. Your compilation error is also not consistent with the code, but I'll take a guess at what is going on)
    There are a number of things that are strange about the code example.
    1. It looks like your 'occupied' field is a boolean[] (the compilation error indicates that this is the case). That means each element of occupied is a primitive boolean, not a reference. Therefore trying to dereference it makes no sense. This is what the compiler error is telling you. Note that this is not an exception.
    2. Now looking at the intent of what I think you're trying to do... I think you are trying to determine if element i of the 'occupied' array is equal to the parameter 'lessNum'. This is nonsensical since the elements of 'occupied' are booleans and lessNum is an int.
    3. Finally, trying to set an element of 'occupied' to null, doesn't make sense because the elements of 'occupied' are not references, but primitives.
    Regarding your question about the difference between setting something to 0 or null: I assume you come from a C or C++ background where 0 and null are the same thing. In Java, null is not equivalent to 0 but is instead a special value for a variable of reference type that means that the variable is not currently referring to anything. In C and C++ if a pointer has the value 'null' or 'zero' it simply means that any attempt to dereference it will mean an attempt to look for an object at memory address 0 which will usually result in unimaginable horrors (alright, it's not that bad).
    Regards,
    Lance
    Lance Walton - [email protected]
    Team In A Box - Software without Tragedy
    http://www.teaminabox.co.uk

  • Remove null values from query

    Hi All;
    Below is my query and the output and i need to remove null values from the output
    Any help regarding same is much appreciated
    Thanks
    ; WITH CTE AS
    select a.opportunityid,a.new_entrypoint_displayname,c.parentcustomerid,c.contactid,c.fullname,a.new_mainprogramme_idname,
    a.new_subprogramme_idname,
    a.owneridname,
    a.new_dateofapplication,count(appt.activityid) as NoOfAppointments,
    ap.scheduledstart,
    ap.scheduleddurationminutes
    from opportunity a
    left join contact c on (c.contactid = a.parentcontactid)
    inner join activitypointer ap on ( ap.regardingobjectid = c.contactid )
    inner join appointment appt on (appt.activityid = ap.ActivityId)
    where
    appt.new_didmeetingtakeplace = 1
    and appt.statecode = 1 and
    (a.SCRIBE_DELETEDON is null and c.SCRIBE_DELETEDON is null and ap.SCRIBE_DELETEDON is null and appt.SCRIBE_DELETEDON is null)
    group by a.opportunityid,a.new_entrypoint_displayname,c.parentcustomerid, c.contactid,c.fullname,a.owneridname,
    a.new_mainprogramme_idname,a.new_subprogramme_idname,
    a.new_dateofapplication,ap.scheduledstart,
    ap.scheduleddurationminutes
    union
    select a.opportunityid,a.new_entrypoint_displayname,c.parentcustomerid,c.contactid,c.fullname,
    a.new_mainprogramme_idname,a.new_subprogramme_idname,a.owneridname,
    a.new_dateofapplication,count(appt.activityid) as NoOfAppointments,
    ap.scheduledstart,
    ap.scheduleddurationminutes
    from opportunity a
    left join contact c on (c.contactid = a.parentcontactid)
    inner join activitypointer ap on (ap.regardingobjectid = a.opportunityid)
    inner join appointment appt on (appt.activityid = ap.ActivityId)
    where
    appt.new_didmeetingtakeplace = 1
    and appt.statecode = 1 and
    (a.SCRIBE_DELETEDON is null and c.SCRIBE_DELETEDON is null and ap.SCRIBE_DELETEDON is null and appt.SCRIBE_DELETEDON is null)
    group by a.opportunityid,a.new_entrypoint_displayname,c.parentcustomerid,c.contactid,a.owneridname,
    a.new_mainprogramme_idname,a.new_subprogramme_idname,
    c.fullname,a.new_dateofapplication,
    ap.scheduledstart,
    ap.scheduleddurationminutes
    CTE2 As
    select opportunityid,parentcustomerid,new_entrypoint_displayname,contactid,fullname,
    new_mainprogramme_idname,new_subprogramme_idname,cte.owneridname,
    ac.new_businessstartdate,new_dateofapplication,(NoOfAppointments),
    case when ac.new_businessstartdate > = CTE.scheduledstart
    then (CTE.scheduleddurationminutes) end as PreStartHours,
    case when ac.new_businessstartdate < CTE.scheduledstart
    then (CTE.scheduleddurationminutes) end as PostStartHours
    pp.new_outputs,
    case when po.new_outputsname = 'Pre Start Assist'
    then 'Yes' else 'No' end as Precheck,
    case when po.new_outputsname = 'Business Assist'
    then 'Yes' else 'No' end as Buscheck
    from CTE
    join account ac on (ac.accountid = CTE.parentcustomerid)
    join dbo.new_programmeoutput as po on (CTE.opportunityid = po.new_relatedopportunity)
    join dbo.new_programmeprofile pp on (
    po.new_mainprogrammeid = pp.new_mainprogrammeid and
    po.new_subprogrammeid = pp.new_subprogrammeid
    and pp.new_claimstartdate = po.new_claimdate
    and pp.new_outputsname = po.new_outputsname)
    where (ac.SCRIBE_DELETEDON is null)
    group by opportunityid,parentcustomerid,new_entrypoint_displayname,contactid,fullname,ac.new_businessstartdate,new_dateofapplication,NoOfAppointments,
    scheduledstart,new_mainprogramme_idname,new_subprogramme_idname,cte.owneridname,scheduleddurationminutes
    select opportunityid,parentcustomerid,new_entrypoint_displayname,contactid,fullname,
    new_mainprogramme_idname,new_subprogramme_idname,cte2.owneridname,
    new_businessstartdate,new_dateofapplication,(NoOfAppointments),
    PreStartHours, PostStartHours,po.new_programmeoutputid,
    case when (new_outputsname) = 'Pre Start Assist'
    then 'Yes' else 'No' end as Precheck,
    case when (new_outputsname) = 'Business Assist'
    then 'Yes' else 'No' end as Buscheck --po.*
    from cte2
    left join dbo.new_programmeoutput as po on (cte2.opportunityid = po.new_relatedopportunity)
    where po.new_claimmonthidname is not null and po.statuscode_displayname = 'claimed'
    group by opportunityid,parentcustomerid,new_entrypoint_displayname,contactid,fullname,
    new_mainprogramme_idname,new_subprogramme_idname,cte2.owneridname,
    new_businessstartdate,new_dateofapplication,(NoOfAppointments),
    PreStartHours, PostStartHours,po.new_programmeoutputid,new_outputsname
    --where new_claimmonthidname is not null --and CTE2.PreStartHours is not null and CTE2.PostStartHours is not null
    Pradnya07

     i need to remove null values from the output
    Hello,
    What exactly do you mean with "remove", to filter the rows out from result set or to replace the null value by an other value e.g. 0? This can be done with the
    ISNULL function:
    ISNULL(case when ac.new_businessstartdate > = CTE.scheduledstart
    then (CTE.scheduleddurationminutes) end, 0) as PreStartHours, ...
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Removing Null values from character string

    Hi All,
    Can i remove NULL values (hexadecimal - 0000) from character string. I am uploading a file from presentation layer (shared server) and getting NULL values in many fields which i want to remove.
    please assist.
    Thanks for you help..
    Regards,
    Mohaiyuddin

    Hi,
    Most likely, nobody needed it, but if anybody in future will need the solution for related problem  - here's solution:
    data: lv_nullchar type xstring value '0'.
    shift lv_xstring right deleting trailing lv_nullchar in byte mode.
    shift lv_xstring left deleting leading lv_nullchar in byte mode.
    This hack deleting null chars in lv_xstring at end file and at begining of file. Works perfect for me, where i also worked with files.

  • How to remove null values from list?

    I had created a list in forms 6i and I am getting list values at run time using add_list_item function. The problem is I am getting null value at end of the list. In the property pallet I kept required yes and set the initial value but it is not removing null value. Can any one help me. Thank you.......

    Hello
    Sorry mis-read question on first reply.
    1. Have you set a default value?
    2. Is this default value still in your list?
    3. What happens if you default the list's value to a value you know exists after you have populated it?
    Cheers
    Q
    Message was edited by:
    Q_STEPHENSON

  • How do I remove NaN values from an array?

    I'm trying to test if the values in an array are less than 0.001. All of them are...BUT the problem is that some of the elements in the array are NaN. I'd like to do one of two things:
    1. Remove the NaN elements from the array and set them to zero to make the test work.
    2. Make the test understand that NaN elements are okay.
    The test results in a boolean array of T/F values. If all of the values of the boolean array are T, it will result in a single boolean value of T. In #2, I am saying that I want it to test if an element of the array is less than 0.001 OR equal to NAN.
    Solved!
    Go to Solution.

    Your statements don't make much sense. It's irrelevant how many NaNs are in the array. A sort will move them all to the bottom. You had said you wanted to find out if all the elements in an array are less than 0.001, and that you've got some NaNs in there. Well, this will do that:
    twolfe13 wrote:
     I did see how to remove NaN once, but couldn't determine a good way to generalize it other than doing a test loop. I thought there might have been a simple function that I overlooked to do this.
    As I noted, there have been several posts in the past about efficient techniques for removing certain elements out of an array. Seek, and ye shall find.
    Joseph Loo wrote:
    Have you look at the coerce function where you can set the lower and upper limit?
    That won't do anything for NaN. Or perhaps I misunderstood what you are suggesting to do?
    Attachments:
    NaN sort.png ‏20 KB
    NaN sort small.png ‏5 KB

  • How to remove NULL values from crosstab sheet in Viewer/Plus.

    I created a worksheet as crosstab. The sheet shows blanks in Desktop when there is no data in the cell, but the same sheet is showing NULL in Viewer. Is there any solution to make NULL as 0 or blank in Viewer?
    Thank you.

    Here you can find solution for this issue and its works for me......
    Show null values as

  • Removing null values from a chart

    Hello,
    I have a chart embedded in  a Crystal report. (v.11.5).  The data set essentially is a value per date, but because of the way the stored procedure is written, I have null values returned.   Is there anyway to have the chart ignore null values?
    Thanks
    Ray

    Even if the SP returns null values, in your record selection criteria couldnt you just say NOT ISNULL() and thus eliminate null values?

  • Removing specific values from an array

    Good day:
    I'm trying to code a program that does the following transformation:
    {1, 2, 3, 2, 3, 4, 5, 6, 5, 6, 7} ---> {1, 2, 3, 3, 4, 5, 6, 6, 7}   (Bold numbers have been removed)
    Technically, I'm trying to do the comparison x_(i+1) >= x_i. If this is false, remove x_(i+1) and the data in the corresponding row.
    Text-wise I believe it looks like this:
    for i=2 to Length(A)
    j = i - 1;
    if A[i] < A[j]
    Delete A[i];
    else
    end
    However, I'm having alot of trouble trying to program using a mix of for/case loops and shift registers.
    Could someone point me in the correct direction?

    What is your LabVIEW version?
    Show us what you tried!
    Maybe you should start here and add a shift register to compare current with previous to create the decision for the conditional tunnel. Shouldn't be hard.

  • How to remove gaps/null values from set of columns in a row

    Im trying to implement a solution for removing null value columns from a row.
    Basically in below example i have five codes and corresponding id's for that codes.What im trying to achive here is if
    i have a null code then i have to move next not null code and id into its new location.
    Example:
    'A1'cd1,'A2'cd2,null cd3,'A4'cd4,null cd5,'i1'id1,'i2'id2,null id3,'i4' id4,null id5 So here cd4 and id4 should take positions of cd3 and id3.
    Output should look like this
    cd1 cd2 cd3 cd4 cd5     id1 id2 id3 id4 id5
    A1  A2   A4              i1  i2  i4Any help would be highly appreciated for below example:
    with temp_table as
    (select 'A1'cd1,'A2'cd2,null cd3,'A4'cd4,null cd5,'i1'id1,'i2'id2,null id3,'i4' id4,null id5 from dual union all
    select 'A11',null,null,'A44','A55','id11',null,null, 'id44','id55' from dual union all
    select null,'A111',null,null,'A555',null,'id111',null, null,'id555' from dual union all
    select 'A',null,null,'A1111','E55','id11',null,null, 'id111','id1111' from dual )
    select * from temp_table;Edited by: GVR on Dec 1, 2010 8:27 AM

    I like case expression B-)
    The same question of my homepage http://www.geocities.jp/oraclesqlpuzzle/7-81.html
    with temp_table(cd1,cd2,cd3,cd4,cd5,id1,id2,id3,id4,id5) as(
    select 'A1' ,'A2' ,null,'A4'   ,null  ,'i1'  ,'i2'   ,null,'i4'   ,null     from dual union all
    select 'A11',null ,null,'A44'  ,'A55' ,'id11',null   ,null,'id44' ,'id55'   from dual union all
    select null,'A111',null,null   ,'A555',null  ,'id111',null,null   ,'id555'  from dual union all
    select 'A'  ,null ,null,'A1111','E55' ,'id11',null   ,null,'id111','id1111' from dual)
    select
    case when SumCD1 = 1 then CD1
         when SumCD1+SumCD2 = 1 then CD2
         when SumCD1+SumCD2+SumCD3 = 1 then CD3
         when SumCD1+SumCD2+SumCD3+SumCD4 = 1 then CD4
         when SumCD1+SumCD2+SumCD3+SumCD4+SumCD5 = 1 then CD5 end as CD1,
    case when SumCD1+SumCD2 = 2 then CD2
         when SumCD1+SumCD2+SumCD3 = 2 then CD3
         when SumCD1+SumCD2+SumCD3+SumCD4 = 2 then CD4
         when SumCD1+SumCD2+SumCD3+SumCD4+SumCD5 = 2 then CD5 end as CD2,
    case when SumCD1+SumCD2+SumCD3 = 3 then CD3
         when SumCD1+SumCD2+SumCD3+SumCD4 = 3 then CD4
         when SumCD1+SumCD2+SumCD3+SumCD4+SumCD5 = 3 then CD5 end as CD3,
    case when SumCD1+SumCD2+SumCD3+SumCD4 = 4 then CD4
         when SumCD1+SumCD2+SumCD3+SumCD4+SumCD5 = 4 then CD5 end as CD4,
    case when SumCD1+SumCD2+SumCD3+SumCD4+SumCD5 = 5 then CD5 end as CD5,
    case when SumID1 = 1 then ID1
         when SumID1+SumID2 = 1 then ID2
         when SumID1+SumID2+SumID3 = 1 then ID3
         when SumID1+SumID2+SumID3+SumID4 = 1 then ID4
         when SumID1+SumID2+SumID3+SumID4+SumID5 = 1 then ID5 end as ID1,
    case when SumID1+SumID2 = 2 then ID2
         when SumID1+SumID2+SumID3 = 2 then ID3
         when SumID1+SumID2+SumID3+SumID4 = 2 then ID4
         when SumID1+SumID2+SumID3+SumID4+SumID5 = 2 then ID5 end as ID2,
    case when SumID1+SumID2+SumID3 = 3 then ID3
         when SumID1+SumID2+SumID3+SumID4 = 3 then ID4
         when SumID1+SumID2+SumID3+SumID4+SumID5 = 3 then ID5 end as ID3,
    case when SumID1+SumID2+SumID3+SumID4 = 4 then ID4
         when SumID1+SumID2+SumID3+SumID4+SumID5 = 4 then ID5 end as ID4,
    case when SumID1+SumID2+SumID3+SumID4+SumID5 = 5 then ID5 end as ID5
    from (select cd1,cd2,cd3,cd4,cd5,id1,id2,id3,id4,id5,
          nvl2(cd1,1,0) as SumCD1,
          nvl2(cd2,1,0) as SumCD2,
          nvl2(cd3,1,0) as SumCD3,
          nvl2(cd4,1,0) as SumCD4,
          nvl2(cd5,1,0) as SumCD5,
          nvl2(id1,1,0) as SumID1,
          nvl2(id2,1,0) as SumID2,
          nvl2(id3,1,0) as SumID3,
          nvl2(id4,1,0) as SumID4,
          nvl2(id5,1,0) as SumID5
          from temp_table)
    order by cd1,cd2,cd3,cd4,cd5;
    CD1   CD2    CD3   CD4   CD5   ID1    ID2    ID3     ID4   ID5
    A     A1111  E55   null  null  id11   id111  id1111  null  null
    A1    A2     A4    null  null  i1     i2     i4      null  null
    A11   A44    A55   null  null  id11   id44   id55    null  null
    A111  A555   null  null  null  id111  id555  null    null  nullMy SQL articles of OTN-Japan
    http://www.oracle.com/technology/global/jp/pub/jp/ace/sql_image/1/otnj-sql-image1.html
    http://www.oracle.com/technology/global/jp/pub/jp/ace/sql_image/2/otnj-sql-image2.html

  • Removing duplicate values from selectOneChoice bound to List Iterator

    I'm trying to remove duplicate values from a selectOneChoice that i have. The component binds back to a List Iterator on the pageDefinition.
    I have a table on a JSF page with 5 columns; the table is bound to a method iterator on the pageDef. Then above the table, there are 5 separate selectOneChoice components each one of which is bound to the result set of the table's iterator. So this means that each selectOneChoice only contains vales corresponding to the columns in the table which it represents.
    The selectOneChoice components are part of a search facility and allow the user to select values from them and restrict the results that are returned. The concept is fine and i works. However if i have repeating values in the selectOneChoice (which is inevitable given its bound to the table column result set), then i need to remove them. I can remove null values or empty strings using expression language in the rendered attribute as shown:
    <af:forEach var="item"
    items="#{bindings.XXXX.items}">
    <af:selectItem label="#{item.label}" value="#{item.label}"
    rendered="#{item.label != ''}"/>
    </af:forEach>
    But i dont know how i can remove duplicate values easily. I know i can programatically do it in a backing bean etc.... but i want to know if there is perhaps some EL that might do it or another setting that ADF gives which can overcome this.
    Any help would be appreciated.
    Kind Regards

    Hi,
    It'll be little difficult removing duplicates and keeping the context as it is with exixting standard functions. Removing duplicates irrespective of context changes, we can do with available functions. Please try with this UDF code which may help you...
    source>sort>UDF-->Target
    execution type of UDF is Allvalues of a context.
    public void UDF(String[] var1, ResultList result, Container container) throws StreamTransformationException{
    ArrayList aList = new ArrayList();
    aList.add(var1(0));
    result.addValue(var1(0));
    for(int i=1; i<var1.length; i++){
    if(aList.contains(var1(i)))
         continue;
    else{
    aList.add(var1(i));
    result.addValue(var1(i));
    Regards,
    Priyanka

  • How to replace NULL values from main table

    Dear all,
    I like to remove the NULL values from a main table field. Or the question is how to replace any part of the string field in MDM repository main table field.
    e.g.   I have a middle name field partly the value is NULL in some hundreds of records, I like to replace NULL values with Space
    any recommendation.
    Regards,
    Naeem

    Hi Naeem,
    You can try using Workflows for automatically replacing NULLs with any specific value.
    What you can do is: Create a workflow and set trigger action as Record Import, Record Create and Record Update. So, that whenever any change will occur in the repository; that workflow will trigger.
    Now create an assignment expression for replacing NULLs with any specific value and use that assignment expression in your workflow by using Assign Step in workflow.
    For exiting records, you will have to replace NULLs manually using the process given by Preethi else you can export those records in an Excel spreadsheet which have NULLs and then replace all NULLs with any string value and then reimport those records in your MDM repository.
    Hope this will solve your problem.
    Regards,
    Varun
    Edited by: Varun Agarwal on Dec 2, 2008 3:12 PM

  • Need help Take out the null values from the ResultSet and Create a XML file

    hi,
    I wrote something which connects to Database and gets the ResultSet. From that ResultSet I am creating
    a XML file. IN my program these are the main two classes Frame1 and ResultSetToXML. ResultSetToXML which
    takes ResultSet & Boolean value in its constructor. I am passing the ResultSet and Boolean value
    from Frame1 class. I am passing the boolean value to get the null values from the ResultSet and then add those
    null values to XML File. When i run the program it works alright and adds the null and not null values to
    the file. But when i pass the boolean value to take out the null values it would not take it out and adds
    the null and not null values.
    Please look at the code i am posing. I am showing step by step where its not adding the null values.
    Any help is always appreciated.
    Thanks in advance.
    ============================================================================
    Frame1 Class
    ============
    public class Frame1 extends JFrame{
    private JPanel contentPane;
    private XQuery xQuery1 = new XQuery();
    private XYLayout xYLayout1 = new XYLayout();
    public Document doc;
    private JButton jButton2 = new JButton();
    private Connection con;
    private Statement stmt;
    private ResultSetToXML rstx;
    //Construct the frame
    public Frame1() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
    jbInit();
    catch(Exception e) {
    e.printStackTrace();
    //Component initialization
    private void jbInit() throws Exception {
    //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
    contentPane = (JPanel) this.getContentPane();
    xQuery1.setSql("");
    xQuery1.setUrl("jdbc:odbc:SCANODBC");
    xQuery1.setUserName("SYSDBA");
    xQuery1.setPassword("masterkey");
    xQuery1.setDriver("sun.jdbc.odbc.JdbcOdbcDriver");
    contentPane.setLayout(xYLayout1);
    this.setSize(new Dimension(400, 300));
    this.setTitle("Frame Title");
    xQuery1.setSql("Select * from Pinfo where pid=2 or pid=4");
    jButton2.setText("Get XML from DB");
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    catch(java.lang.ClassNotFoundException ex) {
    System.err.print("ClassNotFoundException: ");
    System.err.println(ex.getMessage());
    try {
    con = DriverManager.getConnection("jdbc:odbc:SCANODBC","SYSDBA", "masterkey");
    stmt = con.createStatement();
    catch(SQLException ex) {
    System.err.println("SQLException: " + ex.getMessage());
    jButton2.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent e) {
    jButton2_actionPerformed(e);
    contentPane.add(jButton2, new XYConstraints(126, 113, -1, -1));
    //Overridden so we can exit when window is closed
    protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
    System.exit(0);
    void jButton2_actionPerformed(ActionEvent e) {
    try{
    OutputStream out;
    XMLOutputter outputter;
    Element root;
    org.jdom.Document doc;
    root = new Element("PINFO");
    String query = "SELECT * FROM PINFO WHERE PID=2 OR PID=4";
    ResultSet rs = stmt.executeQuery(query);
    /*===========This is where i am passing the ResultSet and boolean=======
    ===========value to either add the null or not null values in the file======*/
    rstx = new ResultSetToXML(rs,true);
    } //end of try
    catch(SQLException ex) {
    System.err.println("SQLException: " + ex.getMessage());
    ======================================================================================
    ResultSetToXML class
    ====================
    public class ResultSetToXML {
    private OutputStream out;
    private Element root;
    private XMLOutputter outputter;
    private Document doc;
    // Constructor
    public ResultSetToXML(ResultSet rs, boolean checkifnull){
    try{
    String tagname="";
    String tagvalue="";
    root = new Element("pinfo");
    while (rs.next()){
    Element users = new Element("Record");
    for(int i=1;i<=rs.getMetaData().getColumnCount(); ++i){
    tagname= rs.getMetaData().getColumnName(i);
    tagvalue=rs.getString(i);
    System.out.println(tagname);
    System.out.println(tagvalue);
    /*============if the boolean value is false it adds the null and not
    null value to the file =====================*/
    /*============else it checks if the value is null or the length is
    less than 0 and does the else clause in the if(checkifnull)===*/
    if(checkifnull){ 
    if((tagvalue == null) || tagvalue.length() < 0 ){
    users.addContent((new Element(tagname).setText(tagvalue)));
    else{
    users.addContent((new Element(tagname).setText(tagvalue)));
    else{
    users.addContent((new Element(tagname).setText(tagvalue)));
    root.addContent(users);
    out=new FileOutputStream("c:/XMLFile.xml");
    doc = new Document(root);
    outputter = new XMLOutputter();
    outputter.output(doc,out);
    catch(IOException ioe){
    System.out.println(ioe);
    catch(SQLException sqle){

    Can someone please help me with this problem
    Thanks.

  • How can I delete null values from List Item?

    Hi Friends,
    I used List item for field job_Type, I entered values in List item at design time through property pallet. When I run form I will see null values in this List Item.
    How can I remove these null values from the List?
    Best regards,
    Shahzad

    Dear Shahzad,
    It can be removed by adding the following code in the When-new-Form-Instance.
    Set_item_property('List name', required, property_true);
    :block_name.list_name := <put your default value here>; (If you didn't oput the default value, then you will get some problem and the cursor may not navigate away from the list).
    Senthil Alagu .P.

  • How to post null values from h:inputText?

    Hello,
    I have a form made of h:inputText fields that map to an entity class as the backing bean. Whenever I post the form from a web page, all the fields that I did not fill out and that are mapped to String fields in the entity class are set to "" (empty string) instead of null.
    However, I would like to post null values to my entity, because that would indicate that the user did not fill out the field. In other contexts (outside of the web app) it is possible to set the fields to empty strings, but from the web app it should always be null. How can I get JSF to do this correctly?
    Also, when reading entitys with null values from the database, these are converted to empty h:inputText fields, so this direction works as expected.
    Ulrich

    I haven't seen a solution for this as far.
    This is how I do it:
    public void action() {
        if (isEmpty(inputValue)) {
            // do your thing
        } else {
            // do your thing
    public static boolean isEmpty(Object value) {
        if (value == null) {
            return true;
        if (value instanceof String && ((String) value).trim().length() == 0) {
            return true;
        if (value instanceof Collection && ((Collection) value).size() == 0) {
            return true;
        // And go so on .. make it an utility method.
        return false;
    }

Maybe you are looking for