Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

Reading web pages from a standalone application

Thread view: 
moGio - 17 Jun 2006 16:04 GMT
Hi all,
sorry for my english.

I don't have much experience on java so I don't know if what I want to
realize is possible or not.

I am trying to do a little standalone java application which reads web
pages, parse them and show some data.

Using URL.openConnection().connect() and some reading on it with an
InputStreamReader, I am able to read a standard web pages.

The problem is that the pages I need to read are protected: for
example, just think about a webmail sevice: first there is an
autentication form with the fields:
 username
 password

after submission you are free to navigate the pages (inbox, sent,
trash, options, ...).

I believe that when you login, username/password are stored in the
session active between your browser and the server.

In my application I am able to read the login page, find out the
user/password fields and the "action" of the form (the page following
the submit) but than I don't know what to do...

I tried to write on the connection those data and than I tried to load
the following page, but I'm always redirected to the login page: I
think I am not correctly using sessions or cookies in my application...

do anyone of you gurus have some suggestion? Maybe a link to some
tutorial? Is possible to realize my intentions with java?

I know I haven't been too much clear... my problem in summury is: I
can't read web pages from a standalone java application because I'm
always redirected to the login page.

tnx in advice
Chris Smith - 18 Jun 2006 06:54 GMT
> Using URL.openConnection().connect() and some reading on it with an
> InputStreamReader, I am able to read a standard web pages.
[quoted text clipped - 4 lines]
>   username
>   password

> I tried to write on the connection those data and than I tried to load
> the following page, but I'm always redirected to the login page: I
> think I am not correctly using sessions or cookies in my application...

Yep.  Cookies are actually a bit of a pain with URLConnection.  Google
for Jakarta Commons HttpClient for a more complete HTTP client-side API
that includes easy cookie management.

Signature

Chris Smith - Lead Software Developer / Technical Trainer
MindIQ Corporation

moGio - 19 Jun 2006 22:29 GMT
Chris Smith ha scritto:

> Yep.  Cookies are actually a bit of a pain with URLConnection.  Google
> for Jakarta Commons HttpClient for a more complete HTTP client-side API
[quoted text clipped - 3 lines]
> Chris Smith - Lead Software Developer / Technical Trainer
> MindIQ Corporation

Yes, I finally realized that the package java.net is not the best to
use to work with http,
I am studying the one you suggested (which seems to me so much
powerful) and also HttpUnit (on sourceforge).

thx


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.