This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes HTML, CSS and JavaScript and the fly likes JSTL or JQuery plug-ins? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "JSTL or JQuery plug-ins?" Watch "JSTL or JQuery plug-ins?" New topic
Author

JSTL or JQuery plug-ins?

Bryce Martin
Ranch Hand

Joined: Nov 19, 2007
Posts: 269
I recently ran across jqGrid and it looks super slick. Would you suggest this over JSTL <c:forEach>? The difference would be a servlet returning a list of Beans or a servlet returning JSON. Any ideas on which would be faster? Easier? I currently have both working. Just wondering what you though?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61043
    
  66

Without having made any direct comparisons, I really can't comment. Seems like a "6 of one" scenario at first guess.

And there's really no JSTL or jQuery debate. I use both. JSTL is still ultra-useful on the server for formatting whatever's going to be retuned to the client, be it a full page or just an HTML fragment requested via Ajax.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bryce Martin
Ranch Hand

Joined: Nov 19, 2007
Posts: 269
Well there's my claim to fame JSTL vs jQuery

haha

if only I can form some hypothesis now. Let the debate begin!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61043
    
  66

That's like debating peanut butter or jelly. Both please!
Bryce Martin
Ranch Hand

Joined: Nov 19, 2007
Posts: 269
Yeah, they really are suited for best for different uses. It would be nice though to look at the areas they overlap and see which is better.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61043
    
  66

There really isn't any overlap. JSTL is used in conjunction with JSP to generate the body of the response sent to the client. jQuery operates on the client to make JavaScript easier to write and manage.

What you may be thinking about really has nothing to do with either technology and that's "do I do everything on the server and fully refresh every page for every action, or do I write a rich Internet application that leverages client-side capabilities".

Such as decision is at a much higher level than what specific technologies one decides to use for server-side templating and client-side DOM manipulation.
Bryce Martin
Ranch Hand

Joined: Nov 19, 2007
Posts: 269
I was thinking that I can load a table of data with jQuery, via jqGrid, or I can use JSTL, via <c:forEach>. But the only real difference is whether you pass back a JSON string to jqGrid or a Bean(or in my case a list of beans) in the case of JSTL. What I've done is I actually create the list of beans server side, and instead of setting the Bean(or list) to the session I use StringTree JSON and send that back to the javascript instead.

6 of one half dozen of the other?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61043
    
  66

Exactly.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

DisplayTag is a custom JSP tag library that can do basically what jqGrid does but without AJAX. DisplayTag would do full page refreshing for paging and sorting the data.


GenRocket - Experts at Building Test Data
Bryce Martin
Ranch Hand

Joined: Nov 19, 2007
Posts: 269
but if it doesn't do AJAX like jqGrid then that kind of limits its usefulness. Its amazing how much I hate full page refreshes now that I've got ajax working. Unless there is some very large significant change to a page then there really isn't a reason to do a full page refresh. In almost all cases AJAX will be quicker, cleaner, and an all around better solution.

Don't mind me too much...I didn't have my morning coffee today....sorry if I grumble a bit...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61043
    
  66

Originally posted by Bryce Martin:
but if it doesn't do AJAX like jqGrid then that kind of limits its usefulness

What is "it"? JSTL? Even using Ajax, what do you think is the best server-side tool to format the response? JSTL. It doesn't matter if the response is a full page refresh or an HTML fragment that's going to be stuffed into an existing DOM.

So I assert once again that it's never Ajax or JSTL, but AJax and JSTL.

Of course, I may have completely missed your point. I'm pre-caffeine as well.
Bryce Martin
Ranch Hand

Joined: Nov 19, 2007
Posts: 269
I was searching around the forums and I ran across this post that I started a few months ago. After working with jqGrid and JSTL a few months more I would like to share what I've found.

Bear, you are right. Its not a matter of JSTL or AJAX, but JSTL and AJAX. I have found that for data that is page specific and won't change while the user is on the page it is best to use JSTL in conjunction with beans to display data from the server. If there is data that needs to change on the page then its probably (in most cases) going to be best to use AJAX to avoid a page refresh.

Thats my story and I'm sticking to it
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by Bryce Martin:
I was searching around the forums and I ran across this post that I started a few months ago. After working with jqGrid and JSTL a few months more I would like to share what I've found.

Bear, you are right. Its not a matter of JSTL or AJAX, but JSTL and AJAX. I have found that for data that is page specific and won't change while the user is on the page it is best to use JSTL in conjunction with beans to display data from the server. If there is data that needs to change on the page then its probably (in most cases) going to be best to use AJAX to avoid a page refresh.

Thats my story and I'm sticking to it


For the sake of argument I'd only recommend that just because you use jqGrid it doesn't mean you *have* to use all its features (sorting, paging, etc, via Ajax). If it were me (and it has been on past projects) I go for consistency. It's much better, in my opinion, to use the same patters and the same type of code across the board than to mix and match with the caveat that you aren't creating more work on yourself in the process.

It's pretty easy to tell jqGrid to just display some static data that won't change and you get not only the server side consistency but the client side with regards to your javascript and your css.
Bryce Martin
Ranch Hand

Joined: Nov 19, 2007
Posts: 269
But you don't always want to display the information in a grid. For instance... my user does a search by PO and Cust#. Well when I go to the results page I want to show them their search criteria as well as a few details associated with the given customer they looked up. So I don't need a grid to show the customer name and other details. In fact that would be a little over kill. So I just have a bean I fill on the server and in the JSP I have some divs that reference those variables for display as a header.

Below this header is my grid with its search results. No reason for two grids. It is quicker to do it with one grid and some JSTL as opposed the user seeing two grids loading...

I hope I'm expressing myself clearly...if it wasn't an internal app I'd show you pictures...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSTL or JQuery plug-ins?