I am new in Servlet, I used the following code to read some inputStream,
class MyServlet implements Servlet{
void service(ServletRequest req, ServletResponse res){
InputStream inA, inB, inC;
//...
inA.read(); // May block
inB.read(); // May block
inC.read(); // May block
// ...
}
}
How to let the servlet container (Tomcat) interrupts/destroys MyServlet after some configurable time. And in this case which method(s) will it call?
thanks in advance,,,
You don’t call those methods, the container does.
I’d wonder why you would do this. Do you really want to re-read those files with every request? If you need the contents, I’d prefer to see you read them in the init method and cache them.