Hi ,
I am a new to java and am stuck with coupe of lines i wonder if any of you ppl could help me i wud be gr8full...
URL localURL = new URL("http://www.xyz.com");
URLConnection localURLConnection = localURL.openConnection();
String str2 = localURLConnection.getHeaderField("string1");
What wud these lines actually do or to be more precise wt wud i receive in str2 is there a way to see wt the string wud be.

Thanks in advance

You could already answered your question if you checked API
URLConnection.getHeaderField(String name)

getHeaderField

public String getHeaderField(String name)

Returns the value of the named header field.

If called on a connection that sets the same header multiple times with possibly different values, only the last value is returned.

Parameters:
name - the name of a header field.
Returns:
the value of the named header field, or null if there is no such field in the header.

Ok still not clear am confused anyway... is their a way i could see wt it returns without actually having to write any java ... i mean something from the src coad or something

Ok still not clear am confused anyway... is their a way i could see wt it returns without actually having to write any java ... i mean something from the source code of page having the applet or something and wt is the value is it like an integer number or a string of characters.

Thanx for the reply

You need to know at least something about the HTTP protocol before understanding that piece of code.

But what comes to my mind is why do you want to know what that piece of code does, are you involved in plagiarism .... trying to use someone else's code and showing it off as you own, because for a person trying out something new the question is always on the lines of "How do I do this ..", where as yours is the opposite "What does this do ..." ?????

well no am not into any plagiarism or anything ...its just that there is this challange in a website i had to solve it and the thing is i understood almost all of the code other than these cpl of lines ...I guess i will have to go thru HTTP but still any suggestion as to what am i supposed to look at. It wud be gr8 help....AND BELIEVE ME AM DOING NOTHIN LIKE PLAGIARISM ....thanx FOR THE REPLY

AND YA THANKS FOR ADDING A NEW WORD IN MY VOCABULARY REALLY DINT KNEW PLAGIARISM

Comments
Read the forum rules on chat-speak.

Well what you are looking for is a quick fix, an explanation of a couple of lines which will solve all your problems ... May be the following line will do :-

The couple of lines of code you have pointed, get the value of the HTTP Header "string1" set by the server when you invoke the default page of "http://www.xyz.com".

Now if you do not understand that I suggest you begin to read more about HTTP, cause there are no short cuts when you are gathering knowledge.

This article has been dead for over six months. Start a new discussion instead.