I have read in a few places now not to use jsp script in jsp pages. I can see why but every book I go through to learn how to do web programming always has a jsp section with scriplets. It puts me off completely even looking at it to be perfectly honest, it's horrible! JSTL seems to be the work around and far better. I am learning to use servlets now to process html forms and send the data to an output page. I use java classes as my 'backend', a servlet as a 'middle man' and JSTL to show the data on the output page. I'm just curious is this the correct way to go about it or do developers still use scriplets? I am trying to get into my head how its done in the real world. It will help me learn and understand web programming better.
In a nutshell, if you were to write an overview paragraph in a web programming book (for beginners) with the title 'How its done in the real world', what would you say?
In the real world, you'll need to understand scriptlets to support legacy code, and unfortunately, there are still companies writing scriptlet code today (like mine). I'm the heretic here because I refuse to write scriptlets.
I've already decided that the next time I'm offered a job, I'll insist on looking at their code-base. If I see a mountain of scriptlets, I will decline the job unless it involves a project to re-design and refactor all that crap code.
You are on the right track with the MVC architecture. That's the way it should be done.
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
Bear Bibeault wrote:
And I don't buy the "quick development" baloney. It's just as quick to do things correctly as to do them sloppily.
I'm certainly not defending them, but the pro-scriptlet folks at HQ reason that it's easier to upload a single jsp file, with maybe a css and js file, than to deploy servlets, POJOs, modify web.xml, etc.
What they don't seem to understand is that the time you save on initial development is going to be eaten up by maintenance, and then some. By using scriptlets, they end up with code that is untestable, can't be extended, abstracted, or re-used, and is a nightmare to modify when enhancements are requested. And I won't even address the security issue of having SQL embedded in the jsp.
There has been at least one case where I was asked to modify an existing app and it was such a mess of scriptlets that it was easier for me to completely re-write the thing using MVC rather than try to modify the existing code. By doing so, I now have an app than can be easily modified in the future.
It's like the old saying...."never enough time to do it right, but always time to do it over".