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 / December 2005

Tip: Looking for answers? Try searching our database.

URL Connection and getLastModified()

Thread view: 
lukasmeyer - 04 Dec 2005 19:28 GMT
Hello,

I'm trying to write a small method, that gives me the LastModified Date
of an URL. My program is working and returns sometimes this Date. But
in most cases it return a Date of 1970-01-01. If i access this Website
by Browser and lookup this information by "Page Info" it shows me a
correct date.

So can anyone explain me why getLastModified() can't get the correct
date and the browser can? Is there a possibility to get this date in
another way and how does the browser access this information?

best regards,

Lukas
Thomas Hawtin - 04 Dec 2005 19:51 GMT
> I'm trying to write a small method, that gives me the LastModified Date
> of an URL. My program is working and returns sometimes this Date. But
[quoted text clipped - 5 lines]
> date and the browser can? Is there a possibility to get this date in
> another way and how does the browser access this information?

It's worth looking at exactly what the server is sending:

Find yourself a telnet program (or nc on some UNIX-like systems). telnet
to the web server with port 80. Once it has connected write an HTTP request:

HEAD / HTTP/1.1
Host: java.net

(You will need to press return a second time.) The first word is the
command. HEAD returns just the header information (sometimes). GET
returns the header and content. Next is the URL. I've just gone for the
root page. Then the protocol name.

The next line(s) are request headers. I've just set Host to the machine
I connected to. This is necessary for virtual web hosts.

Then a blank line indicates end of headers.

You should get a response something like:

HTTP/1.1 200 OK
Date: Sun, 04 Dec 2005 19:39:03 GMT
Server: Apache/1.3.33 (Unix) mod_perl/1.29
Vary: Host
Content-Type: text/html; charset=ISO-8859-1
X-Cache: MISS from www.java.net

Tom Hawtin
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/

Roedy Green - 04 Dec 2005 22:11 GMT
On Sun, 04 Dec 2005 19:52:26 +0000, Thomas Hawtin
<usenet@tackline.plus.com> wrote, quoted or indirectly quoted someone
who said :

>Find yourself a telnet program (or nc on some UNIX-like systems). telnet
>to the web server with port 80. Once it has connected write an HTTP request:
>
>HEAD / HTTP/1.1
>Host: java.net

the other way to do is with a packet sniffer. You snoop on what yore
browser sends and receives.

See http://mindprod.com/jgloss/sniffer.html

The advantage of the sniffer approach is your browser will fill in
other fields the server may demand, e.g. cookies, User-Agent etc.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



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.