Read html from a cgi returned page using URL

i have a problem with the following case.
i want to quote google's searching result in my program, and what i do it like this.
1> open a connection
URL url = new URL("http://images.google.com/images");
URLConnection connection = url.openConnection();
connection.setDoOutput(true);
2>post a parameter
PrintWriter out = new PrintWriter(connection.getOutputStream());
out.println("q=singapore+satellite+image");
out.close();
3>Read the result
BufferedReader in = new BufferedReader(
                    new InputStreamReader(
                    connection.getInputStream()));
     String inputLine;
     while ((inputLine = in.readLine()) != null)
     System.out.println(inputLine);
     in.close();
However, i get the following result:
<HTML><HEAD><TITLE>Bad Request</TITLE></HEAD>
<BODY><H1>400 Bad Request</H1>
Your client has issued a malformed or illegal request
</BODY></HTML>
Press any key to continue . . .
can anyone tell me what is wrong?
thanks a lot.
post on networking p2p.wrox.com

Without looking it up, I seem to recall there's a setMethod() method, and you give it "GET" for a parameter. But you could look that up. With the Get method, the parameters are appended to the URL after a question mark, like this:
http://images.google.com/images?q=singapore+satellite+image
where as with the Post method, the parameters are sent in a separate stream, the way you wrote your program. Get can usually extend only to 255 characters (or some small number like that), Post is theoretically unlimited.
If you look at the URLs that a Google search produces, you will see that it uses the Get method.

Similar Messages

  • Read html from a cgi returned file: help, thanks

    i have a problem with the following case.
    i want to quote google's searching result in my program, and what i do it like this.
    1> open a connection
    URL url = new URL("http://images.google.com/images");
    URLConnection connection = url.openConnection();
    connection.setDoOutput(true);
    2>post a parameter
    PrintWriter out = new PrintWriter(connection.getOutputStream());
    out.println("q=singapore+satellite+image");
    out.close();
    3>Read the result
    BufferedReader in = new BufferedReader(
                        new InputStreamReader(
                        connection.getInputStream()));
         String inputLine;
         while ((inputLine = in.readLine()) != null)
         System.out.println(inputLine);
         in.close();
    However, i get the following result:
    <HTML><HEAD><TITLE>Bad Request</TITLE></HEAD>
    <BODY><H1>400 Bad Request</H1>
    Your client has issued a malformed or illegal request
    </BODY></HTML>
    Press any key to continue . . .
    can anyone tell me what is wrong?
    thanks a lot.
    post on networking p2p.wrox.com

    Try a shortcut like this:
    URL url=new URL("http://www.google.com/search?hl=en&q=java");
    Where the query string is in bold!
    V.V.

  • Can I import HTMLs from inside the project and use as portlet page ?

    As you know, I am using Java Studio Creator 2 Update 1 for my current portal project. I have created JSR-168 JSF Portlet Project for my portlet development.
    As I have some html pages ready for my development,
    Can I import HTMLs from inside the project and use as portlet page for my project?
    I did the followings steps:
    1: In side the project - File -> Add Existing Item -> Web Page ( imported test.html page from my local folder)
    2: Let it convert some of the tags for me ( so now it becomes - �test.jsp� )
    3: Set it to initial view.
    4. A default portlet page � newPortletPage.jsp is still there with no initial view.
    Now after doing this, No Visual Designer and Properties window available to for that �test.jsp� page. Though it allowed me to �build� the project successfully.
    When I build and run the portlet application, got the error message �Error occurred in portlet!� on Pluto Portal. Please advice.

    You do not open fcpproject files. You don't double click or anything else. The files have to be in the correct folder structure in the Final Cut Projects folder and the application opens them automatically. Can you post screen shots of the Final Cut Projects folder and its location.

  • 0 down vote favorite share [fb] share [tw]        How to hide cut/copy/paste/Replace- menu on the UIWebView when it is being displayed over the keyboard.  Detail: I am having a HTML from, having text box, displayed using UIWebView. If user types in text b

    How to hide cut/copy/paste/Replace… menu on the UIWebView when it is being displayed over the keyboard.
    Detail: I am having a HTML from, having text box, displayed using UIWebView. If user types in text box it shows the keyboard. Now If user tap and hold on text box it shows a popup menu. Now while keyboard and pop up are being displayed user scrolls the view. At this time it shows pop up over the keyboard which I need to hide.
    I tried setMenuVisible of UIMenuController when popup rect and keyboard rect intersects each other on viewDidScroll but it didn't help me.
    Any clues will help a lot.
    Thanks.

    You are more likely to get an answer if you post programming problems to the Developer forum. This forum is intended for normal user level problems.

  • Return Page (AICC) url

    To date we have only worked with SCORM 1.2 training files in OLM. We are looking to launch a course from a 3rd party vendor and to test they are asking for our return page (AICC) url.
    Does anyone know where I can find this to supply to this vendor?
    Thank you,
    Lisa Hart
    Manager, Learning Management Services
    Haemonetics Corporation
    [email protected]

    Hi Lisa,
    One way is to set up a learning object with the tracking type of HACP (if you don't have one), offer it and set up a class, and enroll yourself.
    When you launch AICC/HACP course, view the source of the OLM Player. There should be a variable in the source code of the page that says AICC_URL = with a URL value. That value is your return page (AICC) url.
    Scott
    http://www.seertechsolutions.com

  • Reading HTML from JSP

    Hi, I am currently doing an enterprise application and constructed a page using html with a link using HREF. When I click the link I run a jsp file. It there a way to read the name of the link into a string in the jsp file when the link is clicked? Please help I am still a bit green in jsp.
    Thank you.

    // I usr acceptCharset
    %@ page contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
    <html:form acceptCharset="UTF-8" action="/doSomthing">
    <html:text property=" firstname" />
    </html:form>
    in the action Action class
        Sysrem.out.println("Firsname: "+myForm.getFirstname())
       // ouput
        Firstname: ��ther is any method to it ???????

  • How to read files from MIT-BIH arrhythmia database using labview

    hello friends,
    How can i read the files from MIT-BIH arrhythmia database using labview 8.6. These file extensions are in different format ie is .atr, .dat and .hea
     The link for the following database is below, any example vi for reading this data in labview would be very useful.
    http://www.physionet.org/physiobank/database/mitdb​/
    Message Edited by infra444 on 01-27-2009 07:01 AM

    You will find some help here.
    http://www.physionet.org/physiotools/matlab/#wfdb
    Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
    (Sorry no Labview "brag list" so far)

  • Read data from MCU with bluetooth with using labview function ?

    Hi.
    I send data from MCU to labview. I do this work with usb to serial pl2303TA and it work well.
    recently I decide to use bluetooth for communicate between MCU and LV. MCU use a bluetooth module like HC-05 or BC-04. 
    with using VISA read functions we just use a VISA configured serial and read functions. 
    in bluetooth we must use which functions for receive data ? and where we can use them ?  
    I use bluetooth discover function and it show my phone or module ID. what are other steps for reading data ?
    Thanks.

    As Dennis_Knuttson pointed out, if you associate a COM port to your bluetooth adapter on your LV PC, you can just use very simple VISA functions.
    Maybe this example can help you how to do this (this one is an Android<-PC serial comm via bluetooth):
    https://decibel.ni.com/content/docs/DOC-39917

  • How to read data from PC format external disk, using Labview MAC

    Hi folks,
    For years I have not been able to read data files from a PC formatted (created) external disk, using Labview for Mac. More specifically:
     - I have Labview 7.01 running on OS X 10.4.11 on a PowerBook G4
     - I have a 500GB external USB/firewire disk that was formatted on a PC and has data files (custom format) that were created on the PC. I believe that C code actually creates the files, but Labview 7/PC opens the files and appends some info (I don't think the fact that C or Labview touches the files is actually relevant to this issue though).
     - I can connect the 500 GB disk to my mac, and it will mount just fine and OS X can see all of the data files (and anything else on the disk).
     - if I use my Labview app to open and read a data file it fails:
           - open/create/replace.vi (with read-only access) shows a file dialog window that lets me navigate to any file on the external disk.
           - but, the vi returns an error 7
     - if I use OS X to copy the data file to my Mac disk, my Labview app works fine.
    So, does anyone know if:
     - I'm just doing something wrong in my Mac Labview app?
     - Labview 7.x solves this problem?
     - Labview 8/Mac solves this problem?
     - OS X 10.5 solves this problem; with Labview 7 or 8; or does OS X 10.5 worsen the problem?
    Thanks, in advance...

    Hi kehander,
    Thanks for the reply. I tried filling a constant path with the Mac-defined path to a data file on the USB disk (ie "DATA2:file1.dat"). This resulted in the same error message.
    I then considered that maybe I was misinterpreting the LV error message, and that perhaps I was supposed to address the file using PC-notation (ie. "DATA2\file1.dat"), even though the app is running on a Mac. No joy with this, but I get a different error msg:
    "Error 1430 occurred at Open File
    Possible reason(s):
    LabVIEW:  The path is empty or relative. You must use an absolute path."
    Can you share what your reasoning was for your suggestion... I'm not sure I understand why a constant path would produce different results?

  • IE 5.0 hanging when one is reading HTML from Weblogic 6.0

    I have following configuration:
    Local network (TCP/IP, Wins server)
    SERVER: NT 2000 AdvServer & Weblogic Eval 6.0 Sp2 & Oracle 8.1.7
    CLIENTS
    1) Win 2000Pro & IE 5.0
    2) Win 98 & IE 5.0
    Quite often IE (client one) is hanging when one is reading static HTML pages.
    Also IE (client two) says that there is fail in Kernel and display dump of memory.
    In last case it is occured less often.
    I located these static HTML pages in Webdefault catalog.
    Also I have two simple JSP pages, one of them is genering current time and is
    working constantly.
    This situation was not changed when I did the following:
    1. Disable Java Plugin
    2. Set Weblogic Sp1.
    What did I wrong?
    Thanks in advance
    Eugenia
    [email protected]

    I play the mp3 files as sprites in the score that are
    streaming from the web server. If you selecr "Insert->Media
    Element->Shockwave Audio" from the menu in Director you can
    choose to import a mp3/swa file. This file will import as a cast
    member which will have an external link address. (e.g.
    http://www.adobe.com/mysound/myfile.mp3)
    I have then dragged this cast member onto channel 1 in the score
    spanning for instance 10 frames.
    It does not make a difference wether the soundfile is of type
    mp3 or swa, I have tried both.

  • Read Data from a different presentation server using IP address

    Hi Experts,
    I have a excel file on a system with ip a.b.c.d...I want to upload data from that excel into SAP.
    I am able to achieve it by using gui_upload function module by specifying file path in the format as  
    a.b.c.d\Shared\abc.xls.
    But, i am able to read the data only after i am logging into the remote system thru their user id and password using the RUN->... operation once....after i am doing this only, i am able to read the data....i want to read the data thru SAP, i will provide user id and password if required...only thru SAP...no other medium of interaction should be there.
    Please suggest me a approach.
    Regards,
    Lakshman.

    Unfortunately, there is not a lot of documenation on how to use DDE in Forms. I would recommend you keep googling for examples. I know there are some demo's out there that show the "basics" of how to use DDE, but then you are pretty much on your own to "Trail and Error" your way through making it work.
    I haven't actually worked with DDE in Forms 6i, but I have used OLE with WebUtil's Client_OLE to interact with MS-Office so I don't have any DDE examples I could give you. Sorry. I have seen some DDE examples here in the Forum so you could try searching here as well.
    Craig...
    Edited by: CraigB on Nov 21, 2011 8:53 AM

  • How to read data from FESTO MPS work-station using easyport in Labview ?

    Hello!
    I am working on a festo MPS PA compact workstation and I have connected the system to the PC using the EasyPort.
    So far, I can send commands to the system to turn on some components like Pump, Heater, Pressure Valve. But the problem is that I could not read the data from the sensors at the system like the tank level and the temperature of the water.
    attached is the vi file for what I have done so far
    I would really appreciate your help!!
    Thank you in advance
    Attachments:
    EasyPort1.vi ‏19 KB

    cise438,
    thanks for the forum post. Are you not able to read any values? or are you getting incorrect values? Are the reads from the sensors digital reads or analog reads?
    Applications/Systems/Test
    National Instruments | AWR Group

  • Read out from OBD-II Freematic Emulator using ELM327 with USB and LabView

    Hello. I have an Freematic OBD-II mk2 emulator which simulates diagnostics of a real car. I have connected an ELM327 diagnostic device with USB cable to the emulator and a PC. The connection between emulator, diagnostic device and computer works. Now I need to read out parameters in LabView. How do I do it? I tried to use the NI VISA functions, but didn't manage to read out anything sensible. How can I for example read out Engine RPM? Do you have some example code?
    I want to avoid using Automotive Diagnostic Command Set, because it's to expensive for me. 

    Oh yes, I didn't realize what this hardware does.  Some beginners think that a DB9 is a standard interface for a CAN bus, and when they see the DB9 serial port on their computer they think they can just use that.  I was worried this was what you were attempting.
    So yes VISA is the right way to go.  Once you have this device installed and recognized in Windows it should appear as a COM port.  You can open the Windows Device Manager and by plugging and unplugging your device you should see a COM port appear and disappear.  
    Assuming you do launch LabVIEW and go to the example finder and search for Simple Serial.  This is an example VI that can send serial data to a COM port, wait, then read the response.  It can basically work like hyperterminal.  Assuming there are no already made LabVIEW drivers (I haven't seen any) this will be a good place to start.  Using documentation on your hardware you can start to come up with commands to do things like read and write CAN data, by sending the appropriate commands to the hardware over serial.
    http://www.elmelectronics.com/obdic.html
    Depending on what you want to do it might be a decent amount of work.  Of course if you do get anything good and working feel free to post your progress here so others can benefit.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • How do I read in from a Lab-PC+ card using Visual Basic?

    I have a Lab-PC+ card installed and hooked up to a number of pressure trasnducers etc. I want to read the data in using VB but I've heard that VB cannot interface to I/O without some extraq bits of software.

    While your data acquisition programming in Visual Basic will be easier and faster with our Measurement Studio product, you are not restricted to using it. You can simply make calls into the NI-DAQ driver DLL. Take a look at the first Knowledge Base article I have linked below for information on installing NI-DAQ examples for VB. You will be interested in the second paragraph which describes how to install examples from the driver.
    How Do I Install the DAQ Example Programs for VB and VC?
    http://digital.ni.com/public.nsf/websearch/67B97D1BADB40A4186256C7500770847?OpenDocument
    As for the API into the driver DLL, you will need the NI-DAQ Function Reference Manual, which I have also linked below.
    NI-DAQ Function Reference Manual for PC Compati
    bles
    http://digital.ni.com/manuals.nsf/websearch/1630A0B68738B269862567C1007A2912?OpenDocument&node=132100_US
    Regards,
    Justin Britten
    Applications Engineer
    National Instruments

  • Create PDF from Web Page Using URL List

    Hello
    I have a list of 100+ URLs which I would like to convert into PDF's
    I currently need to open each web page and hit the convert button
    Is there a way to automate the process. (For example can I import the list of URL's into Acrobat) and have Acrobat convert all the urls into PDF
    Thank you

    JohnnyNobody wrote:
    S.D.A.
    Your response did not show up, could you please repeat
    Thanks
    Sure, (e-mail responses aren't working good I'm afraid).
    What I said; was that I don't know of a 'pont 'n click' way of doing this, It can be done programmtically.
    Might not be what you want to hear though.

Maybe you are looking for

  • Not able toView Data in Answers

    Hi, I created small Repository sai.rpd but when i logon to the answers i am un able to see the data. i am getting the below error Odbc driver returned an error (SQLExecDirectW). Error Details Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P State: HY000. Code

  • Sum in report

    Hello ,  i have group report that group email/sms per patient name . when i sum the email/sms ;summation get from db with repeated col the result expected  in footer is : emailcount=6 , smscount is =8 Ahmed Osman

  • 10.2.8 installation and external hard disk does not show on desktop

    I just reinstalled OS X 10.2 (by erasing the hard disk during installation) and upgraded with the Combo pack to 10.2.8 . This is an iMac G4 1GHz with a 17-inch display. I tried connecting a Western Digital MyBook with 500Gb through both the USB port

  • Customer master record

    well, i m new in sap..may i know what is customer hirarchy, how does it work...and how to configure it in the system?

  • Steve Jobs Probably Uses A Blackberry

    I have had it with Iphones! My 1st generation Iphone was great for the first year until it conveniently developed dead screen spots at month 14. The "Genious Bar" told me that because I was out of warranty I would have to pay $199 for a refurbished f