<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Instant XML feeds via the JSTL SQL tags</title>
	<atom:link href="http://krook.net/archives/210/feed" rel="self" type="application/rss+xml" />
	<link>http://krook.net/archives/210</link>
	<description>Daniel Krook is an IBM Certified IT Specialist based in Armonk, New York.  He has over 10 years experience in Web site development and presently builds integrated applications on WebSphere and DB2 along with Apache, MySQL, and PHP for ibm.com and the intranet.  He holds certifications in PHP (ZCE), Java (SCJP, SCWCD), DB2 (ICDAssoc., ICAD), and Solaris (SCSA).  He occasionally writes PHP-related articles for IBM developerWorks and co-authored the IBM Redbook 'Developing PHP Applications for IBM Data Servers.'  His current interests include RESTful Web services and mobile application development for smartphones.</description>
	<lastBuildDate>Thu, 05 Aug 2010 20:55:29 -0400</lastBuildDate>
	
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Art Jolin</title>
		<link>http://krook.net/archives/210/comment-page-1#comment-78036</link>
		<dc:creator>Art Jolin</dc:creator>
		<pubDate>Sat, 07 Nov 2009 19:08:42 +0000</pubDate>
		<guid isPermaLink="false">http://krook.net/archives/210#comment-78036</guid>
		<description>&quot;this should be considered a temporary and unorthodox option &quot; -- my reading was different. If nothing else then my post helped to make clear to all readers your position on this. The &quot;temporary&quot; part must always be carefully considered; we&#039;ve all done &quot;temporary&quot; work which is still in use years later because we lack the time to fix it until it truely bites us hard (always at the worst possible time).

&quot;In DB2, or any other database, you can control access through grants to particular users.&quot; -- in my experience in enterprise applications (and that of all my collegues, based on discussions and papers written &amp; reviewed by the community), it is very rare for DB admins to set up per-end-user access. WAS guidelines recommend a single userid/password for an application (often for an entire suite of apps) as the typical case. Also, r/w vs. r/o access isn&#039;t enough since the vast majority of secured enterprise data must be secured from read as well (do you want your neighbors reading your bank statements?). There are indeed alot of control points but DB admins and their executives don&#039;t want to use them. That&#039;s why we have LDAP and ActiveDirectory. Getting very clever (and more verbose in your JSP logic) means more logic that is difficult to debug using today&#039;s IDEs (anyone who has tried to debug JSPs would agree -- if anyone doesn&#039;t pls chime in). Until there is a revolution throwing out MVC as the most common design pattern there will be no motivation for IDEs to make this any easier.

&quot;while a consuming application necessarily loses… You could serve different formats to each&quot; -- my point is that putting such new function in the model (outside JSPs) with the minimum JSP view logic means that access by consuming apps is free - you don&#039;t have to reimplement your SQL and related logic in a second place the apps can reach. The additional cost is very minor, only an extra method call or two from the JSP instead of the logic being inline. If this was &quot;bolt[ed] on separate to the existing application&quot; it&#039;s still a JSP and thus not accessible to model (ie., plain Java) code; implement it in the model and its accessible to both.


&quot;cheaply prototyping &quot; --  honestly I don&#039;t see this as any cheaper to implement than doing it as MVC, except for those 1-2 method calls I mentioned. A prototype MVC implementation is fast because you don&#039;t add in the full set of error checking, edge functions, etc. You still end up with the layering you&#039;ll use in the final production-ready feature (assuming you&#039;re adding a feature to a mature app which good layering standards already) and only have to add code to the existing classes. If you prototype as JSPs then you must create the basic classes for layering and refactor all your JSP logic into them.  I happen to currently have a customer (not the first I&#039;ve seen) that took a variation of your &quot;all in the JSP&quot; approach and they experienced exactly this no-faster and hard-to-debug situation. SO I&#039;m saying you can definitely cheap-prototype to validate a need and still stick with good MVC.

&quot;About your later point regarding caching&quot; -- I am talking about data-level caching (Dynacache dynamic page content caching is great, but isn&#039;t always the best choice). Dynacache command caching, for example, assumes you have MVC and actions/commands; it would be really messy stuffed inside a JSP. Beyond that are the more recent techniques (still 8-10 years old) of caching at the data layer (after you do a DB query and turn the data into a Java object, you caching it to avoid repeating the DB query).  This includes simple single-JVM caching using java.util.Map and  cross-JVM caching products like WebSphere Extreme Scale or Coherence. You also miss out on using Hibernate or the Java Persistence Architecture (JPA)  feature in WAS to automate your DB access - as well as the caching points built into these frameworks. These are the sorts of caching technlogy you miss out on if you put your data access logic in a JSP (to be precise, it would look WAY WAY UGLY to stuff this into a JSP). Yet the primary benefit of JPA is to speed up development of data access logic (but in a production-ready way when you later add query tuning and other fine adjustments). Using the PreparedStatementCache does greatly speed up making a DB query a second or nth time, but it can&#039;t compare to avoiding the query altogether by caching the data. About 70% of my gigs over the last 2 years have been involved at least partially with going beyond query optimization into actual data caching. Ask other currently-practicing consultants and I bet you get a number more like 40% (since caching is a special skill area of mine) but that still clearly shows that most apps benefit from some form of caching beyond DynaCache static and dynamic content caching.

&quot;best tool for the job&quot; -- I totally agree with you, as I am also a pragmatist. We seem to only disagree about the relative benefits and drawbacks of SQL-based tags in JSPs. I do fully recognize the one inescapable benefit of putting the entire function in a JSP - that JSPs are easier to upload on the fly (on the sly??? ;-) into a running application than non-JSP Java classes are. However, that is really a process problem - there SHOULD be a way in any web application environment to easily try out potentially useful new function. It is totally technically possible, in several ways. It will always be controlled and that&#039;s as it should be - you can&#039;t have any developer with wild hair adding function to a public web app which is the public face of a company. If the only reason to put business logic into a JSP is to hack around a self-defeating corporate IT policy then call it a hack and perhaps use the above drawbacks to justify fixing the policy so you can prototype the way you should.
</description>
		<content:encoded><![CDATA[<p>&#8220;this should be considered a temporary and unorthodox option &#8221; &#8212; my reading was different. If nothing else then my post helped to make clear to all readers your position on this. The &#8220;temporary&#8221; part must always be carefully considered; we&#8217;ve all done &#8220;temporary&#8221; work which is still in use years later because we lack the time to fix it until it truely bites us hard (always at the worst possible time).</p>
<p>&#8220;In DB2, or any other database, you can control access through grants to particular users.&#8221; &#8212; in my experience in enterprise applications (and that of all my collegues, based on discussions and papers written &amp; reviewed by the community), it is very rare for DB admins to set up per-end-user access. WAS guidelines recommend a single userid/password for an application (often for an entire suite of apps) as the typical case. Also, r/w vs. r/o access isn&#8217;t enough since the vast majority of secured enterprise data must be secured from read as well (do you want your neighbors reading your bank statements?). There are indeed alot of control points but DB admins and their executives don&#8217;t want to use them. That&#8217;s why we have LDAP and ActiveDirectory. Getting very clever (and more verbose in your JSP logic) means more logic that is difficult to debug using today&#8217;s IDEs (anyone who has tried to debug JSPs would agree &#8212; if anyone doesn&#8217;t pls chime in). Until there is a revolution throwing out MVC as the most common design pattern there will be no motivation for IDEs to make this any easier.</p>
<p>&#8220;while a consuming application necessarily loses… You could serve different formats to each&#8221; &#8212; my point is that putting such new function in the model (outside JSPs) with the minimum JSP view logic means that access by consuming apps is free &#8211; you don&#8217;t have to reimplement your SQL and related logic in a second place the apps can reach. The additional cost is very minor, only an extra method call or two from the JSP instead of the logic being inline. If this was &#8220;bolt[ed] on separate to the existing application&#8221; it&#8217;s still a JSP and thus not accessible to model (ie., plain Java) code; implement it in the model and its accessible to both.</p>
<p>&#8220;cheaply prototyping &#8221; &#8212;  honestly I don&#8217;t see this as any cheaper to implement than doing it as MVC, except for those 1-2 method calls I mentioned. A prototype MVC implementation is fast because you don&#8217;t add in the full set of error checking, edge functions, etc. You still end up with the layering you&#8217;ll use in the final production-ready feature (assuming you&#8217;re adding a feature to a mature app which good layering standards already) and only have to add code to the existing classes. If you prototype as JSPs then you must create the basic classes for layering and refactor all your JSP logic into them.  I happen to currently have a customer (not the first I&#8217;ve seen) that took a variation of your &#8220;all in the JSP&#8221; approach and they experienced exactly this no-faster and hard-to-debug situation. SO I&#8217;m saying you can definitely cheap-prototype to validate a need and still stick with good MVC.</p>
<p>&#8220;About your later point regarding caching&#8221; &#8212; I am talking about data-level caching (Dynacache dynamic page content caching is great, but isn&#8217;t always the best choice). Dynacache command caching, for example, assumes you have MVC and actions/commands; it would be really messy stuffed inside a JSP. Beyond that are the more recent techniques (still 8-10 years old) of caching at the data layer (after you do a DB query and turn the data into a Java object, you caching it to avoid repeating the DB query).  This includes simple single-JVM caching using java.util.Map and  cross-JVM caching products like WebSphere Extreme Scale or Coherence. You also miss out on using Hibernate or the Java Persistence Architecture (JPA)  feature in WAS to automate your DB access &#8211; as well as the caching points built into these frameworks. These are the sorts of caching technlogy you miss out on if you put your data access logic in a JSP (to be precise, it would look WAY WAY UGLY to stuff this into a JSP). Yet the primary benefit of JPA is to speed up development of data access logic (but in a production-ready way when you later add query tuning and other fine adjustments). Using the PreparedStatementCache does greatly speed up making a DB query a second or nth time, but it can&#8217;t compare to avoiding the query altogether by caching the data. About 70% of my gigs over the last 2 years have been involved at least partially with going beyond query optimization into actual data caching. Ask other currently-practicing consultants and I bet you get a number more like 40% (since caching is a special skill area of mine) but that still clearly shows that most apps benefit from some form of caching beyond DynaCache static and dynamic content caching.</p>
<p>&#8220;best tool for the job&#8221; &#8212; I totally agree with you, as I am also a pragmatist. We seem to only disagree about the relative benefits and drawbacks of SQL-based tags in JSPs. I do fully recognize the one inescapable benefit of putting the entire function in a JSP &#8211; that JSPs are easier to upload on the fly (on the sly??? ;-) into a running application than non-JSP Java classes are. However, that is really a process problem &#8211; there SHOULD be a way in any web application environment to easily try out potentially useful new function. It is totally technically possible, in several ways. It will always be controlled and that&#8217;s as it should be &#8211; you can&#8217;t have any developer with wild hair adding function to a public web app which is the public face of a company. If the only reason to put business logic into a JSP is to hack around a self-defeating corporate IT policy then call it a hack and perhaps use the above drawbacks to justify fixing the policy so you can prototype the way you should.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Krook</title>
		<link>http://krook.net/archives/210/comment-page-1#comment-77964</link>
		<dc:creator>Daniel Krook</dc:creator>
		<pubDate>Wed, 04 Nov 2009 04:22:23 +0000</pubDate>
		<guid isPermaLink="false">http://krook.net/archives/210#comment-77964</guid>
		<description>Hi Art,

Thanks for the comments.  Don&#039;t worry, I don&#039;t take them as rude. :)

Before I address your points, let me just re-iterate a passage from the post.  This should reinforce my view that this should be considered a temporary and unorthodox option - based on something that&#039;s available in the spec - not necessarily a best practice.  The goal is to provide some extra, low cost functionality quickly to justify further development using the proper approach.  

&lt;blockquote&gt;
Of course, the flip side is that you&#039;ve [provided data-powered functionality] outside of your application framework and may have circumvented some well-intended best practices. However, you may to prefer to think of this approach as a temporary, low-risk way to share the data available to the users of your application in novel ways that may justify investing in the development of longer term solutions. 
&lt;/blockquote&gt;

So in no way is this post meant to disparage architectural best practices in JEE development.  I find it complementary to - and doesn&#039;t compete with - our Struts and Spring MVC applications in production.  

In fact, it even becomes a necessary measure when your application is deployed to a hosting center that requires 4 months and $20k to deploy an updated EAR file, versus promoting a single JSP on demand. 

On to your points;

To answer the first one, about security exposures.  This is &lt;em&gt;indeed&lt;/em&gt; a low risk approach.  There is nothing in the tags that implies that the data source you are accessing from the tags has unlimited privileges on the database.  

In DB2, or any other database, you can control access through grants to particular users.  Or even set up views to limit their access to the underlying table structure.  In WebSphere, or any other app server, you&#039;ll then associate the user id to a data source and make it available in your deployment descriptor to the Web application.   So there are a lot of control points here.

For example, you might have one read-write JNDI resource for your business logic, and another read only or restricted access enforced by the database and optimized through several modifications to your queries, such as those that increase concurrency through isolation levels.

To address your second point, I don&#039;t understand why doing this implies that the end user gains while a consuming application necessarily loses... You could serve different formats to each, or just bolt this on separate to the existing application without upsetting any existing interface.  

And what if one user or another now wants the same access to the data you&#039;ve just freed up... that&#039;s the point of cheaply prototyping in order to validate a business need and justify new development to meet the requirement.

About your later point regarding caching, can you provide some more detail here how this defeats the cache?  These JSPs are compiled like any other into servlets, and you can still use WebSphere&#039;s DynaCache to set a policy for these URLs.  Using prepared statements and the proper read-only optimization in your queries makes this as efficient as any other data access method you could deploy in a Web app.

As for ColdFusion... I refuse to defend that platform, and I feel your pain... What&#039;s the sounder platform you suggest?

In any case, my experience has shown me that it&#039;s wisest to choose the best tool for the job, even if that means integrating several platforms (e.g., &lt;a href=&quot;http://www.ibm.com/developerworks/websphere/techjournal/0505_krook/0505_krook.html&quot; rel=&quot;nofollow&quot;&gt;WebSphere and PHP&lt;/a&gt;) or breaking down your system requirements into manageable chunks that can have their own independent technology implementation and link them together with an SOA, or even supplement an MVC architecture with good old functional, type one JSP scriptlet pages.</description>
		<content:encoded><![CDATA[<p>Hi Art,</p>
<p>Thanks for the comments.  Don&#8217;t worry, I don&#8217;t take them as rude. :)</p>
<p>Before I address your points, let me just re-iterate a passage from the post.  This should reinforce my view that this should be considered a temporary and unorthodox option &#8211; based on something that&#8217;s available in the spec &#8211; not necessarily a best practice.  The goal is to provide some extra, low cost functionality quickly to justify further development using the proper approach.  </p>
<blockquote><p>
Of course, the flip side is that you&#8217;ve [provided data-powered functionality] outside of your application framework and may have circumvented some well-intended best practices. However, you may to prefer to think of this approach as a temporary, low-risk way to share the data available to the users of your application in novel ways that may justify investing in the development of longer term solutions.
</p></blockquote>
<p>So in no way is this post meant to disparage architectural best practices in JEE development.  I find it complementary to &#8211; and doesn&#8217;t compete with &#8211; our Struts and Spring MVC applications in production.  </p>
<p>In fact, it even becomes a necessary measure when your application is deployed to a hosting center that requires 4 months and $20k to deploy an updated EAR file, versus promoting a single JSP on demand. </p>
<p>On to your points;</p>
<p>To answer the first one, about security exposures.  This is <em>indeed</em> a low risk approach.  There is nothing in the tags that implies that the data source you are accessing from the tags has unlimited privileges on the database.  </p>
<p>In DB2, or any other database, you can control access through grants to particular users.  Or even set up views to limit their access to the underlying table structure.  In WebSphere, or any other app server, you&#8217;ll then associate the user id to a data source and make it available in your deployment descriptor to the Web application.   So there are a lot of control points here.</p>
<p>For example, you might have one read-write JNDI resource for your business logic, and another read only or restricted access enforced by the database and optimized through several modifications to your queries, such as those that increase concurrency through isolation levels.</p>
<p>To address your second point, I don&#8217;t understand why doing this implies that the end user gains while a consuming application necessarily loses&#8230; You could serve different formats to each, or just bolt this on separate to the existing application without upsetting any existing interface.  </p>
<p>And what if one user or another now wants the same access to the data you&#8217;ve just freed up&#8230; that&#8217;s the point of cheaply prototyping in order to validate a business need and justify new development to meet the requirement.</p>
<p>About your later point regarding caching, can you provide some more detail here how this defeats the cache?  These JSPs are compiled like any other into servlets, and you can still use WebSphere&#8217;s DynaCache to set a policy for these URLs.  Using prepared statements and the proper read-only optimization in your queries makes this as efficient as any other data access method you could deploy in a Web app.</p>
<p>As for ColdFusion&#8230; I refuse to defend that platform, and I feel your pain&#8230; What&#8217;s the sounder platform you suggest?</p>
<p>In any case, my experience has shown me that it&#8217;s wisest to choose the best tool for the job, even if that means integrating several platforms (e.g., <a href="http://www.ibm.com/developerworks/websphere/techjournal/0505_krook/0505_krook.html" rel="nofollow">WebSphere and PHP</a>) or breaking down your system requirements into manageable chunks that can have their own independent technology implementation and link them together with an SOA, or even supplement an MVC architecture with good old functional, type one JSP scriptlet pages.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Art Jolin</title>
		<link>http://krook.net/archives/210/comment-page-1#comment-77963</link>
		<dc:creator>Art Jolin</dc:creator>
		<pubDate>Tue, 03 Nov 2009 23:36:16 +0000</pubDate>
		<guid isPermaLink="false">http://krook.net/archives/210#comment-77963</guid>
		<description>&quot;Why not just free your data for use by your users’ new requirements in a quick hitting, low risk way?&quot;
The answer is &quot;The old style was abandonded for production for good reasons: 1) security exposures (what user is authorized to see ANY AND ALL data? no one in a production app),  2) you have just shifted what user is dissatisfied - use tags and it&#039;s now the other components or apps who want the same access the humans have and you are back to implementing an action.   You put forward the same old argument used when better engineering frameworks and practices were first introduced and the free spirits didn&#039;t want to change.  Sure, we all want to whip it out and see it run - that&#039;s the fun part. When your business depends on it being robust and secure as well as being right and fast (and tags circumvent many of the caching solutions out there now so it may not even be fast except for the coder)  you gotta bite the bullet and do it right. I&#039;ve just been asked to help a large customer migrate from ColdFusion to better, sounder application architecture - ColdFusion has just such DB-access tags for JSPs and many (not all, certainly - if it ain&#039;t broke...) that have lived with it for years are belatedly jumping on the J2EE wagon.  What is ColdFusion&#039;s market share? That should give anyone a clue on the longevity of these sorts of quicky techniques.  Sorry if I sound really opinionated, but it&#039;s from 15+ years consulting on web apps from CGI and C on standalone web servers to J2EE and Java on massive app server clusters and their minions today. Don&#039;t mean to be rude, just been thru it before.</description>
		<content:encoded><![CDATA[<p>&#8220;Why not just free your data for use by your users’ new requirements in a quick hitting, low risk way?&#8221;<br />
The answer is &#8220;The old style was abandonded for production for good reasons: 1) security exposures (what user is authorized to see ANY AND ALL data? no one in a production app),  2) you have just shifted what user is dissatisfied &#8211; use tags and it&#8217;s now the other components or apps who want the same access the humans have and you are back to implementing an action.   You put forward the same old argument used when better engineering frameworks and practices were first introduced and the free spirits didn&#8217;t want to change.  Sure, we all want to whip it out and see it run &#8211; that&#8217;s the fun part. When your business depends on it being robust and secure as well as being right and fast (and tags circumvent many of the caching solutions out there now so it may not even be fast except for the coder)  you gotta bite the bullet and do it right. I&#8217;ve just been asked to help a large customer migrate from ColdFusion to better, sounder application architecture &#8211; ColdFusion has just such DB-access tags for JSPs and many (not all, certainly &#8211; if it ain&#8217;t broke&#8230;) that have lived with it for years are belatedly jumping on the J2EE wagon.  What is ColdFusion&#8217;s market share? That should give anyone a clue on the longevity of these sorts of quicky techniques.  Sorry if I sound really opinionated, but it&#8217;s from 15+ years consulting on web apps from CGI and C on standalone web servers to J2EE and Java on massive app server clusters and their minions today. Don&#8217;t mean to be rude, just been thru it before.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BorisPlus</title>
		<link>http://krook.net/archives/210/comment-page-1#comment-58494</link>
		<dc:creator>BorisPlus</dc:creator>
		<pubDate>Mon, 20 Oct 2008 18:11:26 +0000</pubDate>
		<guid isPermaLink="false">http://krook.net/archives/210#comment-58494</guid>
		<description>hello,I use jstl sql query, but I have some trouble.if I 
select from one table twice
Select t1.Id as Id1, t2.Id as id2 from tab t1,tab t2
, so I have sql result with two columns &quot;Id&quot; and &quot;id&quot;, but not &quot;id1&quot; and &quot;id2&quot;. I use mysql jdbc connector. in this I can&#039;t use simple displaytag construction,because there is only one column &quot;Id&quot;. please, email me</description>
		<content:encoded><![CDATA[<p>hello,I use jstl sql query, but I have some trouble.if I<br />
select from one table twice<br />
Select t1.Id as Id1, t2.Id as id2 from tab t1,tab t2<br />
, so I have sql result with two columns &#8220;Id&#8221; and &#8220;id&#8221;, but not &#8220;id1&#8243; and &#8220;id2&#8243;. I use mysql jdbc connector. in this I can&#8217;t use simple displaytag construction,because there is only one column &#8220;Id&#8221;. please, email me</p>
]]></content:encoded>
	</item>
</channel>
</rss>
