>Can a JSP be used as controllor in MVC architecture Yes it can be. With a JSP you can do anything a servlet can do.
However what would be the point? A controllers purpose in life is to look at the request, and then dispatch it to the appropriate handler. A JSPs purpose in life is to produce an html page for display.
While you CAN use a JSP for a simple controller, I don't see anything about JSPs that recommend it for the job. If you are writing scriptlet code - why isn't it in a servlet? I suppose the <jsp:forward>, <jsp:include> tags combined with the some conditional logic could provide a controller, but only really for the simplest of controllers.
Bottom line: yes you can use a JSP for a controller, but there are more appropriate alternatives. Use the right tool for the right job.
Please remember that everything in the JSP API is designed to serve character streams. If your application ever needs to serve binary data such as PDFs, images, sound files, etc. having a JSP as the initial request handler will cause you endless trouble. Just "bite the bullet" and learn how to use servlets - it really is quite easy. Bill
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop