JSP style: java code or tags

D

Drew Volpe

I'm working on an API to allow customers to extend our
software by writing their own JSPs. For the samples I'm
creating I'm trying to decide if I should use JSTLs or equivalent
Java code snippets. I think JSTLs make things neater (I'm a
Java developer with limited exposure to JSP), but I'm not sure
everyone will have them installed. How common are they ? And
which do most JSP developers prefer ?


ie, either:

<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
<sql:query var="sample">
SELECT * FROM sample WHERE id = 1
</sql:query>


or this:

<%
Connection connection =
DriverManager.getConnection(url, dbUserName, dbUserPassword);
String sqlCommand = "SELECT * FROM sample WHERE id = 1";
ResultSet rs = connection.createStatement().executeQuery(sqlCommand);
rs.next(); // take first one for now

%>



thoughts ?



dv

--
--------------------------------------------------------------------------
The geographical center of Boston is in Roxbury. Due north of the
center we find the South End. This is not to be confused with South
Boston which lies directly east from the South End. North of the South
End is East Boston and southwest of East Boston is the North End.

Drew Volpe, mylastname at hcs o harvard o edu
 
W

Wendy S

Drew Volpe said:
thoughts ?

JSTL! I can't imagine anyone would use scriptlets if given the choice, but
YMMV.

Doing SQL stuff in a JSP is another topic _entirely_ but you didn't ask so
I'll keep my mouth shut. ;)
 
J

Joerg Gippert

Hi Drew,
I'm working on an API to allow customers to extend our
software by writing their own JSPs. For the samples I'm
creating I'm trying to decide if I should use JSTLs or equivalent
Java code snippets. I think JSTLs make things neater (I'm a
Java developer with limited exposure to JSP), but I'm not sure
everyone will have them installed. How common are they ? And
which do most JSP developers prefer ?
[tag or script]

Since the JSTL are implemented in J2EE, people dealing with JSP most likely
will have installed JSTL on their system as well. Using tags, your JSP´s are
also easier to maintain. Personally, I try to avoid scriptletts whereever I
can. Makes everything look cleaner ;)

Regards,
Joerg
 
J

Joerg Gippert

Drew Volpe said:
But they don't come standard in most (all ?) webapps, so they would've
had to install it themselves, right ? Will most JSP developers have
done that ?

Yes, you´re right. Was late yesterday, my fault ;) ...
In order to use the JSTL you would need a JSP container, that supports Java
Servlets specifications 2.3 and JSP specifications 1.2, like Tomcat 4.0.x
does. I have Tomcat 4.1.4 installed and it did come with the "Standard Tag
Library" of the Apache projects, which is a reference implementation of
JSTL. Your taglibs files need to be in the WEB-INF (and WEB-INF/lib) folder.
So, you would need to supply the taglibs along with your webapp (TLD and jar
files). As far as your question "Will most JSP developers have installed a
JSTL compliant server?": I don´t know any JSP developer, that hasn´t heard
of taglibs/JSTL. So, if you´re in that field, it is most likely, that you
have at least tried out JSTL since it really is an enhancement and not just
another "this-is-cool-technology-you-must-use-it" hype. It is also clear,
JSTL will play a fundamental role in the future of JSP developing.
I really want to keep things as simple as possible and make sure
the lowest common denominator can just drop my JSPs in and have
them work.

Yes, I can understand that. Personally, I still would go for the
taglib-version. If someone hasn´t heard of taglibs, I wouldn´t consider
him/her a serious JSP developer. But to make sure, everyone is satisfied
with your work, you could create samples, that use taglibs and samples that
don´t use them. Means lot work but probably less nagging customers ;)

Regards,
Joerg
 
D

Drew Volpe

Yes, you´re right. Was late yesterday, my fault ;) ...
In order to use the JSTL you would need a JSP container, that supports Java
Servlets specifications 2.3 and JSP specifications 1.2, like Tomcat 4.0.x
does. I have Tomcat 4.1.4 installed and it did come with the "Standard Tag
Library" of the Apache projects, which is a reference implementation of
JSTL.

are you sure ? if it comes with the stable release of tomcat, that's
standard enough for me, but I looked at my installations (tomcat 4.1.12
for linux) and couldn't find any JSTL implementation with it.
"find . -name jstl*" and "find . -name standard*" return nothing. and
I just downloaded 4.1.24 for Windows and don't see it in that release
either. Am I looking for the wrong files ?

Yes, I can understand that. Personally, I still would go for the
taglib-version. If someone hasn´t heard of taglibs, I wouldn´t consider
him/her a serious JSP developer. But to make sure, everyone is satisfied
with your work, you could create samples, that use taglibs and samples that
don´t use them. Means lot work but probably less nagging customers ;)

That's my plan right now, but I'd prefer not to publish and maintain
two separate versions of everything.




dv

--
--------------------------------------------------------------------------
The geographical center of Boston is in Roxbury. Due north of the
center we find the South End. This is not to be confused with South
Boston which lies directly east from the South End. North of the South
End is East Boston and southwest of East Boston is the North End.

Drew Volpe, mylastname at hcs o harvard o edu
 
J

Joerg Gippert

Drew Volpe said:
Last time we met, Joerg Gippert <[email protected]> had said:
are you sure ? if it comes with the stable release of tomcat, that's
standard enough for me, but I looked at my installations (tomcat 4.1.12
for linux) and couldn't find any JSTL implementation with it.
"find . -name jstl*" and "find . -name standard*" return nothing. and
I just downloaded 4.1.24 for Windows and don't see it in that release
either. Am I looking for the wrong files ?

Now I´m confused as well. Just downloaded Tomcat for Windows (latest 4.1
release)
the taglibs are *not* incuded there. However, they were included in the
version I used at this very moment(
Apache Tomcat/4.1.12). I am sure, that I did not download the JSTL
separately. Maybe I downloaded some nightly built which accidently had JSTL
taglibs included? Don´t know. I´m sorry for confusing you but obviously
something to mixed up in my site here. :( The file by the way were the
correct ones. By default, they´ve been copied into the ROOT WEB-INF/
directory with my "weird" Tomcat version.

That's my plan right now, but I'd prefer not to publish and maintain
two separate versions of everything.

True. That might mean a lot of work. But can´t you just publish your samples
(I assume, it´s a WAR archive or something like that) including the taglibs?
Taglibs usually are in the WEB-INF folder anyways. You don´t need to put the
whole 20 MB distribution of the JSTL into it. Just the ones your samples
require. MAybe that´s a way around it?

Joerg
 
D

Drew Volpe

Last time we met said:
Now I´m confused as well. Just downloaded Tomcat for Windows (latest 4.1
release)
the taglibs are *not* incuded there. However, they were included in the
version I used at this very moment(
Apache Tomcat/4.1.12). I am sure, that I did not download the JSTL
separately. Maybe I downloaded some nightly built which accidently had JSTL
taglibs included? Don´t know. I´m sorry for confusing you but obviously
something to mixed up in my site here. :( The file by the way were the
correct ones. By default, they´ve been copied into the ROOT WEB-INF/
directory with my "weird" Tomcat version.


ok. good; I'm not loosing my mind.


thanks a lot for your help.


dv


--
--------------------------------------------------------------------------
The geographical center of Boston is in Roxbury. Due north of the
center we find the South End. This is not to be confused with South
Boston which lies directly east from the South End. North of the South
End is East Boston and southwest of East Boston is the North End.

Drew Volpe, mylastname at hcs o harvard o edu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top