| | |
Newbii Plz help me
![]() |
•
•
Join Date: Jan 2009
Posts: 15
Reputation:
Solved Threads: 0
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
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.
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.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
•
•
Join Date: Jan 2009
Posts: 15
Reputation:
Solved Threads: 0
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
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 ..." ?????
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 ..." ?????
Last edited by stephen84s; Jan 10th, 2009 at 6:28 am.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
"How to ask questions the smart way ?"
"How to ask questions the smart way ?"
•
•
Join Date: Jan 2009
Posts: 15
Reputation:
Solved Threads: 0
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
AND YA THANKS FOR ADDING A NEW WORD IN MY VOCABULARY REALLY DINT KNEW PLAGIARISM
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.
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.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
"How to ask questions the smart way ?"
"How to ask questions the smart way ?"
![]() |
Other Threads in the Java Forum
- Previous Thread: Need Help with Java Mortgage Calculator
- Next Thread: Stand alone Application Jar
| Thread Tools | Search this Thread |
911 actionlistener addressbook android api append applet application array arrays automation binary blackberry block bluetooth character chat class client code component consumer csv database desktop developmenthelp eclipse error fractal ftp game givemetehcodez graphics gui html ide image integer j2me j2seprojects japplet java javaarraylist javac javaee javaprojects jni jpanel julia lego linked linux list loops mac map method methods mobile netbeans newbie number objects online oriented panel printf problem program programming project projects properties recursion replaydirector reporting researchinmotion rotatetext rsa scanner se server set singleton sms sort sql string swing test textfields threads time title tree tutorial-sample ubuntu update windows working






