my application does not close http connection and shows error message after give invalid input
<p>this is my code which i used to get xml response.  The problem is when i give valid input it works fine, but when i give wrong input and after that correct input,  it shows invalid input again. Tell me why??
This code works fine and gets xml response from server if valid input, but if I give wrong input, a toast message shows invalid input, but after invalid input, if I again give VALID input, it still shows invalid input.  Tell me why?? </p>

<pre><code>btnsubmit.setOnClickListener(new OnClickListener()
{
public void onClick(View v)

{

    submitTransaction();

    }

      private void submitTransaction() {
     xmlResponse =  
 AgAppHelperMethods.myXMLParser("www.xyz"+txtPinno.getText().toString() +txtmobile 
      number.getText().toString() +);


         if(!AgAppHelperMethods.flag)
            {
                 Toast.makeText(getApplicationContext(),  
   "Invalid    Input " , Toast.LENGTH_SHORT).show();
      }


   public static   String[][] myXMLParser( String parUrl) {



    String _node,_element;
    String[][] xmlRespone = null;

       try {

            String url = AgAppHelperMethods.getUrl() + parUrl;
            URL finalUrl = new URL(url);    



               HttpURLConnection urlConnection = (HttpURLConnection) 
                      finalUrl.openConnection();



            DocumentBuilderFactory dbf =  
  DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.parse(new 
    InputSource(urlConnection.getInputStream()));
            doc.getDocumentElement().normalize();

            NodeList list=doc.getElementsByTagName("*");
            _node=new String();
            _element = new String();
            xmlRespone = new String[list.getLength()][2];

            //this "for" loop is used to parse through the
            //XML document and extract all elements and their
            //value, so they can be displayed on the device

            for (int i=0;i&lt;list.getLength();i++)
                {
                    Node value=list.item(i).      getChildNodes().item(0);
                    _node=list.item(i).getNodeName();
                    _element=value.getNodeValue();
                    xmlRespone[i][0] = _node;
                    xmlRespone[i][1] = _element;

                }//end for

        }//end try

          catch (Exception e)

    {
        String[][] res;
     flag=false;
    Log.e(LOG_TAG, "CONNECTION ERROR  SERVER NOT RESPONDING", e);
</code></pre>

<p>}</p>
