This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java Micro Edition and the fly likes how to read specific data from a web page.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "how to read specific data from a web page.." Watch "how to read specific data from a web page.." New topic
Author

how to read specific data from a web page..

saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
i want to develop a midlet which can read specific data from a web page..

any suggestions please...
thanx in advance

cinux


A = HARDWORK B = LUCK/FATE If C=(A+B) then C=SUCCESSFUL IN LIFE else C=FAILURE IN LIFE
SCJP 1.4
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Is this a web page that already exists that you didn't create. If so, then you will have to write code that parses the HTML and get the data you would like.

Or you can create your own Servlet, that your MIDlet calls, in which the Servlet does the call to the outside Web Page, and parses it on behalf of the MIDlet, and just send back the needed text to the MIDlet.

Otherwise, I would suggest creating a seperate Servlet for you to call that will only pass back the specific text that you want. Or if you don't have Servlets, then create a new "html" page that will just be text that sends back the information that you want.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
yes, i want to create a servelt which can read the data from the html page and hand it over to the midlet..
but how???
Alfredo Estrada
Greenhorn

Joined: Jan 07, 2006
Posts: 4
Dear saikrishna cinux:

the way to read "bytes" a URL connection is next pseudocode:

1- Connect to URL
2- Open InputStream
3- Read bytes and store into ByteArrayOutputStream
4- Close the InputStream
5- Get the byte[] from the ByteArrayOutputStream, and process !
6- Notify to other Main Class( like work as Listener) (e.g. using static boolean flags) that the connection has done.

*7 If any error ocurrs, must do some like step 6. but specifing the reason of error.

these steps shuld be in a separated Thread, the body of run method.
Casper Maxwell
Ranch Hand

Joined: Aug 04, 2005
Posts: 88
You may use following code as a starting point too:

How to download an image from a web server
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to read specific data from a web page..
 
Similar Threads
Regarding onSubmit method
Uploading a image file from SD card to web service
Generate Excel file
Thread from Struts Action class/Servlet
URL reading contents from a webpage online