Results 1 to 1 of 1
  1. #1
    ibanez270dx is offline Member
    Join Date
    Nov 2007
    Location
    Bay Area, CA
    Posts
    13
    Rep Power
    0

    Default Probably a really simple question...

    Hello,
    I have an applet which POSTs data to a PHP page, and I think the code is ok. However, it doesn't redirect to that page. I need it to close the applet and redirect to posttest.php with the POST info. I did a stacktrace and nothing came up ... Here is my code:

    Java Code:
    if (f.exists()) 
    	     {
                  overallLayout.show(cardPanel, "3");  //show scanning files, please wait 
    	      try
    		{
            	// Construct data
            	 String data = URLEncoder.encode("key1", "UTF-8") + "=" + URLEncoder.encode("value1", "UTF-8");
            	 data += "&" + URLEncoder.encode("key2", "UTF-8") + "=" + URLEncoder.encode("value2", "UTF-8");
        
        		// Send data
            	 URL url = new URL("posttest.php");
            	 URLConnection conn = url.openConnection();
            	 conn.setDoOutput(true);
            	 OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
            	 wr.write(data);
            	 wr.flush();
        
            	// Get the response
            	 BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            	 String line;
            	 while ((line = rd.readLine()) != null) 
    		   {
                	// Process line...
            	   }
           		 wr.close();
            	 rd.close();
        		}
    		 catch (Exception ex)
    		{
       		}
    	     } 
              else 
                 {
                  overallLayout.show(cardPanel, "2");  //show that it doesn't exist
                 }
    Any help is appreciated!

    Thank you,
    - Jeff
    Last edited by ibanez270dx; 11-16-2007 at 01:45 AM. Reason: just did a stacktrace

Similar Threads

  1. Question mark colon operator question
    By orchid in forum Advanced Java
    Replies: 9
    Last Post: 12-19-2010, 08:49 AM
  2. Simple Method Question
    By Froz3n777 in forum New To Java
    Replies: 2
    Last Post: 02-13-2008, 02:39 AM
  3. simple GUI
    By dim_ath in forum New To Java
    Replies: 3
    Last Post: 01-07-2008, 03:00 PM
  4. Simple append question
    By Rageagainst20 in forum New To Java
    Replies: 0
    Last Post: 12-20-2007, 11:40 PM
  5. Simple question of JTable
    By carl in forum AWT / Swing
    Replies: 1
    Last Post: 08-07-2007, 07:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •