WEB BROWSER AND WEB SERVER:
* A web browser lets a user to request a resource.
* The web server gets the request, finds the resource, and returns something back to the user. The returned resource can be a HTML page, a picture, a sound file or even a PDF document. The client asks for the resource and the server sends it back.
In short, A web server takes a client request and gives something back to the client.
REASONS A WEB SERVER DOESN'T SEND A RESOURCE:
* A server doesn't send a resource if its not there, or even if it’s not where the server is expecting it to be. "404 Not Found" is the error response you get when the server can’t find what we asked for.
WEB CLIENT:
* Clients mean both (or either) the human user and the browser application.
* The browser is the piece of software (like Netscape or Mozilla) that knows how to communicate with the server. The browser’s other big job is interpreting the HTML code and rendering the web page for the user.
* The client is the browser application doing what the user asked it to do.
FUNCTIONALITY OF A WEB CLIENT:
A web client lets the user request something on the server, and shows the user the result of the request.
* CLIENTS AND SERVERS COMMUNICATE USING HTML and HTTP.
HTML(HyperText Markup Language):
When a server answers a request,the server usually sends some type of content to the browser so that the browser can display it. Servers often send the browser a set of instructions written in HTML. The HTML tells the browser how to present the content to the user. All web browsers know what to do with HTML, although sometimes an older browser might not understand parts of a page that was written using newer versions of HTML.
HTTP(HyperText Transfer Protocol):
Most of the conversations held on the web between clients and servers are held using the HTTP protocol, which allows for simple request and response conversations. The client sends an HTTP request, and the server answers with an HTTP response.
HTML and HTTP IN SHORT:
if you’re a web server, you speak HTTP.
When a web server sends an HTML page to the client, it sends it using HTTP.
Monday, October 5, 2009
Wednesday, September 30, 2009
J2EE Class -1
Dear friends,
From today I would also like to focus on J2EE concepts.
What all you need to learn:
Besides your brain and a pencil, you also need Java, Tomcat 5, and a
computer.You do not need any Integrated Development Environment like Eclipse, etc. I strongly recommend you, not to use anything but a basic editor until you complete the J2EE tutorial.
GETTING THE SOFTWARE
* If you don’t already Java SE v1.5 or greater, you’ll need it.
* If you don’t already have Tomcat 5, go get it from:http://tomcat.apache.org/
* Select "Tomcat v5.5" in the Downloads menu on the left side of the home page.
* Scroll down to the "Binary Distributions" section and download the version of your
choice. If you do not know, then select the "Core" distribution; it is all you need.
* Save the installation file in a temporary directory.
* Install Tomcat.
--> For Windows, that means double-clicking the install.exe file and following the
installer wizard instructions.
--> For the others, unpack the install file into the place on your hard drive
where you want Tomcat to be.
* To make it easier to follow the book instructions, name the Tomcat home directory
"tomcat".
* Set environment variables for JAVA_HOME and TOMCAT_HOME.
Test Tomcat by launching the tomcat/bin/startup script (which is startup.sh) for
Linux/Unix/OS X. Point your browser to:
http://localhost:8080/ and you’ll see the Tomcat welcome page.
From today I would also like to focus on J2EE concepts.
What all you need to learn:
Besides your brain and a pencil, you also need Java, Tomcat 5, and a
computer.You do not need any Integrated Development Environment like Eclipse, etc. I strongly recommend you, not to use anything but a basic editor until you complete the J2EE tutorial.
GETTING THE SOFTWARE
* If you don’t already Java SE v1.5 or greater, you’ll need it.
* If you don’t already have Tomcat 5, go get it from:http://tomcat.apache.org/
* Select "Tomcat v5.5" in the Downloads menu on the left side of the home page.
* Scroll down to the "Binary Distributions" section and download the version of your
choice. If you do not know, then select the "Core" distribution; it is all you need.
* Save the installation file in a temporary directory.
* Install Tomcat.
--> For Windows, that means double-clicking the install.exe file and following the
installer wizard instructions.
--> For the others, unpack the install file into the place on your hard drive
where you want Tomcat to be.
* To make it easier to follow the book instructions, name the Tomcat home directory
"tomcat".
* Set environment variables for JAVA_HOME and TOMCAT_HOME.
Test Tomcat by launching the tomcat/bin/startup script (which is startup.sh) for
Linux/Unix/OS X. Point your browser to:
http://localhost:8080/ and you’ll see the Tomcat welcome page.
Labels:
J2EE
Tuesday, September 29, 2009
The To String method
The toString() Method Override toString() when we want to read something meaningful about the objects of our class. Code can call toString() on our object when it wants to read useful details about our object.
To be more clear, Now when we pass an object reference to the System.out.println() method, and for example, the object's toString() method is called as follows,
public class ClassA {
public static void main (String [] args) {
ClassA classA = new ClassA();
System.out.println(classA);
}
}
then, Running the ClassA class gives us the following output,
% Java ClassA
ClassA@10b62c9
The above output is what we get when we don't override the toString() method of class Object. It gives us the class name (at least that's meaningful) followed by the @ symbol, followed by the unsigned hexadecimal representation of the object's hashcode.
Trying to read this output might motivate us to override the toString() method in our classes, for example,
public class ClassA {
public static void main (String[] args) {
ClassB classB = new ClassB("Test the toString method", new Date());
System.out.println(classB);
}
}
class ClassB {
Date data1;
String data2;
ClassB(String data2, Date data1) {
this.data1 = data1;
this.data2 = data2;
}
public String toString() {
return ("The main aim of this program is to " + data2 +
". This program was written on " + data1);
}
}
The output of this would be a bit more readable:
% Java ClassA
The main aim of this program is to Test the toString method. This program was written on Tue Sep 29 10:26:59 IST 2009
For your Information, Some people refer the toString() method as the "spill-your-guts method," since the most common implementations of toString() simply tell us the object's state.
To be more clear, Now when we pass an object reference to the System.out.println() method, and for example, the object's toString() method is called as follows,
public class ClassA {
public static void main (String [] args) {
ClassA classA = new ClassA();
System.out.println(classA);
}
}
then, Running the ClassA class gives us the following output,
% Java ClassA
ClassA@10b62c9
The above output is what we get when we don't override the toString() method of class Object. It gives us the class name (at least that's meaningful) followed by the @ symbol, followed by the unsigned hexadecimal representation of the object's hashcode.
Trying to read this output might motivate us to override the toString() method in our classes, for example,
public class ClassA {
public static void main (String[] args) {
ClassB classB = new ClassB("Test the toString method", new Date());
System.out.println(classB);
}
}
class ClassB {
Date data1;
String data2;
ClassB(String data2, Date data1) {
this.data1 = data1;
this.data2 = data2;
}
public String toString() {
return ("The main aim of this program is to " + data2 +
". This program was written on " + data1);
}
}
The output of this would be a bit more readable:
% Java ClassA
The main aim of this program is to Test the toString method. This program was written on Tue Sep 29 10:26:59 IST 2009
For your Information, Some people refer the toString() method as the "spill-your-guts method," since the most common implementations of toString() simply tell us the object's state.
Labels:
Java
Thursday, September 24, 2009
LINKS EXCHANGE
Dear friends,
Check for your links here, If you dont find them here, then I would be really pleased to share links with you.
Currently blog is under updation,
If you miss your link in my friends list kindly shout in my SHOUT BOX. I will add you.
Sorry for the inconvinience.
4 Feb
9 X Hot
Aim – Mba
All about Computers
Applications And Softwares
Assasins
Awake Studio
Beautiful Tourist Places
Comijam
Communicate Better
Computer Technology and Entertainment
Cookie
Cool Tafreeh
Ctexpeditions
Day O Day
Download Gratis34
Dwisusilo
E- Browse
Earn Money From Ads
Edublawg
Ekaputriani
Fashions-Funda
Fast Diet
Fraud Mamy
Game Review 2 U
Games 4x
Gamez Console
Gears Of War 8081
Gratis-Ebooks
Hobby Chaos
Huihuiakatara
Ilalangpagi
Indian Rocks Star
Indo Blogster
Info Abt World
Info By Vicky
Kooool Time
Kung fu Panda81
Liezl Read Write
Ligaya's Corner
Me In The Dutch Society
Medical Cravings
Mimo 9
Mrilham
Music And Movie News
My Fashion Link
My Recollection
My Gossip Girl
Nadahima2
New York Visitor
Nice Events
Nice Thoughts n Thrills
Our Vote Matters08
Pacrim-Entertainment
Pure Blood Rayne
Reeyou36
Rune Upload
Single Mom Thoughts
Shalini Samuel
Socket Shield
Special Food World
Students Exclusive
Suresh My Joyz
Tamil CS
Tamil Thrill
Task Cricket
The Glimpse Of Art
The TECH Repository
Thu Soft Com
Tutorial-Tip-Trik
Twins Column
Vijay Kiran
Virtual Buzz
Web World
Welcome My New Blog
Wild Tusker
When My Mind Try To Speak
Your Local Gallery
Zeethru
Check for your links here, If you dont find them here, then I would be really pleased to share links with you.
Currently blog is under updation,
If you miss your link in my friends list kindly shout in my SHOUT BOX. I will add you.
Sorry for the inconvinience.
4 Feb
9 X Hot
Aim – Mba
All about Computers
Applications And Softwares
Assasins
Awake Studio
Beautiful Tourist Places
Comijam
Communicate Better
Computer Technology and Entertainment
Cookie
Cool Tafreeh
Ctexpeditions
Day O Day
Download Gratis34
Dwisusilo
E- Browse
Earn Money From Ads
Edublawg
Ekaputriani
Fashions-Funda
Fast Diet
Fraud Mamy
Game Review 2 U
Games 4x
Gamez Console
Gears Of War 8081
Gratis-Ebooks
Hobby Chaos
Huihuiakatara
Ilalangpagi
Indian Rocks Star
Indo Blogster
Info Abt World
Info By Vicky
Kooool Time
Kung fu Panda81
Liezl Read Write
Ligaya's Corner
Me In The Dutch Society
Medical Cravings
Mimo 9
Mrilham
Music And Movie News
My Fashion Link
My Recollection
My Gossip Girl
Nadahima2
New York Visitor
Nice Events
Nice Thoughts n Thrills
Our Vote Matters08
Pacrim-Entertainment
Pure Blood Rayne
Reeyou36
Rune Upload
Single Mom Thoughts
Shalini Samuel
Socket Shield
Special Food World
Students Exclusive
Suresh My Joyz
Tamil CS
Tamil Thrill
Task Cricket
The Glimpse Of Art
The TECH Repository
Thu Soft Com
Tutorial-Tip-Trik
Twins Column
Vijay Kiran
Virtual Buzz
Web World
Welcome My New Blog
Wild Tusker
When My Mind Try To Speak
Your Local Gallery
Zeethru
Labels:
LINKS EXCHANGE
Wednesday, September 23, 2009
ABOUT ME
I am a cool and an optimistic person hungry for achievements with a burning desire for knowledge transfer to help others by getting helped. If you prefer to hear from me, please feel free and contact me at s.its.chandru@gmail.com
Labels:
ABOUT ME
BLOG's OBJECTIVE
The main Objective Of the Blog is to share everything that I want to share with my readers.The Blog is a repository Of Facts, Health, and most importantly it focuses on Java. Java is a technology which always has something new to offer, no matter how many websites are launched to share it. So, through this blog, I would like to share my Java Experience and supported aptly by Java Quizzes, this is a Repository Of Knowledge which Helps everyone in need in some way or other.
Labels:
BLOG's OBJECTIVE
Tuesday, September 22, 2009
Java Quiz -17
Hi friends,
Today I would like to post few more questions to test your capability.
Dont worry guys, I will give you the answer too! Try to answer it yourself without referring to the answers to test yourself.
Q: 1 Given a valid DateFormat object named df, and
1. Date data1 = new Date(0L);
2. String data2 = "September 22, 2009";
3. // insert code here
What updates data1's value with the date represented by data2?
A. 3. data1 = df.parse(data2);
B. 3. data1 = df.getDate(data2);
C. 3. try {
4. data1 = df.parse(data2);
5. } catch(ParseException e) { };
D. 3. try {
4. data1 = df.getDate(data2);
5. } catch(ParseException e) { };
Answer: C
Q: 2 Given:
1. public class ClassA {
2. private StringBuilder testStringBuilder = new StringBuuilder();
3. public void logTest(String data1, String data2) {
4. testStringBuilder.append(data1);
5. testStringBuilder.append(data2);
6. }
7. }
The programmer must guarantee that a single ClassA object works properly for a multi-threaded system. How must this code be changed to be thread-safe?
A. Synchronize the logTest method
B. No change is necessary, the current ClassA code is already thread-safe.
C. replace StringBuilder with just a String object and use the string concatenation (+=) within the logTest method
D. replace StringBuilder with StringBuffer
Answer: A
Q: 3 Given:
1 . import java.io.*;
2. public class ClassA implements Serializable {
3. private ClassB tree = new ClassB();
4. public static void main(String [] args) {
5. ClassA classA = new ClassA();
6. try {
7. FileOutputStream fileOutputStream = new FileOutputStream("ClassA.ser");
8. ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
9. objectOutputStream.writeObject(classA);
10.objectOutputStream.close();
11. } catch (Exception ex) { ex.printStackTrace(); }
12. } }
13.
14. class ClassB { }
What is the result?
A. An exception is thrown at runtime.
B. Compilation fails.
C. An instance of ClassA is serialized.
D. An instance of ClassA and an instance of ClassB are both serialized.
Answer: A
Q: 4 Assuming that the serializeClassC() and the deserializeClassC() methods
will correctly use Java serialization and given:
1. import java.io.*;
2. class ClassA {ClassA() { System.out.print("1"); } }
3. class ClassB extends ClassA implements Serializable {
4. ClassB() { System.out.print("2"); } }
5. public class ClassC extends ClassB { int size = 42;
6. public static void main(String [] args) {
7. ClassC b = new ClassC();
8. b.serializeClassC(b); // assume correct serialization
9. b = b.deserializeClassC(b); // assume correct
10. System.out.println(" restored " + b.size + " "); }
11. // more ClassC methods
12. }
What is the result?
A. Compilation fails.
B. 1 restored 42
C. 12 restored 42
D. 121 restored 42
E. 1212 restored 42
F. An exception is thrown at runtime.
Answer: D
Q: 5 Given this method in a class:
1. public String toString() {
2. StringBuffer testStringBuffer = new StringBuffer();
3. testStringBuffer.append('<');
4. testStringBuffer.append(this.name);
5. testStringBuffer.append('>');
6. return testStringBuffer.toString();
7. }
Which statement is true?
A. This code will perform well and converting the code to use StringBuilder will not enhance the performance.
B. This code will perform poorly. For better performance, the code should be rewritten:
return "<" + this.name + ">";
C. The programmer can replace StringBuffer with StringBuilder with no other changes.
D. This code is NOT thread-safe.
Answer: C
Q: 6 Given:
1. double data = 314159.26;
2. NumberFormat nf = NumberFormat.getInstance(Locale.ITALIAN);
3. String b;
4. //insert code here
Which code, inserted at line 4, sets the value of b to 314.159,26?
A. b = nf.parse( data );
B. b = nf.format( data );
C. b = nf.equals( data );
D. b = nf.parseObject( data );
Answer: B
Q: 7 Given:
System.out.format("Pi is approximately %d.", Math.PI);
What is the result?
A. Pi is approximately 3.141593.
B. Pi is approximately 3.
C. Compilation fails.
D. An exception is thrown at runtime.
Answer: D
Q: 8 Given:
1. public class ClassA implements Comparable {
2. private int data1, data2;
3. public ClassA(int data3, int data4) { data1 = data3; data2 = data4; }
4. public int getTestdata1() { return data1; }
5. public int getTestdata2() { return data2; }
6. public String toString() {
7. return "<" + data1 + "," + data2 + ">";
8. }
9. // insert code here
10. }
Which method will complete this class?
A. public int compareTo(Object object1){/*more code here*/}
B. public int compareTo(ClassA classA){/*more code here*/}
C. public int compare(ClassA classA1,ClassA classA2){/*more code here*/}
D. public int compare(Object object1,Object object2){/*more code here*/}
Answer: B
Q: 9 Given:
1. public class ClassA {
2. private String data1;
3. public ClassA(String data1) {
4. this.data1 = data1;
5. }
6. public boolean equals(Object o) {
7. if ( ! o instanceof ClassA ) return false;
8. ClassA p = (ClassA) o;
9. return p.data1.equals(this.data1);
10. }
11. }
Which statement is true?
A. A HashSet could contain multiple ClassA objects with the same data1.
B. Compilation fails because the hashCode method is not overridden.
C. All ClassA objects will have the same hash code because the hashCode method is not overridden.
Answer: A
Q: 10 Given:
13. public static void search(List listObject) {
14. listObject.clear();
15. listObject.add("data2");
16. listObject.add("data1");
17. listObject.add("data3");
18. System.out.println(Collections.binarySearch(listObject, "data1"));
19. }
What is the result of calling search with a valid List implementation?
A. 0
B. 1
C. 2
D. data1
E. data2
F. data3
G. The result cannot be defined.
Answer: G
Hope you found this useful! Kindly give me your comments regarding the same.Many more Quizzes are to be posted! Kindly make use of them as much as possible!
Today I would like to post few more questions to test your capability.
Dont worry guys, I will give you the answer too! Try to answer it yourself without referring to the answers to test yourself.
Q: 1 Given a valid DateFormat object named df, and
1. Date data1 = new Date(0L);
2. String data2 = "September 22, 2009";
3. // insert code here
What updates data1's value with the date represented by data2?
A. 3. data1 = df.parse(data2);
B. 3. data1 = df.getDate(data2);
C. 3. try {
4. data1 = df.parse(data2);
5. } catch(ParseException e) { };
D. 3. try {
4. data1 = df.getDate(data2);
5. } catch(ParseException e) { };
Answer: C
Q: 2 Given:
1. public class ClassA {
2. private StringBuilder testStringBuilder = new StringBuuilder();
3. public void logTest(String data1, String data2) {
4. testStringBuilder.append(data1);
5. testStringBuilder.append(data2);
6. }
7. }
The programmer must guarantee that a single ClassA object works properly for a multi-threaded system. How must this code be changed to be thread-safe?
A. Synchronize the logTest method
B. No change is necessary, the current ClassA code is already thread-safe.
C. replace StringBuilder with just a String object and use the string concatenation (+=) within the logTest method
D. replace StringBuilder with StringBuffer
Answer: A
Q: 3 Given:
1 . import java.io.*;
2. public class ClassA implements Serializable {
3. private ClassB tree = new ClassB();
4. public static void main(String [] args) {
5. ClassA classA = new ClassA();
6. try {
7. FileOutputStream fileOutputStream = new FileOutputStream("ClassA.ser");
8. ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
9. objectOutputStream.writeObject(classA);
10.objectOutputStream.close();
11. } catch (Exception ex) { ex.printStackTrace(); }
12. } }
13.
14. class ClassB { }
What is the result?
A. An exception is thrown at runtime.
B. Compilation fails.
C. An instance of ClassA is serialized.
D. An instance of ClassA and an instance of ClassB are both serialized.
Answer: A
Q: 4 Assuming that the serializeClassC() and the deserializeClassC() methods
will correctly use Java serialization and given:
1. import java.io.*;
2. class ClassA {ClassA() { System.out.print("1"); } }
3. class ClassB extends ClassA implements Serializable {
4. ClassB() { System.out.print("2"); } }
5. public class ClassC extends ClassB { int size = 42;
6. public static void main(String [] args) {
7. ClassC b = new ClassC();
8. b.serializeClassC(b); // assume correct serialization
9. b = b.deserializeClassC(b); // assume correct
10. System.out.println(" restored " + b.size + " "); }
11. // more ClassC methods
12. }
What is the result?
A. Compilation fails.
B. 1 restored 42
C. 12 restored 42
D. 121 restored 42
E. 1212 restored 42
F. An exception is thrown at runtime.
Answer: D
Q: 5 Given this method in a class:
1. public String toString() {
2. StringBuffer testStringBuffer = new StringBuffer();
3. testStringBuffer.append('<');
4. testStringBuffer.append(this.name);
5. testStringBuffer.append('>');
6. return testStringBuffer.toString();
7. }
Which statement is true?
A. This code will perform well and converting the code to use StringBuilder will not enhance the performance.
B. This code will perform poorly. For better performance, the code should be rewritten:
return "<" + this.name + ">";
C. The programmer can replace StringBuffer with StringBuilder with no other changes.
D. This code is NOT thread-safe.
Answer: C
Q: 6 Given:
1. double data = 314159.26;
2. NumberFormat nf = NumberFormat.getInstance(Locale.ITALIAN);
3. String b;
4. //insert code here
Which code, inserted at line 4, sets the value of b to 314.159,26?
A. b = nf.parse( data );
B. b = nf.format( data );
C. b = nf.equals( data );
D. b = nf.parseObject( data );
Answer: B
Q: 7 Given:
System.out.format("Pi is approximately %d.", Math.PI);
What is the result?
A. Pi is approximately 3.141593.
B. Pi is approximately 3.
C. Compilation fails.
D. An exception is thrown at runtime.
Answer: D
Q: 8 Given:
1. public class ClassA implements Comparable
2. private int data1, data2;
3. public ClassA(int data3, int data4) { data1 = data3; data2 = data4; }
4. public int getTestdata1() { return data1; }
5. public int getTestdata2() { return data2; }
6. public String toString() {
7. return "<" + data1 + "," + data2 + ">";
8. }
9. // insert code here
10. }
Which method will complete this class?
A. public int compareTo(Object object1){/*more code here*/}
B. public int compareTo(ClassA classA){/*more code here*/}
C. public int compare(ClassA classA1,ClassA classA2){/*more code here*/}
D. public int compare(Object object1,Object object2){/*more code here*/}
Answer: B
Q: 9 Given:
1. public class ClassA {
2. private String data1;
3. public ClassA(String data1) {
4. this.data1 = data1;
5. }
6. public boolean equals(Object o) {
7. if ( ! o instanceof ClassA ) return false;
8. ClassA p = (ClassA) o;
9. return p.data1.equals(this.data1);
10. }
11. }
Which statement is true?
A. A HashSet could contain multiple ClassA objects with the same data1.
B. Compilation fails because the hashCode method is not overridden.
C. All ClassA objects will have the same hash code because the hashCode method is not overridden.
Answer: A
Q: 10 Given:
13. public static void search(List
14. listObject.clear();
15. listObject.add("data2");
16. listObject.add("data1");
17. listObject.add("data3");
18. System.out.println(Collections.binarySearch(listObject, "data1"));
19. }
What is the result of calling search with a valid List implementation?
A. 0
B. 1
C. 2
D. data1
E. data2
F. data3
G. The result cannot be defined.
Answer: G
Hope you found this useful! Kindly give me your comments regarding the same.Many more Quizzes are to be posted! Kindly make use of them as much as possible!
Labels:
Java Quiz
Subscribe to:
Posts (Atom)









