This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Dear all, I have the following doubts: First: I was thinking about the following architecture for a web based application - having a single servlet which would receive all requests. The rest of the modules of the application can be classes. The servlet would do * the authentication, * log the result of the same (who logged in, when and if the attempt is unsuccessful - log the same) * the connection pool object would be in the servlet context its getConnection() method would return a connection to the database. This method would be passed to the method of the class instantiated * check if the user has rights to access the module asked for (say - prepare a sales order) * if the user has the rights, then it would insantiate the sales order class and call the appropriate method of the class depending on the type of the request (prepare a new sales order, modify an existing sales order, query an order etc...) in short the servlet would have a huge switch case which would take care of the business logic. These would return the html to the servlet and the servlet calls some template files , does patern matching and outputs the html content to the browser in one out.println() statement do you think that such big a servlet would cause performance issues - one because all requests to the servlet would be handled by this one servlet and another it would instantiate the business class required and process it. Second: My main question is - will the classes be reused once they are instantiated in RAM (on the next hit) OR are we completely at the mercy of the garbage collector (ie if he leaves the class object in RAM then and then only would it be reused, else the next request for the same class would need the instantiation again)? Third: Because servlets are internally threaded, would the object instantiated by one thread be available to another thread? if yes, then do i need to take care about the mutation of public variables in the class. in the servlets case, i feel that i may get some benefits.. but that again is a feeling - no arguments in support I WOULD APPRECIATE A DETAILED RESPONSE FROM THE SHERRIFS AND ANYONE WHO IS DWINDLING WITH WEB TECHNOLOGIES AND HAVE ENOUGH EXPERIENCE...I would like to know where would this approach go haywire.