wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes TCP socket connection and Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "TCP socket connection and Servlet" Watch "TCP socket connection and Servlet" New topic
Author

TCP socket connection and Servlet

A. Aka
Ranch Hand

Joined: Sep 08, 2012
Posts: 47
Hi,

I do not understand this mock response :

You are building a servlet that requires high speed numerical computations of weather data before generating a PNG image of the data. There is a dedicated server that performs these computations and your servlet needs to send these requests over a TCP socket connection to this server. Your servlet needs to
manage that socket connection which must be set up once for the duration of life of the servlet. Furthermore, the server's IP address and TCP port information is stored in the web.xml file in the servlet initialization parameters

Which two parts of the servlet life cycle should you use to create the code to handle this scenario? (Choose two.)

1/servlet is destroyed
2/servlet is finalized
3/servlet is initialized
4/servlet class is loaded
5/servlet is instantiated
6/servlet responds to HTTP requests

they said the answers are 1/ and 3/, why ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42283
    
  64
Let's start by you trying to provide an answer (even if it different from the given one).


Ping & DNS - my free Android networking tools app
A. Aka
Ranch Hand

Joined: Sep 08, 2012
Posts: 47
suppose they did not ask for 2 answers,

I would put all the servlet lifecycle listed( 4/servlet class is loaded , 5/servlet is instantiated , 3/servlet is initialized , 1/servlet is destroyed) and why not 6/servlet responds to HTTP requests as it is the purpose of servlet

regards,
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42283
    
  64
As I understand it, the question is just about managing the socket connection to the server, not about handling requests (and thereby actually using the connection).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: TCP socket connection and Servlet