Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

confusion with all front end technologies - what's in and what's out

 
Billy Vandory
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been studying for my SCJWD and I'm sort of lost of what's in and what's out.

Is JSTL in or out? And is it common practice to have JSTL generate HTML?

(I'm reading Head First Servlets and JSP and it shows code for a JSTL that generates HTML.
Just seems odd to me, to have a Java class generate HTML code - isn't that coupling presentation with code?)

Billy

 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a JSP file, a lot of tags will generate html. Imagine a tag generating a table, by passing it a list of values.

isn't that coupling presentation with code?

No. The logic is in the tag handler, or in a Tag File. This is not visible from the JSP.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64712
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Billy Vandory wrote:Is JSTL in or out?

Very, very in.

And is it common practice to have JSTL generate HTML?

The whole purpose of a JSP is to generate HTML.

(I'm reading Head First Servlets and JSP and it shows code for a JSTL that generates HTML.
Just seems odd to me, to have a Java class generate HTML code - isn't that coupling presentation with code?)

The fact that the tags are written in Java is moot. From the point of view of the JSP they are a black box whose implementation is irrelevant.

shows code for a JSTL

Huh? What do you mean by "shows code for a JSTL"? That doesn't make much sense. Are you (very incorrectly) using the term JSTL to mean custom tags? (JSTL is a specific standardized library of custom tags.)
 
Billy Vandory
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:
Billy Vandory wrote:Is JSTL in or out?

Very, very in.

And is it common practice to have JSTL generate HTML?

The whole purpose of a JSP is to generate HTML.

(I'm reading Head First Servlets and JSP and it shows code for a JSTL that generates HTML.
Just seems odd to me, to have a Java class generate HTML code - isn't that coupling presentation with code?)

The fact that the tags are written in Java is moot. From the point of view of the JSP they are a black box whose implementation is irrelevant.

shows code for a JSTL

Huh? What do you mean by "shows code for a JSTL"? That doesn't make much sense. Are you (very incorrectly) using the term JSTL to mean custom tags? (JSTL is a specific standardized library of custom tags.)


Thanks both Bear and Christopher. I must confess, this stuff is hard to get my head around.

What I meant by 'shows code for JSTL', I guess I should have said 'shows code for a custom Tag Handler'. Thanks for the correction !


So as far as a design approach to a login screen, would creating a Custom Tag Handler to generate the Login Dialog Box with the appropriate fields, and using that custom tag within a JSP be an appropriate design?

Billy

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64712
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right, JSTL == JSP Standard Tag Library. It's the standardized set of custom tags, such as <c:out> and <fmt:message>.

I hate building up HTML in Java code, but for custom tags that aren't appropriate to be implemented as tag files, it's rather a necessary evil. That is the only place you'll ever see me build HTML in Java code.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64712
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Billy Vandory wrote:So as far as a design approach to a login screen, would creating a Custom Tag Handler to generate the Login Dialog Box with the appropriate fields, and using that custom tag within a JSP be an appropriate design?

Why implement it as a tag at all? Is it something that will be re-used on many pages?

If it turns out that it is appropriate to implement as a tag, and if there's HTML involved, I'll first try to implement it as a tag file. Or even a hybrid of a tag file with a backing bean to help it out if need be. As I said above, I only resort to building HTML in Java code when it's absolutely necessary.

But first, figure out if a tag is called for in the first place.
 
Billy Vandory
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:
Billy Vandory wrote:So as far as a design approach to a login screen, would creating a Custom Tag Handler to generate the Login Dialog Box with the appropriate fields, and using that custom tag within a JSP be an appropriate design?

Why implement it as a tag at all? Is it something that will be re-used on many pages?

If it turns out that it is appropriate to implement as a tag, and if there's HTML involved, I'll first try to implement it as a tag file. Or even a hybrid of a tag file with a backing bean to help it out if need be. As I said above, I only resort to building HTML in Java code when it's absolutely necessary.

But first, figure out if a tag is called for in the first place.


Well the web site I'm building (as I'm learning) I envision to have login/password field in the top right corner in many pages. For example, Youtube lets you navigate their site without logging in, and provides a login form on every page.

Just wondering the best approach to do that. I'll re-read the section on tag files.

Thanks so much for your wisdom.

Billy

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64712
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Billy Vandory wrote:Well the web site I'm building (as I'm learning) I envision to have login/password field in the top right corner in many pages.

In that case, this is a great candidate for a tag. I'd approach it as a tag file unless you hit the wall.
 
Alpesh Padra
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP Standard Tag Library. It is standardized custom tags

JSTL is mainly used for presentation layer.
 
Manish Singh
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The subject is somewhat misleading. I thought it has something to do with technologies like GWT , flex etc
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic