• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

This weeks giveaway

 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This weeks Giveaway is : "Professional JSP Tag Libraries".
And the best part our own Simon Brown will be on-line to answer your questions

Thanks to the good people at Wrox for the books!
 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a great giveaway, I think Tag Libraries are becoming very important. Does the book go into specific libraries such as STRUTS and JSTL?
 
Zac Roberts
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry I did not read the summary before I posted previously. It seems that the books focus is on creating Tab Libraries from scratch. Do you think that it is better to take the time to create your own custom tags then use 3rd party solutions? Maybe it just depends on the type and scope of the project.
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Simon,
Nice to meet you here again. Your advices about MVC Model2 helped me a lot, but I hesitated to use Struts and Taglib in my project because of performance concern. Could you please tell from your experience how much Taglib or Struts might impact the performance? Thanks.
Ren
 
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everybody!
Thanks for all your kind words so far and I look forward to "meeting" you all over the next few days. For those of you that don't know, I'm based in the UK so apologies if I seem slow at replying - I'm probably sleeping.
Simon
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Simon,
I hope I win one of your books. Welcome to the Ranch.
Janet
 
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Simon,
can you tell a little bit about the examples in your book? Found the information at amazon a little scarce.
How does it relate to the Manning book about tag-libraries. Does it have a similar focus?
Just want to mention that I really like your writing style. I have assembled some training stuff for servlet/jsp. The web-app design discussion was easy to write using your chapter of servlets 2.3 as solid foundation.
Axel
 
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Simon ! Welcome to the Ranch!Looking forward for a great discussion!
 
Simon Brown
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Axel Janssen:
can you tell a little bit about the examples in your book? Found the information at amazon a little scarce.
How does it relate to the Manning book about tag-libraries. Does it have a similar focus?
Just want to mention that I really like your writing style. I have assembled some training stuff for servlet/jsp. The web-app design discussion was easy to write using your chapter of servlets 2.3 as solid foundation.


Thanks Axel!
I'll also admit that the information over at Amazon is a little sparse. For more information about the book and how it differs from other tags books, check out this thread.
Thanks
Simon
 
Simon Brown
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ren Li:
Hi Simon,
Nice to meet you here again. Your advices about MVC Model2 helped me a lot, but I hesitated to use Struts and Taglib in my project because of performance concern. Could you please tell from your experience how much Taglib or Struts might impact the performance? Thanks.
Ren


Hi Ren,
As far as performance goes, you are going to take a slight hit when using custom tags. This is because the JSP page (when requested) has to instantiate the tag handler classes and execute the methods associated with the tag lifecycle. Some newer containers provide optimizations that are optional parts of the JSP specification. For example, they can choose to reuse tag handler instances on the same page, and additionally pool them to reduce the overheads associated with object creation. Of course, if you wrap up the same logic inside a JavaBean, you will encounter the same performance hit anyway, and possibly even worse than containers that provide those optional tag handler optimizations. In my experience, it isn't generally significant, although if you do have 100+ tags on the page then you may start running into difficulties.
As for Struts, well this is an entire framework for building MVC-style web applications. Therefore, while I've addressed the performance of custom tags which will also apply to the Struts taglibs, the core framework is different. Once again, you'll probably encounter a slight performance hit by taking up such a framework (whether it is Struts or not), simply because the way in which requests are serviced is different from a model 1 architecture. In summary, there are more components involved in the request dispatch cycle. The best thing to do with any candidate framework is to run some benchmarks over a simple application to give you a flavour of the sort of performance you are looking at.
I hope that answers the questions about performance and although there will be a small hit, the benefits that you get in terms in structure, maintainability, reusablity and time-to-market from adopting these technologies almost definitely outway the disadvantages. For a detailed look at some more of the issues around performance when using beans and tags, check out Chapter 8 : Tag Patterns (including a discussion of custom tags vs. JavaBeans) that is available to download in PDF format for free.
Anybody else have any real world experiences where performance has been a problem in these areas?
Simon
[ September 11, 2002: Message edited by: Simon Brown ]
 
Simon Brown
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Zac Roberts:
It seems that the books focus is on creating Tab Libraries from scratch. Do you think that it is better to take the time to create your own custom tags then use 3rd party solutions? Maybe it just depends on the type and scope of the project.


That's right, the book is focussed around building the various types of tags that are available. However, if there's a 3rd party solution available (a good example being the JSP Standard Tag Library, or JSTL) then I would certainly recommend using it. For all those situations where you need something more specific, you can either extend/modify the source (a good advantage of open source) or, since tags are fairly small components and quick to develop, you can build your own.
Simon
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Simon, Greetings from Canada,it sounds like your book is what I am looking for, and easy to understand.
I have some java code in my jsp page, and actually like it there, but I keep hearing about
"maintainability and reusability, it's best not to place too much Java code in your JSPs."
I haven't seen a posting of code snippets in the book givaways, but the below piece of code is what I have on my page. Is it best to put it into a tag or a bean? I should note that I have a number of these for year month and days, where the years start and end with different dates, and I use javascript for the validation.
<%
String passedBirthDateYear = (String) session.getValue("birthDateYear");
if (passedBirthDateYear==null) passedBirthDateYear="";
int birthStart = 82; // when does the years start
int birthEnd = 16; // and when do they end
String[] birthYears = new String[birthStart-birthEnd+1];
java.util.Calendar birthCal = java.util.Calendar.getInstance();
birthCal.add(java.util.Calendar.YEAR,-birthStart);
//for (int i=0;i<birthStart-birthEnd+1;i++) { //for 1920-1986
for (int i=(birthYears.length-1); i>=0; i--) { //1986-1920
birthYears[i]= String.valueOf(birthCal.get(java.util.Calendar.YEAR));
birthCal.add(java.util.Calendar.YEAR,1);
}
// Here we have an array of years from 2002-16 to 2002-82
// dob year needs to start with 1986 and end with 1920
// next year it would be 2003-17 to 2003-83
%>
---------
down in the form i have the other half
<select name="birthDateYear" tabindex="2" <% if ( secureSite != null ){ %>
class="disable" onFocus="termDtYr.focus()"
<% } else if ( display ){ %> onfocus='messageBirthDate()'<% }else{ %>
<% } %> onChange="return (isBirthDate(this.form, 'check') && allOK(this.form, 'check'));">
<OPTION >Year
<%
String ySelect1 = "";
for (int i=0;i<birthYears.length;i++) {
if (birthYears[i].equals(passedBirthDateYear)) ySelect1 = "selected";
else ySelect1 = "";
%>
<option value="<%= birthYears[i] %>"<%= ySelect1 %>><%= birthYears[i] %></option>
<%}%></select>
so what do you think?
 
Simon Brown
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From a quick glance, it looks as if the logic here is mainly used to generate a dropdown containing numbers, while additionally adding some validation.
Generating HTML controls is a good example of presentation logic and hence can easily be wrapped up inside a custom tag. One of the main benefits of using tags over JavaBeans is that tag handlers have complete access to the environment in which they are running. In other words, custom tags have access to things like the page context, session and so on, whereas JavaBeans don't since they are just environment independent reusable components. If built in a generic fashion, such tags can be reused all over your web application. In fact, you can also generate the JavaScript validation as a part of the tag if that's also useful to you elsewhere.
As far as the (server-side) validation logic goes, this could be placed inside a JavaBean, and Enterprise JavaBean, or even as other reusable classes if you choose to adopt a model 2 (MVC) style framework such as Struts. For a simple page however, a JavaBean is a good choice. Having validation logic as JavaScript is a good idea, although don't forget that users can disable it! This is one of the reasons why it makes sense to have validation logic back at the server to compliment any validation carried out on the client.
Does this help?
Simon
[ September 11, 2002: Message edited by: Simon Brown ]
 
Author
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
something that i've found is that if you try and do too much in a single tag then you can run into problems - as a hint, one of my tags had 200-300 lines of code in the do end bit. I find that this makes the tag less reusable and that breaking it down to the component parts improves the reusability.
Havent had much luck with getting the designers to use it tho because of the poor support by dreamweaver which makes it difficult the consequences of adding and taking away tags. Even the live view mode is a bit limited because it assumes the whole backend is written before the front end and I can only seem to make it work with Model 1 so far.
 
Simon Brown
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by chanoch wiggers:
I find that this makes the tag less reusable and that breaking it down to the component parts improves the reusability.


And this is where cooperating tags come into play.
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are "cooperating tags"? Are they tags that calls other tags?
 
Simon Brown
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cooperating tags are simply tags that communicate in some way. There are various reasons behind why you might want tags to cooperate, and there are several mechanisms for doing this, ranging from the exchange of information through variables to tag handler classes actually calling methods on other (generally parent, or enclosing) tag handlers.
Chapter 7 of my book is devoted to this topic and covers it in detail, including recommendations and best practices as to which type of cooperation is good for various scenarios.
Simon
 
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chapter 7 of Simon's book will cover cooperating tags. Seems that cooperating tags focus on design of tags and thus bring us reusability during tag library development.
 
Simon Brown
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Indeed - much of it is about partitioning that functionality so that it can be reused as often as possible.
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Apache DBTags we have lots of tags which helps us in getting the output of SQL statements in the JSP pages.
But is it a best practise to have the DataBase specific things ( Connection , ResultSet objetcs and the SQL Queries) in the presentation layer ?
Thanks
Sateesh
[ September 11, 2002: Message edited by: sateesh kommineni ]
 
Simon Brown
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Many people (myself included) would say no because data access/persistence logic becomes mixed up and intertwined with presentation logic. In addition to this, it makes it harder and more time consuming to modify the way that data is represented and/or stored. You lose some maintainability. A comprimise is to use JavaBeans/tags to wrap up this type of logic, although having a logically separated tier and object view of the data is generally better practice.
As with all things however, there are always circumstances that break the rules. In this case, small applications and prototypes can quickly be put together with such techniques.
That's just my opinion though...
Simon
[ September 11, 2002: Message edited by: Simon Brown ]
 
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I program JSP and mostly using java beans or help classes to separate logic and presentation.
My question is what are guidelines when we should use java-beans and when we should use Tags ? What is the best pattern of using the combination ?
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome Simon !
Do you have some sample chapters from your book to look at?
 
Simon Brown
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ruilin Yang:
I program JSP and mostly using java beans or help classes to separate logic and presentation.
My question is what are guidelines when we should use java-beans and when we should use Tags ? What is the best pattern of using the combination ?


There are several guidelines that can be followed, and a good place to read about them is in one of the sample chapters (Chapter 8 : Tag Patterns) from the book that can be downloaded from http://www.projsptags.com.
Hope that helps...
Simon
 
Simon Brown
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rajeev Nair:
Welcome Simon !
Do you have some sample chapters from your book to look at?


Hi Raj,
Yes, as usual with Wrox books, there are 2 sample chapters that are available to download in PDF format, both of which can be downloaded from http://www.projsptags.com. The chapters are (5) Iteration Tags and (8) Tag Patterns.
Cheers
Simon
 
Ruilin Yang
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thinks Simon.
That helps
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Simon,
I have a question. Sometimes when i using <jsp:include/>, it's work in window platform but it's not work in Linux. Why?
steffy
 
Simon Brown
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Steffy Sing:
Hi Simon,
I have a question. Sometimes when i using <jsp:include/>, it's work in window platform but it's not work in Linux. Why?
steffy


I've not come across this before - which container are you using?
Simon
 
sing
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry simon, i actually not really know the meaning of "container". So, i don't know how to answer you. I usually use these two simple tags:
<jsp:forward page="" />
<jsp:include page="" />
This is the code that always come with error when i run it in Linux.
<jsp:include page="trxDelivery.jsp" flush="true" />
 
Simon Brown
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, which web server are you using?
Perhaps it's something to do with how the output streams are flushed, or perhaps the size of the page buffer.
Simon
 
Zac Roberts
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I like the sound of these cooperating tags and would like to learn more about them. I have only done some very small stuff with TagLibs but I found that I just kept adding attribute after attribut to one big huge tag. It's hard to decide when to stop adding attributes and actually just create a new tag. For instance, if I have a tag that creates an HTML table with certain information, do I use one tag to create the structure of the table and another to create the information within the table? That's the sort of thing I would like to learn more about.
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to write a iterate tag for the rowset datatype ?
 
Author
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how do i write a bean to maintain a database connection to my db server.
i m quite new to JSP/Beans, working a lot with Servlets only.
malhar
 
Simon Brown
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by hanumanth reddy:
How to write a iterate tag for the rowset datatype ?


You can use the tags provided with the JSTL, or check out the examples from
Chapter 5 : Iteration Tags that is available to download for free (in PDF format) from my book.
Simon
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Simon! What's your opinion about XSLT?
 
sing
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using Tomcat.
 
Simon Brown
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by urarom sogard:
Hi Simon! What's your opinion about XSLT?


It's certainly useful for taking XML documents and transforming them into different forms, but as far as generating content for web applications is concerned (especially when mixed with JSP), I'm not so convinced. Unless, perhaps, you have to support multiple client types. As with all the different technologies, it depends what you want to use it for.
Simon
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Simon,
I think I could benefit from this book. I am involved heavily with tagslibs right now. Good to see you in the JavaRanch!
[ September 13, 2002: Message edited by: John Boyce ]
 
Simon Brown
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by John Boyce:
Hi Simon,
I think I could benefit from this book. I am involved heavily with tagslibs right now. Good to see you in the JavaRanch!
[ September 13, 2002: Message edited by: John Boyce ]


Thanks! How are you finding tag libraries?
Simon
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Please help me.
Can I use "include" to include a html page, which is in a different server, into my JSP file? Is there anything in JSP like "href" to link html pages.
Thanks in advance.
David
 
Power corrupts. Absolute power xxxxxxxxxxxxxxxx is kinda neat.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic