Answer the question
In order to leave comments, you need to log in
Lifecycle of servlets in Tomcat?
I would like to ask if I understand a number of things correctly, and ask a couple of questions:
1. Tomcat has a set of threads that it manages and in which it launches servlets.
At the same time, two or more instances of the same (class) servlet can be executed in parallel.
Answer the question
In order to leave comments, you need to log in
https://jsfiddle.net/wuopahjd/
1) Use let instead of var . This does not affect functionality. This is the standard.
2) Why are you passing the string argument to the function? I removed 3 in my example
) Everything is correct for you, only you do not return anything from the function and do not display the result inside it. return - displays the result of the function, returns values that can already be displayed in the console.
https://developer.mozilla.org/en/docs/Web/JavaScript...
Socket socket = new Socket("localhost", 8005);
if (socket.isConnected()) {
PrintWriter pw = new PrintWriter(socket.getOutputStream(), true);
pw.println("someLongAndSecretString");
pw.close();
socket.close();
}
A servlet life cycle can be defined as the entire process from its creation till the destruction. The following are the paths followed by a servlet.
The servlet is initialized by calling the init() method.
The servlet calls service() method to process a client's request.
The servlet is terminated by calling the destroy() method.
Finally, servlet is garbage collected by the garbage collector of the JVM.
for servlet tutorial
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question