Why are JSP tags considered as being less logic than scriplets

G

Guest

Most of you have probably heard/read that it's better to use JSP tags
instead of scriptlets for the reason that you should not "mix
presentation and logic" (for example that's what the JSP chapter of
the Java Web Services Tutorial claims) but can someone explain why
"the logic" is considered to be less mixed just because you change the
logic from normal java syntax to xml syntax?

For example have a look at this page with scriptlets:
http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSPIntro2.html
And this similar page written with JSP standard tags:
http://java.sun.com/webservices/docs/1.3/tutorial/examples/web/date/web/index.txt

Does anyone really think that the XML syntax (jsp tags) is easier to
read or that you are using less logic just because the syntax for the
logic is XML instead of java ?
 
A

Anton Spaans

The separation between presentation and business-logic is an old and still
very current idea that promotes the maintainability of (large) software
projects. A change in your business logic has a lesser chance to require a
change in your presentation logic and vice versa.

Also, coding JSP tags doesn't have a steep learning curve as Java coding
does. Its easier to teach people to code JSP tags (or even let graphical
design tools generate them instead) than to teach (generate) Java code. All
the hard-core business logic is then coded into the implementation of the
JSP tags (proprietary business logic can be coded into JSP
taglib-extensions).
It also shields the gui coder (JSP tag coders) from business logic code..
they don't need to deal with it.

These are just a couple of reasons.
-- Anton.
 
S

Sudsy

Does anyone really think that the XML syntax (jsp tags) is easier to
read or that you are using less logic just because the syntax for the
logic is XML instead of java ?

The idea was to separate java code from HTML. Tags look just like any
other HTML tag. They might have different attributes but they're still
just tags. Scriptlets introduce java source code into the HTML page.
This is considered to be a "bad thing". Theoretically, you could work
in a large enough shop where the HTML people are graphic artists who
know nothing about java. Do you really want to run the risk of them
"accidentally" altering your carefully crafted code? With tags they
shouldn't have access to the source, only the functionality provided.
Besides which, IMHO scriptlets just plain look messy! YMMV
 
B

brougham5

can someone explain why
"the logic" is considered to be less mixed just because you change the
logic from normal java syntax to xml syntax?

It's not.

Doesn't matter what kind of tags you use, if they're doing anything other
than presentation logic, they don't belong in a JSP.
 
A

Ajay Patil

It is a very popular and trendy opinion that
"Scriptlets just look plain messy !"

I agree tags look better and are also easier to auto-generate
tags than Java code.

At the same time, how many applications are really there in which the
JSPs are not coded by Java programmers ?

Is Java coding really more difficult to learn than the tag libraries ?
In fact it is quite hard to wire/bind the tags with the back-end model
beans and debugging is hard with zilch error messages.

If the HTML people are graphic artists who nothing of Java, then tag libraries
are certainly the way to go. But if this is not the case, we must
certainly reconsider "Scriplets just look plain messy" and also give
a thought of the additional complexity we are creating.

** Just letting off some steam after being frusturated with these new
taglib frameworks **
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top