This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes confusion with all front end technologies - what's in and what's out Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "confusion with all front end technologies - what Watch "confusion with all front end technologies - what New topic
Author

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

Billy Vandory
Ranch Hand

Joined: Mar 23, 2010
Posts: 57
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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.


[My Blog]
All roads lead to JavaRanch
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

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.)


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Billy Vandory
Ranch Hand

Joined: Mar 23, 2010
Posts: 57
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

Joined: Jan 10, 2002
Posts: 60785
    
  65

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

Joined: Jan 10, 2002
Posts: 60785
    
  65

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

Joined: Mar 23, 2010
Posts: 57
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

Joined: Jan 10, 2002
Posts: 60785
    
  65

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

Joined: Jan 10, 2010
Posts: 41
JSP Standard Tag Library. It is standardized custom tags

JSTL is mainly used for presentation layer.
Manish Singh
Ranch Hand

Joined: Jan 26, 2007
Posts: 160
The subject is somewhat misleading. I thought it has something to do with technologies like GWT , flex etc
 
Consider Paul's rocket mass heater.
 
subject: confusion with all front end technologies - what's in and what's out
 
Similar Threads
Present Database Field LIst
Passing AJAX url value to JSP
dynamic generation of Text Field both in i.e and netscape by clicking submit button
struts Action for asynchronous HTTP processing
Complex Page Layout