Folks i keep on hearing that we should use Expression language in JSP instead of scriplets. But nobody gives any concrete reason behind it. Is readability the only reason behind it? I would like to hear some good reasons for using EL not scriplets so that i can convince my self and others also.I personally feel using scriplets easier than scriplets probably i have better control on java than EL.
Asked
Active
Viewed 550 times
3
-
http://www.theserverside.com/feature/Top-5-reasons-that-JSP-scriptlets-suck – Brian Agnew Nov 21 '12 at 12:14
-
1@BrianAgnew The article again tells only about how ugly scriptlets look in comparison to EL and how everybody is using it. It does not give anything else which is already described in the question though in a nice marketable way. May be complex code can be avoided which is not possible with ELs, but still I am beginning to think that `readability` is really a very important aspect when it comes to writing JSP and I think it is enough of a reason to choose EL over scriptlets. – Prakash K Nov 21 '12 at 12:20
-
1Possible duplicate of [How to avoid Java Code in JSP-Files?](http://stackoverflow.com/questions/3177733/how-to-avoid-java-code-in-jsp-files) It contains a link to the official Sun/Oracle document about JSP coding recommendations. "Better control" makes no sense. Starters who know nothing about scalability/reusability usually prefer to have *all* the code in a single place/file. But this is thus definitely not reuseable/scalable which may lead to serious maintainability trouble in "real world" (in other words, waste of $$$). – BalusC Nov 21 '12 at 12:23
1 Answers
2
You want to avoid scriptlets with complex logic (such as conditionals or loops), because that just leads to spaghetti code.
Expression language does not have any of this (it just evaluates expressions).

Thilo
- 257,207
- 101
- 511
- 656