Why use JSP? All that we can do with scriptlets we can do with JavaScript as well, I think. Can somebody explain?

ryan wexler

Yes Javascript is a very powerful tool, but you must realize that it has its place in the web development hierchy. That place being the client side. It is executed within the client browser and is so then limited to client side applications. You could say javascript is a tool for the presentation layer of the web
on the other hand....
While JSP/Servlets interact with the client their power is in that they are run on the server side. Allowing for more intense manipulations to be run, server side code is executed, database calls can be made, etc. Basically providing linkage from a server to a client and vice versa. A client can not access resources on your server, but a server can take request for resources and propagate them back to the client. How does a shopping cart remember what items you have in your cart? This leads to two of the most important words of web design: Session Management. This can not be done without a server side to your webpage, JSP can of course be a tool for server side developlment.
The beautiful thing about it all is you can mix Javascript with JSP. Focusing the use of JSP for server side code and linkage with the client, but at the same time you can use javascript to enhance your presentation layer.