• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

TCP socket connection and Servlet

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's start by you trying to provide an answer (even if it different from the given one).
 
A. Aka
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Lasagna is spaghetti flvored cake. Just like this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic