Querying a web site for Single Info by Java

Posted on 2004-04-26
Last Modified: 2010-03-31

Dear Experts

My question is , can I query a web site for specific info - and only this info - by Java ?

for example, there is a web site that give the weather forecast for cities & countries, and from my application ( actually a j2me device )  I want to query for spicific city and get only this value ( not in HTML ), I did something like :

URL = ""

but it gave me the whole page  in HTML format,

what I need is only for example : 24 celcuis

thanks for your help

Question by:kotoz23
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
LVL 92

Expert Comment

ID: 10925099
the site would need to support what u require.
otherwise u need to parese the html.

Expert Comment

ID: 10925191
As objects said, it can be done only if the site supports retrieval of data based upon ur request.

Alos if it does....It will always give u a html u have to parse it accodingly to get the desired data which then you can show in ur application

Author Comment

ID: 10926010

So it seems that I've to make a web site that take this information first from that site and then forward it to the j2me device ?, is it possible ? ( please give me some hints because I am not a web server developer )

So what is the use of the .setRequestProperty("content-type","plain/text")  instead of plain/html ?!

thanks for your help
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

LVL 86

Expert Comment

ID: 10927551
So it seems that I've to make a web site that take this information first from that site and then forward it to the j2me device ?, is it possible ?

Yes. This would be using a proxy essentially. The proxy would take the parameter from the mobile device, forward that to the real site, get the response, scrapes the required info from the page and then returns that subset of info to the mobile device. You will need control of a scriptable web server in order to do this
LVL 92

Expert Comment

ID: 10934444
first you should check that the site doesn't already provide a service you can use.

> and then forward it to the j2me device ?, is it possible ?

Figuratively speaking no.
What your j2me device would do is make a request to your server, which would then return the required results.
These could be obtained by calling the target site and extracting thje required details from the page, or in this case they could be just returned from memory so you're not pulling the same details from target site on every request.

> So what is the use of the .setRequestProperty("content-type","plain/text")  instead of plain/html ?!

That says that the returned response is plain text and not html.

Author Comment

ID: 10935673

Thank you all, but if ".setRequestProperty("content-type","plain/text")  " says that I get the response in text, so no need to do this proxy, because the information I'll get will be small anyway, no pictures, no tags.. , Am I right ?

I actually tried setRequestProperty("content-type","plain/text")  but it gave me same as HTML ?!!

maybe I used it wrong ?

please help

LVL 92

Accepted Solution

objects earned 75 total points
ID: 10935701
sorry read your last q too fast, content-type is typically set on the *response* from the server, and not the request.
LVL 86

Assisted Solution

CEHJ earned 50 total points
ID: 10937314
You certainly can't use it to force the server to return its results in a different format

Author Comment

ID: 10970349

Object : can you give some hint in this question


Author Comment

ID: 10970647

just an advice, what is the best to use for such proxy job , php, cgi/c++, javascript, servlet ?

or all possible ?

thanks, if required another question I'll do

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
even odd program using while loop 3 74
configure dependency in POM for new database 3 48
Selenium docs api java index 3 69
Java array sort 10 35
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question