I'm trying to develop a very simple Java web application using JSP and Servlets.
1) There is a textbox and a submit button on the page,
2) The user enters his name, say John, to the textbox and clicks the button,
3) The string is forwarded to my servlet,
4) At the doPost method of my servlet, I access the posted string variable,
5) The web service I'll use has a sayHello
method that takes an argument and returns "Hello "
concatenated with the argument,
6) So, I call the sayHello
method of the web-service, get the returned variable and forward this to a JSP, which basically writes Hello John
.
I have 2 questions:
1) Flooding: How do I avoid flooding of requests to my servlet? How do I deal with it? I thought of creating a thread to contact the web service and say hello. When a request arrives, I check if the thread is running/busy, if not, I process the request. Therefore, I would be answering at most 1 request per unit time. How does that sound?
2) Scalability: Assume that tonight, 1,000,000 million people will reach my web app and make my app say hello ten times each. How do I make sure that this app will scale well? Anything I can do about the JSP/Servlet part, other than the hardware the server is dependent on?
I know that the questions are kind of generic so I tried to provide as much detail as I can. I would really appreciate a thorough and to-the-point answer =)
Thanks in advance.