Help with http request

Please, help me with two problems I have to solve. I'm beginner in Java.
1. Create a simple program that sends http request for index.html and shows the result.
2. Create a simple program that gets the list of messages from a give mailbox over POP3 (server, username, pass - give as params).
Thank you!

But I think that I need request like this:
GET /index.html HTTP/1.1
Host: www.example.com
and as a result (maybe) something like this:
HTTP/1.1 200 OK
Date: Mon, 23 May 2005 22:38:34 GMT
Server: Apache/1.3.27 (Unix) (Red-Hat/Linux)
Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT
Etag: "3f80f-1b6-3e1cb03b"
Accept-Ranges: bytes
Content-Length: 438
Connection: close
Content-Type: text/html; charset=UTF-8Well, under the covers, that will be what you have.
It says "simple program" - do you think you are expected to connect your own socket and send a request you build from scratch yourself? Unlikely.
As for the response - you can probably skip the headers and just display the content that follows (in your example 438 bytes).

Similar Messages

  • Dimmer control for LED lights with HTTP Requests

    Hello,
    I'm al little bit know with LabVIEW, but I have a problem that I can't get fixed.
    For a project we control the led lights in a house with http requests (we use the http get request): this exists of a http address, the number of the light, the PWM (the brightness of the led) and the current.
    Controlling the lights with the switches is easy and is working fine. Now what we want to do is create a dimmer that can be controlled with the switches in the rooms.
    The following should happen: if the users clicks one time (so lets say for less than a second) than the light should just switch on. If he/she pushes the light switch and keeps pushing it than the light should dim.
    So the value of the PWM (and this is a string value) should change from 0 to (lets say) 100 when pushing it once, and it should decrease form 100 tot 0 (step by step) when the user keeps pushing the button. The thing I'm having difficulties with is making a difference between just clicking once and keeping the button pushed for a few seconds in the labview software.
    Any tips or ideas? Any Help is Welcome!
    Thanks
    CORE CVBA

    CORECVBA wrote:
    The thing I'm having difficulties with is making a difference between just clicking once and keeping the button pushed for a few seconds in the labview software.
    It sounds like everything else is working and your problem is to detect the button action details.
    Are you talking about a real physical switch or is this a switch on the LbVIEW front panel?
    All you need to do is detect a off->on transition, When it occurs, place the current tick count into a shift register, then subtract it from the tick count in subsequent iterations (as long as the button is TRUE). Change your output as a function of the elapsed time until the button is released.
    LabVIEW Champion . Do more with less code and in less time .

  • Problem with HTTPS requests to host with untrusted server certificate

    Hi,
    I develop an iPhone framework which sends HTTPS requests in order to communicate with a publicly available backend server. Currently I have a big problem regarding untrusted server certificates.
    The certificate of the backend server is not signed by a trusted CA, so my first approach was to use NSURLRequest's private allowsAnyHTTPSCertificateForHost. While this worked as expected an was fine as temporary workaround, our customer demands a clean solution as final result. Therefore I wrote a method which allows to install a provided certificate from the file system in the keychain, but this method does not work as expected in the iPhone Simulator. The certificate is installed in the host machine's Mac OS X keychain instead. Unfortunately, if I call NSURLConnection's sendSynchronousRequest method, I retrieve an "untrusted server certificate" error. It seems as if NSURLConnection is not able to access the host's Mac OS X keychain to retrieve the certificate.
    Is my guess correct or did I miss something?
    Would my approach work if I ran my app on a real iPhone device instead (I do not have one available yet)?
    Does there exist a keychain in the iPhone Simulator at all?
    Is it at all possible to send HTTPS requests to a server with an untrusted certificate on the iPhone Simulator or do I have to use precompiler directives to implement different routines depending on the underlying platform (simulator or device, respectively)?
    Any help is highly appreciated.
    Thanks,
    Matthias

    Indeed this would be a clean and simple solution. But our customer is not willing to get a real certificate, for whatever reasons.
    The question that remains is if the HTTPS requests would succeed on the iPhone device itself if the server certificate was installed in the keychain by the same app beforehand.

  • Accessing a .exe file with HTTP Request

    Hi!
    Can I access an executable file located in a WEB page with JMeter?
    I'm tryng to use a HTTP Request:
    Server Name or IP: 111.111.111.1
    Port Number: 8080
    Path: /cliente/file.exe
    The file is in a Tomcat application.
    When I run, in the View Results Tree - Sampler Result, it shows:
    Load time: 63
    HTTP response code: 400
    HTTP response message: Bad Request
    HTTP response headers:
    HTTP/1.1 400 Bad Request
    Date: Wed, 27 Apr 2005 14:26:09 GMT
    Server: Apache-Coyote/1.1
    Connection: close
    I already had copied the link and placed it into the browser to verify
    if it was correct and i had access to the file normaly.
    What am I doing wrong?
    Thanks in advance.
    Marcelo.

    If the .exe file is publically-accessible from your web server (like other normal .html files are for example), then accessing that resource would be done the same way as accessing others (get a stream of bytes that the server would serve up, and do something with those bytes on the client end of the connection). I don't know what JMeter has to do with that.

  • Update-Help cmdlet not able to update the help with https protocol.

    Hi all,
    I am using powershell 3.0 and trying to implement this updatable feature for our custom powershell module. But I getting the below error:
    PS C:\Users\scorchsvc> update-help -Module <modulename> -Force
    update-help : Failed to update Help for the module(s) 'modulename' : HelpInfoURI
     https://10.65.182.141/dev_releases/modulename/onlinehelp does not start with http.
    At line:1 char:1
    + update-help -Module modulename-Force
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (HelpInfoUri:Uri) [Update-Help], Exception
        + FullyQualifiedErrorId : InvalidHelpInfoUriFormat,Microsoft.PowerShell.Commands.UpdateHelpCommand
    I am able to get this work if I use "http". Error message clearly says that it only expects http. But in the Microsoft help topic for Update-Help cmdlet, it is mentioned that cmdlet works for both http and https both.
    Here are my enteries:
    •HelpInforURI entry in module manifest file is:
                        HelpInfoURI = "https://10.65.182.141/dev_releases/modulename/onlinehelp"
    •HelpContentURI in HelpInfo.xml file is:
                       <HelpContentURI> https://10.65.182.141/dev_releases/modulename/onlinehelp </HelpContentURI>
    I am running powershell as an administrator.
    I am not behind any proxy.
    Windows firewall is off.
    I am mentioning it AGAIN that I am ABLE to update help for our custom module if I use http in HelpInfoURI.
    I am also able to access the URI in IE with http/https.
    Can any one please help?
    Thanks,
    Vinay Ravish

    Hi vinay,
    It seems the certificate issue.
    Please access HelpInfoURI =
    https://10.65.182.141/dev_releases/modulename/onlinehelp with https header to see if your computer could access that.
    If it doesn't work, add it to your trusted site and download to see if there is related certification on that website to download and install it to trusted root certificate for test.
    Karen Hu
    TechNet Community Support

  • Java service invocation with HTTP Request

    A simple HTTP Request containing the SOAP envelope is a valid way of calling a web service, right?
    It seems simpler and more efficient than the "traditional" ways (Axis, JAX-RPC, etc), so what are the disadvantages?
    Thanks in advance
    Pedro

    kept the jars under APP-INF/lib

  • Firefox browser continues to hang and sometimes crashes when trying to load more than 10 bookmarks in tabs. Please help with my request as I would like to choose which tabs will load webpages and have all others stopped.

    ''locking as a duplicate - https://support.mozilla.com/en-US/questions/876430''
    I have thousands of favorites and Firefox is my web-browser of choice. Sadly I'm backed up on what bookmarks I have stored and if the websites are still active or not.
    I cannot load more than 15 bookmarks it seems at once as my PC is trying to load all the web content for each page in the new tabs.
    This is my PC specs:
    OS Name Microsoft Windows XP Professional
    Version 5.1.2600 Service Pack 2 Build 2600
    OS Manufacturer Microsoft Corporation
    System Name xxxxxxxx
    System Manufacturer System manufacturer
    System Model System Product Name
    System Type X86-based PC
    Processor x86 Family 15 Model 75 Stepping 2 AuthenticAMD ~2210 Mhz
    Processor x86 Family 15 Model 75 Stepping 2 AuthenticAMD ~2209 Mhz
    BIOS Version/Date American Megatrends Inc. 0301, 21/08/2006
    SMBIOS Version 2.3
    Windows Directory D:\WINDOWS
    System Directory D:\WINDOWS\system32
    Boot Device \Device\HarddiskVolume1
    Locale United States
    Hardware Abstraction Layer Version = "5.1.2600.2180 (xpsp_sp2_rtm.040803-2158)"
    User Name xxxxxxxx/ADMIN
    Time Zone Atlantic Daylight Time
    Total Physical Memory 2,048.00 MB
    Available Physical Memory 1.53 GB
    Total Virtual Memory 2.00 GB
    Available Virtual Memory 1.96 GB
    Page File Space 3.85 GB
    Page File D:\pagefile.sys
    I have High Speed internet connection with the provider Rogers.
    Dlspeed is 12.9 Mbps
    Upspeed is514 kbps
    My PC supports Windows 7 OS which I have as a multiboot alternative when my PC starts up.
    I have continually waited and it says Firefox is not responding and I may be able to see the multiple tabs opened in my browser but cannot navigate or access them.
    I have read on various sites that users have had as many as 1500 bookmarks load at once in tabs in the Firefox browser version that are outdated.
    I have not been successful with just loading 50 bookmarks my goal is to be able to have 500 tabs loaded in firefox with webpage loading stopped on all of them. I will choose reload for about 10 tabs at a time to view webpage content and then close and move on to the rest.
    My ultimate goal is to clear up the Thousands of bookmarks I have piling on for the past 6 years and some are duplicates or similar page sites.
    Their is no Firefox 3rd party addons that I could locate that would allow this. Only to restrict the number of tabs loaded by giving warning messages when limit is reached.
    Please assist me as it will greatly help me with finally deleting and re-organizing my Favorite and frequent websites in my Browser of choice Firefox.
    The email is generic for privacy but it is valid please respond with methods on how I can achieve my request or suggestions on how I can modify my browser or PC settings to allow this. Thanks Firefox Administration Team.
    I edited with a recent Workaround added to Troubleshoot section.
    If there is a keyboard shortcut or easier way to do this would someone please let me know?

    Firebug is notorious for causing problems like you described.
    Disable it when you don't need it or install it in a 2nd Profile. Then you can launch the 2nd Profile separately to use Firebug and not affect what you are doing in the 1st Profile,

  • Synchronous BPM starting with HTTP Request

    Hello there,
    I have a requirement to call 3 web services, consolidate their responses, and sending back the results to the caller (a web page in this case).  The request is coming over HTTP (synchronously...the file sender scenario that is on SDN does not apply here). 
    I have tried the sync/async bridge to prototype this synchronous scenario, but I get the following error.
    "The process does not support the given synchronous interface or does not support synchronous messages"
    Since the Receive step only allows Async and Sync/Async Bridge options (which doesn't really apply here because all of my web service calls are synchronous), and off course the HTTP as well.  What options do I have to build this scenario via BPM (or without BPM)?
    Looking forward to the replies.
    Thanks

    Hi,
    I'm trying to build similar ccBPM process which processes a synchronous message sent from XI SOAP sender to a Web Service. Both sender and receiver systems are synchronous.
    Instead of going directly to the Web Service receiver, I would like the message to go through ccBPM.
    Can you give a sample for such process ?
    What receive step mode should be used - "Asynch" or S\A "bridge" ?
    I tried to receive the message using "Asynch" mode and than send it with "Synch" mode.
    A runtime error is generated:
    <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="1">
    <SAP:Category>XIAdapter</SAP:Category>
    <SAP:Code area="BPE_ADAPTER">SYNCHONOUS_MESSAGE</SAP:Code>
    <SAP:P1 />
    <SAP:P2 />
    <SAP:P3 />
    <SAP:P4 />
    <SAP:AdditionalText />
    <SAP:ApplicationFaultMessage namespace="" />
    <SAP:Stack>The process does not support the given synchronous interface or does not support synchronous messages Exception CX_WAPI_DEF_PROPERTY_NOT_FOUND occurred (program: SAPMHTTP, include: , line: 0).</SAP:Stack>
    <SAP:Retry>N</SAP:Retry>
    </SAP:Error>
    Please help !
    Thanks
    Orit

  • Need help with HTTP keep-alive

    Hi folks!
    I have this very simple web server and I would like to add keep-alive support. I've been trying to get my head around it for a while and could need some help (I found this question in the archive, but those replies didn't help)...
    This is my starting point (stripped down to the basics):
    /* A listener thread that accept incoming requests by creating new request handlers */
    public class HTTPListener implements Runnable
        private ServerSocket serverSocket;
        public HTTPListener(int port)
            // Try to create a server socket on specified port
            try
                serverSocket = new ServerSocket(port, 0);
            catch (IOException ex)
                System.err.println("Oops!");
        public void run()
            while (!Thread.interrupted())
                try
                    // Listen on server socket until a request arrives
                    Socket s = serverSocket.accept();
                    // Create handler to service request
                    RequestHandler h = new RequestHandler(s);
                    new Thread(h).start();
                // Server socket closed when listening
                catch (SocketException ex)
                    Thread.currentThread().interrupt();
                // Failed to close socket or failure during server socket accept
                catch (IOException ex)
                    System.err.println("Failed to accept request");
            try
                serverSocket.close();
            catch (IOException ex)
                System.err.println("Hmpf...");
    /* Handler that prints out requests and always answers with status 200 */
    public class RequestHandler implements Runnable
        private Socket socket;
        public RequestHandler(Socket s)
            socket = s;
        public void run()
            System.out.println(">>> New request handler");
            try
                BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                String str;
                while ((str = reader.readLine()) != null)
                    System.out.println(str);
                sendDummyReplyWithKeepAlive();
                reader.close();
                socket.close();
            catch (IOException ex)
                System.err.println("Crap, got an exception!");
    }When I run the server (which in reality has a little more to it) I never get more than one request printed for each ">>> New request handler", which is not surprising!
    Now, with keep-alive support I expect to get consecutive requests from the same client printed by the same handler instance. What I have to do (as I've understood from my readings) is to modify the while loop in the request handler that reads from the socket so that it spins until the connection is closed by the client (or a keep-alive timeout occurs) and blocks while there is nothing to read.
    Perhaps I'm being stupid now, but how do I actually do this?

    ejp wrote:
    and also an incorrect implementation of the timeout period. This code will still wait forever if no data arrives.You're right... actually I didn't mean to put that while loop there! What I meant was simply
    if (!reader.ready())
        wait(keepAliveTimeout);
    if (!reader.ready())
        break mainLoop;
    // If we get here there is a new request to read...and I agree that it's ugly, that's why I'm asking you guys for help!
    setSoTimeout() is of course a way to go... didn't think of that although I have kind of already added it to my code but with a different timeout. Thanks!
    Last question then is:
    does reader.readLine() block like reader.read(), or do I have to use the latter?
    I would test for myself I could, but at the moment I can't...

  • Help with HTTP protocol.

    Hi every body.
    How can I get HTML code from some page in the internet with
    GET data and POST data?
    OR
    How can use on the usualy sockets like TelNET? I saw the
    MXLsocket class, this is the same thing?
    TNX all.

    Do not know if it's actual for you.
    request a XML with POST data is a little bit contraignent
    because you send only XML in the data field of the request.
    XML.sendAndLoad. (cf.
    http://livedocs.macromedia.com/flash/8/main/00002879.html
    But if you know how to handle that kind of datas on the
    server side, it seems to be your solution.

  • Adobe Update Server - help with HTTP service

    Hi all,
    Could anyone please help me out with the specifics for the HTTP server needed for the Adobe Update Server?
    I'm reading the TechNotes PDF, though helpful for the updater server itself, it isn't really clear on the HTTP service part.
    What url exactly? which rights? and so on...
    Maybe someone could host a website on his OS X Server machine and make some screenshots for me?
    Thanks in advance!!

    Hi,
    There is no specific requirement from the http server for setting up adobe update server using AUSST. It should be any up-and-running http server say Apache. URLs are automatically generated by AUSST in form of client configuration files, so you do not need to bother about the URLs as such.  Similarly rights to the generated updater contents would also be automatically taken care by the tool itself. The only thing you need to figure out and tell the AUSST tool is the http based URL corresponding to the update server root that you are setting up. The latest documentation at http://www.adobe.com/content/dam/Adobe/en/devnet/creativesuite/pdfs/UpdateServerSetupTool_ TechNote.pdf has some troubleshooting steps that help you out with most common issues.
    Thanks,
    Manju
    (AUSST Engineering team)

  • Help with http login privilige levels. Aironet AP-1100.

    In CLI we have users log in at priv 1 and use "enable" to increase privilege and do configurations. This allows "accounting" of command history.
    On the AIR-AP1121G-A-K9 (12.3(8)JED1) I cannot duplicate this for http login.
    I can log in as a user at priv 1. When I try to go to a privileged link like "Security" I get prompted for a second login/pw. Nothing works here unless I have a second user defined at priv 15 and enter that login/pw. The problem is - that login/pw can be used to log in via http in the first place which bypasses accounting of the actual user. It also allows login to the CLI at priv 15 which I cannot permit.
    To test I'm trying to use the most simple tests. No https, no radius, etc.
    After extensive reading of documens and forums I am using this:
    username test1 secret 5 abcdxxx
    username test2 privilege 15 secret 5 efghxxx
    enable secret 5 ijklxxx
    aaa new-model
    <--omit wireless stuff-->
    aaa authentication login default local
    aaa authorization exec default local
    aaa authentication login HTTPonly local
    aaa authorization exec HTTPonly local
    aaa authorization commands 15 HTTPonly local
    aaa cache profile admin_cache
    all
    aaa session-id common
    ip http server
    ip http authentication aaa login-authentication HTTPonly
    ip http authentication aaa exec-authorization HTTPonly
    ip http secure-server

    I'm thinking that maybe it can't be done. I was trying to have the AP require a user level login and then require a second  "enable" password for enable privileges - with "straight to enable" not possible  from the initial login.
    Here are some more attempts:
    (p1 = user with default privileges, p15 = user defined with privilege 15)
    (step up = can authenticate when some gui links result in secondary login dialog)
    aaa authentication login default local
    ip http server
    no ip http secure-server
    ---Only allows login with no login name, just enable pwd---
    aaa authentication login default local
    ip http server
    ip http authentication local
    ---Allows login with p1 or p15. Only p15 works for step-up---
    aaa authorization exec http1 if-authenticated
    aaa authorization commands 15 http1 local
    ip http server
    ip http authentication aaa exec-authorization http1
    ---Allows login with p1 or p15 user but no step-up if p1---
    aaa authentication login default local
    aaa authorization exec default local
    aaa authorization exec http1 local
    aaa authorization commands 15 http1 local
    ip http server
    ip http authentication aaa exec-authorization http1
    ---Allows login with p1 or p15 user but no step-up if p1---
    aaa authentication login http1 enable
    aaa authorization exec http1 local
    aaa authorization commands 15 http1 local
    ip http server
    ip http authentication aaa login-authentication http1
    ip http authentication aaa command-authorization 15 http1
    no ip http secure-server
    ---Allows login with p1 or p15 only if using enable pw but no step-up if p1---

  • Help with http 401 code ?

    [Add] I forgot to mark this as question [Add]
    I wrote a smalll program that send the xml to soap webservice on the server
    If I use the browser to type the link on(http://myserver/myservices/RequestWS) , it pops up a window authenfication box. I type user name and password in and it works (logged in, see the message from the server)
    However, if I run the java code below, the error is thorwn when I write to the outputStream.
    public static void main(String[] args) throws Exception {
    String SOAPUrl = args[0];
    String xml = args[1];
    URL url = new URL(SOAPUrl);
    URLConnection connection = url.openConnection();
    HttpURLConnection httpConn = (HttpURLConnection) connection;
    byte[] b = xml.getBytes();
    // Set the appropriate HTTP parameters.
    httpConn.setRequestProperty( "Content-Length",String.valueOf( b.length ) );
    httpConn.setRequestProperty("Content-Type","text/xml; charset=utf-8");
    httpConn.setRequestMethod( "POST" );
    httpConn.setDoOutput(true);
    httpConn.setDoInput(true);
    httpConn.setAllowUserInteraction(true);
    httpConn.setDefaultUseCaches(false);
    httpConn.setUseCaches(false);
    OutputStream out = httpConn.getOutputStream();
    System.out.println("httpConn.getResponseCode():"+httpConn.getResponseCode());
    out.write( b );
    out.close();
    }The console is:
    httpConn.getResponseCode():401
    java.io.IOException: Server returned HTTP response code: 401 for URL: http://ADMIN:password@myserver/myservices/RequestWS
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at SOAPClient.main(SOAPClient.java:81)
    Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL: http://ADMIN:password@myserver/myservices/RequestWS
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at java.net.HttpURLConnection.getResponseCode(Unknown Source)
    at SOAPClient.main(SOAPClient.java:74)
    Exception in thread "main"
    Please help.
    Thank you very much
    Edited by: mycoffee on Jun 8, 2010 10:27 AM
    Edited by: mycoffee on Jun 8, 2010 11:06 AM

    morgalr wrote:
    [Check this thread, it should answer your question.|http://forums.sun.com/thread.jspa?threadID=5247915]
    Thank for quick help. My mistake is the colon after "Authorization
    I removed it and I get another error now from 401, now I am getting 500 :D
    {code}String creds = "ADMIN:password";
    String encodeCreds = Base64.encode(creds.getBytes());
    httpConn.setRequestProperty("Authorization:", "Basic "+encodeCreds); {code}
    Edited by: mycoffee on Jun 8, 2010 12:35 PM
    Edited by: mycoffee on Jun 8, 2010 12:36 PM

  • Help with HTTPS

    I have a vendor with an HTTPS server application. I connect to the server, and send data via Posts, and they reply.
    Here is an example of the code:
    try{
    System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");
         Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
         URL u = new URL(url);
         HttpsURLConnection huc = (HttpsURLConnection) u.openConnection();
         huc.setDoOutput(true);
         huc.setDoInput(true);
         huc.setRequestMethod("POST");
         huc.connect();
         String sndData = URLEncoder.encode("Data sent to remote application);               
         OutputStreamWriter osr = new OutputStreamWriter(huc.getOutputStream(),"UTF-8");
         BufferedWriter bw = new BufferedWriter(osr);
         bw.write(sndData, 0, sndData.length());
         bw.flush();               
         bw.close();
         InputStreamReader isr = new InputStreamReader(huc.getInputStream());
         BufferedReader br = new BufferedReader(isr);
         String response = br.readLine();
         processResponse(response);
         huc.disconnect();
    This code works fine. However, I need to build on this. I would like to keep the HTTPS connection, and send/receive multiple times. Any suggestions?
    Thanks.

    Hi,
    I have exactly the same code, but have on:
    avax.net.ssl.HttpsURLConnection con = (javax.net.ssl.HttpsURLConnection)url.openConnection();
    following exception:
    Exception in thread "main" java.lang.ClassCastException: com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl
         at SimpleClient.madeObjectCall(SimpleClient.java:67)
         at SimpleClient.<init>(SimpleClient.java:26)
         at SimpleClient.main(SimpleClient.java:106)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
    What do you do different?
    Thx a lot.

  • NEed help with HTTP Post

    I am doing an application to login to www.ideas.singtel.com website. There is no error but how do i know that my userName & password is verified?
    [codeimport java.net.*;
    import java.io.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.net.ssl.*;
    class demo_process implements Runnable, ActionListener
         private Thread on;
         //Create Output & Input Stream
         //Connection
         private URL url;
         private URLConnection connection;
         //Create The GUI
         demo client1;
         public void actionPerformed(ActionEvent e)
              String command = e.getActionCommand();
              //TC_MainGUI1 Action Performed
              if(command == "Log In"
              && !(client1.userName.getText().equals(""))
              && !(client1.password.getText().equals("")))
                   on = new Thread(this);
                   on.start();
                   //sms client2 = new sms();
              else if(command == "Log In"
              && !(client1.userName.getText().equals("")))
                   JOptionPane.showMessageDialog(client1,
                   "Invalid Password");
                   client1.userName.setText("");
              else if(command == "Log In"
              && !(client1.password.getText().equals("")))
                   JOptionPane.showMessageDialog(client1,
                   "Invalid User Name");
                   client1.password.setText("");
              else
                   JOptionPane.showMessageDialog(client1,
                   "Invalid User Name & Password");
                   client1.userName.setText("");
                   client1.password.setText("");
         public demo_process(demo client1)
              this.client1=client1;
         public void run()
              Thread thisThread = Thread.currentThread();     
              //Establishing the connection
              try
                   url = new URL("https://www.ideas.singtel.com/myideas/AccessController.jsp?");
                   connection = url.openConnection();
                   login();
              catch(IOException e)
                   System.out.println("Cannot get connected!");
                   System.out.println(e);
         public void login()
              try
                   //Send the Mobile no. & Password
                   connection.setAllowUserInteraction(true);
                   connection.setDoInput(true);
                   connection.setDoOutput(true);
                   connection.setUseCaches(false);
                   connection.setDefaultUseCaches(false);
                   //Establish the Input & Output Streams
                   OutputStream ostream = connection.getOutputStream();
                   String send = "userName="+client1.userName.getText()+"&password="+client1.password.getText();     
                   byte[] send2= send.getBytes();
                   ostream.write(send2);
                   ostream.close();
                   System.out.println(send2);
                   System.out.println("Echo: " + client1.userName.getText());
                   System.out.println("Echo: " + client1.password.getText());
                   InputStream in = connection.getInputStream();
                   InputStreamReader r = new InputStreamReader(in);
                   int c;
                   while((c = r.read()) != -1)
                        System.out.println((char) c);
                   System.out.println(c);
                   in.close();
              catch(IOException e)
                   System.out.println(e);
    }]

    If "form2.php" processes the POST request then you shouldn't be sending it to "myform.php" in the first place.

Maybe you are looking for