HTTP PoSt ... please help !!!

Hi,
I have to simulate an HTTP client and send a file to a server. My code is the following:
URL url = new URL("http://myURL/script.php");
HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();
urlConnection.setDoOutput(true);
urlConnection.setUseCaches(false);
urlConnection.setRequestMethod("POST");
File fi = new File("myFile.bin");
DataOutputStream printout;
printout = new DataOutputStream(urlConnection.getOutputStream());
String contentType="Content-type: multipart/form-data; boundary=XCVBGFDS\r\n\r\n"
+"--XCVBGFDS\r\n"
+"Content-Disposition: form-data; "
+"name=\"upload\"; filename=\""+fi.getName()+"\"\r\n"
+"Content-Type: application/octet-stream\r\n\r\n";
printout.writeBytes(contentType);
int input;
DataInputStream inFile=new DataInputStream(new FileInputStream(fi));
while ((input = inFile.read()) !=-1) {
printout.write(input);
contentType = "--XCVBGFDS--\r\n";
printout.writeBytes(contentType);
printout.flush();
printout.close();
It doesn't work (I can't retrieve the "filename value in the php script"). Thanks for help...
griff

Nothing will be sent to the server until you call URLConnection.getInputStream().
Chuck

Similar Messages

  • Invoices posted without good receipt initial posting - please help

    Hi Gurus,
    I would like to ask you if you have and answer / solution for this situation.
    I have a release order with 6 invoices + goods receipt. The problem here is that all the invoices were posted, but not the initial goods receipt. a Financial account had already been posted as well, so i dont know how i will solve this situation !!
    Can u please help me ?
    If u need more information please ask me.
    Thanks in advance,
    Mário.

    Hi
    If you see these invoices in the vendor line items, all would have got payment block in it. Unless GR is done for these PO's, it will not get released automatically. If GR is not required for these invoices, then you will be able to make payment. But if GR based IV is ticked in PO, unless you do GR, you will not be able to make payment to the vendor.
    You can still post GR through MIGO for the same PO. System will allow you to post GR for these invoices.
    Award points if found useful.
    Regards,
    K Lakshmanan

  • Mavericks is too slow, I've checked other posts, please help.

    I am trying to finish editing a movie in FCPX this weekend for a film festival that has asked for it.
    But everything is Pentium 90 slow.  I don't care about all the other apps that have hiccups and pause to think when they were quite happy, I'll live with those (I'm sure Apple will eventually fix it, even Microsoft eventually released Windows 8.1).
    But I am handcuffed by how debilitatingly slow fcpx has become.  Plenty of free disk space, App Nap turned off for fcpx and compressor.  These are not rendering delays (all files transcoded).
    Please do not give me a lot of homework to do.  The only change (says the retired CTO who's heard that from users for 20 years) was Mavericks.
    Either somebody has a theory about how to help me or they don't.
    If you don't, I can't fault you, I don't know either.
    If you do, I would love to hear from you.  This documentary is about a man dying from cancer and we'd like him to see it at his home town film festival before he passes (seriously).
    Thanks, y'all.
    Hardware Overview:
      Model Name:          iMac
      Model Identifier:          iMac12,2
      Processor Name:          Intel Core i5
      Processor Speed:          2.7 GHz
      Number of Processors:          1
      Total Number of Cores:          4
      L2 Cache (per Core):          256 KB
      L3 Cache:          6 MB
      Memory:          8 GB
      Boot ROM Version:          IM121.0047.B1F
      SMC Version (system):          1.72f2
      Serial Number (system):          C02HFC47DHJP
      Hardware UUID:          55999CBB-BB08-50C2-A8FD-583C0F91ACF8

    Fixed it!  It was so easy.  All weekend, I just rebooted every three hours or so.  Save all work, close everything, reboot my iMac.
    Simple fix, reminds me of Windows for Workgroups.
    My humble I-don't-have-time-or-energy-to-investigate-it guess is that it may be related to a faulty garbage collection.  Why do I say that?  See above.

  • MSI 890FXA-GD65 not posting please help!!!

    Hi everyone I am new to the site and I am doing my second build first time with a MSI board here are my componets.
    1: MSI 890FX-GD65
    2: AMD PHENOM II X4 980 BLACK EDITION 3.7 AM3 SOCKET
    3: G.SKILL Sniper Low Voltage Series 8GB (2 x 4GB) 240-Pin DDR3 SDRAM DDR3 1600 (PC3 12800)
    4: SAPPHIRE FleX 100314FLEX Radeon HD 6870 1GB 256-bit GDDR5
    5:  CORSAIR Builder Series CX500 V2 500W ATX12V v2.3 80 PLUS Certified Active PFC Power Supply\
    Here is the issue I did the minum connections before putting the computer in the case to make sure it would POST, but it doesn't. The motherboard speaker doesn't make a sound but the 8 led lights on top of the MOBO are all lit. I cant get any response from my monitor when its hooked up to my video card. the fan from the PSU and video cards are spinning but again no POST can anyone help Me with this thank you., also I used a second power supply and still no POST or response from the monitor but again all the fans are working and all 8 of the led lights are lit at the top of the MOBO. once again thanks for your help.

    Good evening!
    All parts are new?
    Use a single stick of memory.
    Recheck all power connections are well in place, and don't forget the one near and for the processor.
    Don't think that is the problem, but for good measure you should also reseat the graphics card.
    I'm not sure whether this mobo has a speaker.

  • New Nf980-g65 board refuses to post please help

    Hi everyone I just purchased a nf980-g65 board and installed the cpu a phenom II 945 and connected everything and the board will not post no beeps fans spin up and one power phase light comes on. If I removed the ram however the board will make 3 long beeps without the ram installed I did a bench test no change with ram installed the ram is patriot pdc32g1333elk is the ram causing an issue or what could be wrong?

    Is this a new build?
    Does it worked before?
    Have you tried to boot with barabone setup and mainboard of PC case?
    Do >>Clear CMOS Guide<< with power cord removed,
    leave 1 memory stick in 1st DIMM close to CPU socket. Then try to boot.
    Quote
    Ram: patriot pdc32g1333elk 2x 1gb 1333mhz ddr 3
    This is Intel's tested memory.. ==> http://static.compusa.com/pdf/Patriot-PDC32G1333ELK-datasheet.pdf
    • Tested and compatible with Intel
     P35, X38 and X48 chipsets

  • HTTPS PUT (please help!)

    Can someone please tell me if it's possible to perform a "https put" and if so, please include detailed instructions on how to perform this task. I am needing to "upload" a file, but it must occur over a secure connection (HTTPS). I attempted to use FTP until I realized that everything is sent unencrypted. If HTTPS PUT in not possible, then any other suggestions for a resolution to my dilemma would be greatly appreciated!
    Please contact me with your suggestions at [email protected]
    Thanks in advance!
    Bobby Johns Wiley

    You need to install Java Secure Socket Extentions (JSSE) into the extensions directory for Java 1.2 - 1.3.1, it is included in Java 1.4. Look at the JSSE docs for more detail.
    Chuck

  • SOA with  http Services Please help me  ;(

    Hi
    Form
    I am confused what should i use / not for the SOA service ?.
    Can some body suggest me ,which tools/api's should i make use of to build
    an SOA service on my existing "http" ( TOMCAT 5 , JDK15 ) based application.
    with regards
    Karthik

    Check out Axis2 or XFire.

  • K8N Neo4 Platinum Wont POST please help!!

    ok, i built this pc about a month ago. everything has worked perfectly until yesterday. When i turn the power on, al i get is the Platinum Screen. I cant go into Bios, i cant Post.. The PC beeps once like normal, and the LED on the Motherboard and the videocard come on. Ive tried wiping the CMOS, Tried a different PSU, tried removing one of the memory sticks. I tried just connecting the Mobo, video card and harddrive, to see if it want getting enough power. Heres what ive got:
    K8N Neo4 Platinum/SLI
    Athlon 64 3500+
    Geforce 6800 Gt
    1 Gig corsair 3200 ram (2x512mb)
    550 watt PSU

    reset the bios, make sure its RESET.
    then, try with just 1 stick ram first.
    remember, to run dual for this board, it has to be Slot 1  &  Slot 2. 
    If u follow the color, it'll be single channel instead.
    Read also the instruction, it says never plug into 2nd or 4th slot with 1 stick ram.
    Try with 1 stick ram. if it boots, then insert the 2nd into Slot 2.  for dual channel.
    i had similar prob few days back when newly purchased.
    good luck !

  • Multipart HTTP Post

    Dear All,
    I need to forward a text file (without any conversion or mapping) to the HTTP receiver adapter and create a HTTP POST to an external server. Now the problem is that the HTTP Post is supposed to be a multipart message with 3 different content-types, content-lengths and all of them have to be delimited by a "--BOUNDARY" constant.
    I read through a lot of SDN Blogs and HTTP forum post, even setup TCPGATEWAY in order to trace my HTTP output, but just can't come even close to producing this sample HTTP Post:
    "POST /hapld/tos/kdwhapltos HTTP/1.1
    Host: www.xxx.com
    Content-type: multipart/mixed; boundary=BOUNDARY
    Content-length: 1040
    --BOUNDARY
    Content-type: application/x-www-form-urlencoded
    Content-length: 140
    AppVersion=1.0&AcceptUPSLicenseAgreement=Yes&ResponseType=application/x-xxx-pld&VersionNumber=
    V4R1&UserId=useridvalue&Password=passwordvalue
    --BOUNDARY
    Content-type: application/x-xxx-binary
    Content-length: 719
    020082 2.0 2002101700000000000010500 000000001*AA0A1754 US
    1234567002000001*BA1z1234560100002352 00001+0000000000000010 +000
    0000000000000LBS01PRE10 3INUSD000001*CA18ATTENTION
    DELIVERY 234 SOME LOCAL ST SO
    ME CITY NJ 07652 US12015551212 *PA1z1234560100002352
    02+0000010 +0000010
    *SA000004
    BOUNDARY"
    1. Is it even possible to produce that kind of multipart post, using the HTTP adapter with it's header filed, prolog or epilog possibilities? How to insert a "new line" within the prolog string for example?
    2. Can anyone who was required to develop a similar complex HTTP post, please provide his solution or any useful tips and links. I've read the SAP Help sites...
    Thanks in advance!
    Michael

    Hi again,
    I am using the file adapter and a virtual Inbound Interface and namespace, so that I don't need to define any object within the Repository, but in order to use the java mapping, I need to create an interface-mapping. The interface mapping requires an inbound and outbound interface though.
    What I want to achive is polling a text file from a local network folder via the file adapter and forwarding this file without any conversion as an HTTP Post to an external HTTP service. As this receiver service requires a multipart HTTP message, I'm forced to figure out another way to foward the original payload, but modify the HTTP buildup. 
    Regards
    Michael

  • Change of Business Area to Cost Center (my first thread , please help)

    Hi Everybody i'm Charmaine Leena Martin freshly certified  FICO consultant , this is my first thread i'm posting, please help me with the same.
    A wrong business area has been assigned to a cost center and postings have taken place in the same.
    while using t-code KS02: change cost center , for rectifying the business area , i get the following error:
    "Field change business area is not possible (transaction data exists)"
    so i've created a new cost center and assigned it the right business
    and using t-code kb61 : i have posted the documents to the new cost center
    at that time system generates a co-document automatically:
    But the accounting document of which transfer postings have taken place still shows old business area and cost center
    Please let me know why is it so ,
    and what has to be done with the CO document that gets posted automatically
    and is there any other way out of changing the business area without creation of new cost center
    Moderator: Please, search before posting

    Hi Leena
    Welcome to SDN
    Do KB11N to post the cost back to the Wrong cost center
    Do an FI Posting again Dr the Correct new cost center and Cr the Old wrong cost center
    This will match both FI and CO
    br, Ajay M

  • HTTP POST is killing me, please help ...

    Hello,
    I am trying to send an XML file to a php script sitting on a server. I want to do this by HTTP POST through a Java Application.
    I have the following code developed and haven't an iota why the php script won't pick up the XML file.
    If anyone has any idea, suggestions, I will be glad to hear them.
    Random random = new Random();
    final String CONTENT_BOUNDARY = "------------------------" + random.nextInt();
    public String postInvoice(String strFilePathName) {
    HttpURLConnection httpsUrlConnection = null;
    StringBuffer strBuffer = new StringBuffer();
    try {
    // Using the File name passed in, setup FileInputStream Object
    // to be used to get data to write to URL
    File fileToPost = new File(strFilePathName);
    //FileInputStream fis1 = new FileInputStream(fileToPost);
    // Get the actual filename for setting in the form
    String strFileName = fileToPost.getName();
    URL urlPostTo = new URL("http://server/some.php");
    httpsUrlConnection = (HttpURLConnection)urlPostTo.openConnection();
    // Setup RandomAccessFile
    RandomAccessFile rafXML = new RandomAccessFile(strFilePathName, "r");
    httpsUrlConnection.setRequestProperty("REQUEST_METHOD", "POST");
    httpsUrlConnection.setRequestProperty("Accept", "text/xml");
    httpsUrlConnection.setDoOutput(true);
    httpsUrlConnection.setUseCaches(false);
    httpsUrlConnection.setRequestProperty("Content-Type",
    "multipart/form-data");
    Long longTemp = new Long(rafXML.length());
    httpsUrlConnection.setRequestProperty("Content-Length", longTemp.toString());
    PrintWriter pwOut = new PrintWriter (httpsUrlConnection.getOutputStream());
    // Setup a form field
    pwOut.print(CONTENT_BOUNDARY + "\r\n" +
    "Content-Disposition: form-data; name=\"Filename\"; filename=\"" +
    strFileName + "\"\r\nContent-Type: text/xml\r\n\r\n");
    // Send XML contents
    StringBuffer strBufferFile = new StringBuffer();
    long lngFilePointer = 0;
    long lngFileLength = rafXML.length();
    while (lngFilePointer < lngFileLength) {
    String strTemp = rafXML.readLine();
    strBufferFile.append(strTemp);
    lngFilePointer = rafXML.getFilePointer();
    // Write out File Contents
    pwOut.print(strBufferFile.toString());
    pwOut.print("\r\n\r\n" + CONTENT_BOUNDARY + "--\r\n");
    pwOut.flush();
    pwOut.close(); pwOut = null;
    // Once everything is written, call the connect method
    httpsUrlConnection.connect();
    System.out.println("Connected to " + httpsUrlConnection.getURL().getHost());
    BufferedReader br = new BufferedReader(new InputStreamReader(httpsUrlConnection.getInputStream()));
    String strLine;
    while ((strLine = br.readLine()) != null)
    strBuffer.append (strLine);
    strBuffer.append ("\r\n");
    br.close(); br = null;
    System.out.println(strBuffer.toString());
    catch(FileNotFoundException fnfe) {
    System.out.println("FileNotFoundException in HttpPostInvoice : " + fnfe);
    catch (Exception e) {
    System.out.println("Exception in HttpPostInvoice : " + e);
    finally {     
    if (httpsUrlConnection != null) {
    httpsUrlConnection.disconnect();
    return strBuffer.toString();
    }

    Have that application installed and it makes for interesting reading, not sure I understand it all but anyway ..
    Using the code you supplied, this is what is picked up
    POST /some.php HTTP/1.1
    Content-Length: 4844
    User-Agent: Java1.4.0_03
    Host: www.host.com
    Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
    Connection: keep-alive
    Content-type: application/x-www-form-urlencoded
    POST http://server/some.php HTTP/1.0
    Content-Type: multipart/form-data; boundary=-------------------------1736247667
    Accept: text/xml
    Connection: keep-alive
    Content-Length: 4595
    Cache-Control: no-cache
    Pragma: no-cache
    -------------------------1736247667
    Content-Disposition: form-data; name="Filename"; filename="3000001193.xml"
    Content-Type: text/xml
    <?xml version="1.0"?><Order> ... </Order>
    -------------------------1736247667--
    Using my original code this is what the app picked up ...
    POST /some.php HTTP/1.1
    Accept: text/xml
    Content-Type: multipart/form-data; boundary=------------------------1514140045
    Content-Length: 4557
    User-Agent: Java1.4.0_03
    Host: www.host.com
    Connection: keep-alive
    ------------------------1514140045
    Content-Disposition: form-data; name="Filename"; filename="3000001193.xml"
    Content-Type: text/xml
    <?xml version="1.0"?><Order> ... <Order>
    ------------------------1514140045--
    I really don't know what to make of it, as far as I can see the request header is ok, with the response being 200. That means the request is ok, but shouldn't the response be 201 indicating that the file was created?
    Am going to look at what a POST through a HTML form sends and match up that way ...

  • HTTP POST Request? How? Please Help!

    Hi maybe this is a simple question. But I was able to do a GET Request from an applet to an ASP page just fine but I am having problems with the POST Request. How do you do a HTTP POST and put the parameter on the post data?
    This is what I am doing:
    url = new URL(queryParam);
    connection = (HttpURLConnection)url.openConnection();
    connection.setDoOutput(true);
    connection.setRequestMethod("POST");
    // IS THIS CORRECT WAY TO ADD PARAMETER TO POST
    connection.setRequestProperty("name","javaguy");
    BufferedReader in = new BufferedReader( new InputStreamReader( connection.getInputStream()));
    String inputLine;
    while ((inputLine = in.readLine()) != null)
    System.out.println(inputLine);
    in.close();

    The setRequestProperty() method is used to add HTTP headers to the request. The way you pass "post" parameters is to send them as the body of the message in "application/x-www-form-urlencoded" form. In other words, create a string of URLEncoded "name=value" pairs delimited by '&', just like you would see in the URL when making a GET request through the browser:
    String paramStr = "name=javaguy&occupation=web+developer" ;
    byte[] paramBuf = paramStr.getBytes("ISO-8859-1") ;
    url = new URL(queryParam);
    connection = (HttpURLConnection)url.openConnection();
    connection.setDoOutput(true);
    connection.setRequestMethod("POST");
    // THIS CORRECT WAY TO ADD PARAMETER TO POST
    connection.setRequestProperty("Content-Length", Integer.toString(paramBuf.length)) ;
    OutputStream out = connection.getOutputStream() ;
    out.write(paramBuf) ;
    out.flush() ;
    out.close() ;
    BufferedReader in = new BufferedReader( new InputStreamReader( connection.getInputStream()));
    String inputLine;
    while ((inputLine = in.readLine()) != null)
        System.out.println(inputLine);
    in.close();Good luck!

  • All day calendar events not being displayed in the notification centre for iphone 5 post ios 7 upgrade. Please help. Is it a bug?

    All day calendar events not being displayed in the notification centre for iphone 5 post ios 7 upgrade. Please help. Is it a bug?
    With iOS 6, the all day events showed up in the notification centre but it lacks in the upgrade iOS 7.

    Same problem here. Some people pointed out that all-day events do show up in their notification center, but that seems only to be the case for birthdays (and only as text like the weather). I've tried it myself on my iPhone and iPad and it did work for birthdays but not for any other all-day events. I already sent this to Apple as a product feedback as well, as should everyone of you. The more people mention it, the faster Apple's going to fix this issue. In its current state, notification center is not a very helpful feature in my opinion. There's absolutely no point in not showing all-day events in the 'today' calendar overview.
    Here's a link to the product feedback page: http://www.apple.com/feedback/
    I posted my message in the iPhone section since I couldn't find a page specifically dedicated to iOS 7.
    I really love the look &amp; feel of iOS 7 but it's kinda sad to see notification center not tapping its full potential.
    Cheers!

  • Posted this query several times but no reply. Please help me out

    Hi all,
    How to know whether a servlet had completely sent its response to the request.
    The problem what i am facing is, I send response to a client's request as a file.
    The byte by byte transfer happens, now if the client interrupts or cancels the operation, the response is not completed.
    At this stage how to know the response status. I am handling all exception, even then I am unable to trap the status.
    Please help me out.
    I have posted this query several times but no convincing reply till now. Hence please help me out.
    If somebody wants to see the code. I'll send it through mail.
    regards
    venkat

    Hi,
    thanks for the reply,
    Please check the code what I have written. The servlet if I execute in Javawebserver2.0 I could trap the exception. If the same servlet is running in weblogic 6.0 I am unable to get the exception.
    Please note that I have maintained counter and all necessary exception handling even then unable to trap the exception.
    //code//
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.security.*;
    public class TestServ extends HttpServlet
    Exception exception;
    public void doGet(HttpServletRequest req, HttpServletResponse res)throws ServletException, IOException, UnavailableException
         int bytesRead=0;
         int count=0;
         byte[] buff=new byte[1];
    OutputStream out=res.getOutputStream ();
    res.setContentType( "application/pdf"); // MIME type for pdf doc
    String fileURL ="http://localhost:7001/soap.pdf";
    BufferedInputStream bis = null;
    BufferedOutputStream bos = null;
    boolean download=false;
         int fsize=0;
         res.setHeader("Content-disposition", "attachment; filename="+"soap.pdf" );
    try
                   URL url=new URL(fileURL);
         bis = new BufferedInputStream(url.openStream());
         fsize=bis.available();
         bos = new BufferedOutputStream(out);
    while(-1 != (bytesRead = bis.read(buff, 0, buff.length)))
              try
                        bos.write(bytesRead);
                        count +=bytesRead;
                        bos.flush();
                   }//end of try for while loop
                   catch(StreamCorruptedException ex)
                        System.out.println("Exception ="+ex);
                        setError(ex);
                        break;
                   catch(SocketException e)
                        setError(e);
                        break;
                   catch(Exception e)
                        System.out.println("Exception in while of TestServlet is " +e.getMessage());
                        if(e != null)
                             System.out.println("File not downloaded properly"+e);
                             setError(e);
                             break;
                        }//if ends
                   }//end of catch for while loop
    }//while ends
              Exception eError=getError();
              if(eError!=null)
                   System.out.println("\n\n\n\nFile Not DownLoaded properly\n\n\n\n");
              else if(bytesRead == -1)
              System.out.println("\n\n\n\ndownload \nsuccessful\n\n\n\n");
              else
              System.out.println("\n\n\n\ndownload not successful\n\n\n\n");
    catch(MalformedURLException e)
    System.out.println ( "Exception inside TestServlet is " +e.getMessage());
    catch(IOException e)
    System.out.println ( "IOException inside TestServlet is " +e.getMessage());
         finally
              try
         if (bis != null)
         bis.close();
         if (bos != null)
         {bos.close();}
              catch(Exception e)
                   System.out.println("here ="+e);
    }//doPost ends
    public void setError(Exception e)
         exception=e;
         System.out.println("\n\n\nException occurred is "+e+"\n\n\n");
    public Exception getError()
              return exception;
    }//class ends
    //ends
    regards,
    venakt

  • Need Help in importing data through HTTP post by using OAF

    Hello Everyone,
    I have one requirement of importing data from Job Posting page of iRecruitment into other application or into other file like csv/xml/txt through HTTP post by using Oracle Application Framework.
    Please help me out in the same if anyone know about how to achieve this kind of requirement.
    Help is highly appreciated.
    Thanks,
    Arvind
    Edited by: user636850 on Sep 18, 2009 5:35 AM

    Hi Gaurav,
    Thanks for your reply. I know about export button but my requirement is to import data into other web based application through HTTP post.
    Thanks,
    Arvind

  • Please help with SSL POST: Servlet returns Error 500

    I am struggling for many days to get a Java program to log in to an SSL page. The program is supposed to track ADSL usage statistics from https://secure.telkomsa.net/titracker/, but I never seem to get around Server returned Error 500.
    Could anyone please help me understand what I am doing wrong by looking at the method I used. (It seems on the server side it is a jsp servlet that handles authentication).
    Any help is deeply appreciated!
    I copy-paste the method directly from NetBeans:
    CODE>
    void connectHTTPS(String url){
    try {
    URL page = new URL(url); // login page necessary to get a jsp session cookie
    //------------ SET UP SSL - is it right?
    System.setProperty("java.protocol.handler.pkgs",
    "com.sun.net.ssl.internal.www.protocol");
    try {
    //if we have the JSSE provider available,
    //and it has not already been
    //set, add it as a new provide to the Security class.
    final Class clsFactory = Class.forName("com.sun.net.ssl.internal.ssl.Provider");
    if( (null != clsFactory) && (null == Security.getProvider("SunJSSE")) )
    Security.addProvider((Provider)clsFactory.newInstance());
    } catch( ClassNotFoundException cfe ) {
    throw new Exception("Unable to load the JSSE SSL stream handler." +
    "Check classpath." + cfe.toString());
    URLConnection urlc = page.openConnection();
    urlc.setDoInput(true);
    *Get the session id cookie set by the TelkomInternet java server
    String cookie = urlc.getHeaderField("Set-Cookie");
    //textpane.setText(totextpane);
    textpane.setText(cookie);
    //---------------- form an auth request and post it with the cookie
    String postdata =URLEncoder.encode("ID_Field","UTF-8")+"="+URLEncoder.encode("myusrname","UTF-8")+"&"+URLEncoder.encode("PW_Field","UTF-8")+"="+URLEncoder.encode("mypwd","UTF-8")+"&"+URLEncoder.encode("confirm","UTF-8")+"="+URLEncoder.encode("false","UTF-8");
    // set the servlet that handles authentication as target
    URL page2 = new URL("https://secure.telkomsa.net/titracker/servlet/LoginServlet");
    // cast to httpConn to enable setRequestMethod()
    HttpURLConnection urlc2 = (HttpURLConnection)page2.openConnection();
    // formulate request with POST data urlc2.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
    urlc2.setRequestMethod("POST"); // experimental
    urlc2.setRequestProperty("Content-Length",""+postdata.length());
    urlc2.setRequestProperty("User-Agent","Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)");
    urlc2.setRequestProperty("Accept-Language","en-us");
    urlc2.setUseCaches(false);
    urlc2.setDoOutput(true);
    urlc2.setDoInput(true);
    urlc2.setFollowRedirects(true); // ??
    //send cookies
    urlc2.setRequestProperty("Set-Cookie", cookie); // or "Cookie" - doesn't work either
    //write other data
    PrintWriter out = new PrintWriter(urlc2.getOutputStream());
    out.print(postdata); // username and password here
    out.flush();
    out.close();
    //---------------- get the authenticated page with real ADSL statistics
    BufferedReader br = new BufferedReader(new InputStreamReader(urlc2.getInputStream()));
    String totextpane = "";
    String buffer = "";
    while (buffer != null) {
    try {
    totextpane = totextpane + "\n" + buffer;
    buffer = br.readLine();
    } catch (IOException ioe) {
    ioe.printStackTrace();
    break;
    textpane.setText(totextpane);
    } catch (Exception ex) {
    System.err.println(ex.getMessage());
    ---- END CODE---
    Thank you very much for any attempt at helping with this problem!

    I am struggling for many days to get a Java program to log in to an SSL page. The program is supposed to track ADSL usage statistics from https://secure.telkomsa.net/titracker/, but I never seem to get around Server returned Error 500.
    Could anyone please help me understand what I am doing wrong by looking at the method I used. (It seems on the server side it is a jsp servlet that handles authentication).
    Any help is deeply appreciated!
    I copy-paste the method directly from NetBeans:
    CODE>
    void connectHTTPS(String url){
    try {
    URL page = new URL(url); // login page necessary to get a jsp session cookie
    //------------ SET UP SSL - is it right?
    System.setProperty("java.protocol.handler.pkgs",
    "com.sun.net.ssl.internal.www.protocol");
    try {
    //if we have the JSSE provider available,
    //and it has not already been
    //set, add it as a new provide to the Security class.
    final Class clsFactory = Class.forName("com.sun.net.ssl.internal.ssl.Provider");
    if( (null != clsFactory) && (null == Security.getProvider("SunJSSE")) )
    Security.addProvider((Provider)clsFactory.newInstance());
    } catch( ClassNotFoundException cfe ) {
    throw new Exception("Unable to load the JSSE SSL stream handler." +
    "Check classpath." + cfe.toString());
    URLConnection urlc = page.openConnection();
    urlc.setDoInput(true);
    *Get the session id cookie set by the TelkomInternet java server
    String cookie = urlc.getHeaderField("Set-Cookie");
    //textpane.setText(totextpane);
    textpane.setText(cookie);
    //---------------- form an auth request and post it with the cookie
    String postdata =URLEncoder.encode("ID_Field","UTF-8")+"="+URLEncoder.encode("myusrname","UTF-8")+"&"+URLEncoder.encode("PW_Field","UTF-8")+"="+URLEncoder.encode("mypwd","UTF-8")+"&"+URLEncoder.encode("confirm","UTF-8")+"="+URLEncoder.encode("false","UTF-8");
    // set the servlet that handles authentication as target
    URL page2 = new URL("https://secure.telkomsa.net/titracker/servlet/LoginServlet");
    // cast to httpConn to enable setRequestMethod()
    HttpURLConnection urlc2 = (HttpURLConnection)page2.openConnection();
    // formulate request with POST data urlc2.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
    urlc2.setRequestMethod("POST"); // experimental
    urlc2.setRequestProperty("Content-Length",""+postdata.length());
    urlc2.setRequestProperty("User-Agent","Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)");
    urlc2.setRequestProperty("Accept-Language","en-us");
    urlc2.setUseCaches(false);
    urlc2.setDoOutput(true);
    urlc2.setDoInput(true);
    urlc2.setFollowRedirects(true); // ??
    //send cookies
    urlc2.setRequestProperty("Set-Cookie", cookie); // or "Cookie" - doesn't work either
    //write other data
    PrintWriter out = new PrintWriter(urlc2.getOutputStream());
    out.print(postdata); // username and password here
    out.flush();
    out.close();
    //---------------- get the authenticated page with real ADSL statistics
    BufferedReader br = new BufferedReader(new InputStreamReader(urlc2.getInputStream()));
    String totextpane = "";
    String buffer = "";
    while (buffer != null) {
    try {
    totextpane = totextpane + "\n" + buffer;
    buffer = br.readLine();
    } catch (IOException ioe) {
    ioe.printStackTrace();
    break;
    textpane.setText(totextpane);
    } catch (Exception ex) {
    System.err.println(ex.getMessage());
    ---- END CODE---
    Thank you very much for any attempt at helping with this problem!

Maybe you are looking for

  • Location of Parental Control files

    Does any one know where this file is stored? I thought it would be in user>Library>Preferences>com.apple.systemprefs. I tested a modified file with no luck. Setting up for a computer lab in a school and want to have different settings for the differe

  • Device attaches on Solaris 10

    Hello, We have a device driver that's been working on Solaris 7 and higher for some time. We're seeing different behavior on Solaris 10 that is causing us problems. We are running on Sparcs. Our driver has one pseudo device and one or more physical d

  • How to check if the visitor is registered or Not

    Hi im using PHP-Mysql in dreamweaver and i can login successfully .. now i want to make conditional region based on if the visitor is registered or not how can i check that? thanks in advance.

  • Replacement serial cable needed for an Apple Color Stylewriter 2500

    Hello, I have a question. I lost the serial printer cable for an Apple Color Stylewriter 2500, but if I order a replacement serial printer cable from we love macs, will the cable still work just as good as the original apple cable? I didn't want to h

  • Is idm cc 7.3.1 compatible with firefox5?

    when I installed Firefox5.0, it said that the version was not compatible with IDM CC7.3.1, and I found that IDM was not properly intercepting downloads with URL. then, I got back to Firefox 4 version to get the optimum use of IDM integration module f