File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes directives also kind of  scriptlet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "directives also kind of  scriptlet?" Watch "directives also kind of  scriptlet?" New topic

directives also kind of scriptlet?

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Hi All,

in jsp , scriptlets are discourage. well but i have one doubt that the directives(<%@ %>) also looks like scriptlet

please anyone explain me
Maurizio Nagni
Ranch Hand

Joined: May 29, 2004
Posts: 75
The answer is definitely: no, scriptlet and directive are two well distinguished items.
In a MVC vision, the scriptlet code directly interferes with the business logic of the page (it can generate new methods inside the servlet generated from the page) and that's why is is discouraged, because parameters manipulation should be controlled ONLY from your classes NOT from your page; in the page you can choose what to show and what not BUT you should not be able to change the data (oh well at least you can POST new data but this does not mean it will be changed if your business logic forbidden that operation).

On the other hand the directives handles "just" the view-side of the page (page, include, taglib): they do not manipulate your page parameters.

If you now look at the EL expressions you will see that you can compare or show some parameters but still you cannot change their inner value. Anyway if you want to have a pure MVC schema you know, I guess, that you can use the isELenabled disable also the EL and (surprise, surprise!) both script and EL can be be set per page

or per servlet (in web.xml)

but still no way to disable the directive because, again, they do not interfere with the business logic.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Thanks a lot Maurizio Nagni
I agree. Here's the link:
subject: directives also kind of scriptlet?
It's not a secret anymore!