Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSTL Installation  RSS feed

 
Allen Williams
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I apologize in advance. In my defense, I did read the FAQ, but was still unsure how to install the JSTL. Here is the FAQ, with my questions:


2. Be sure that your web.xml is properly configured for Servlets 2.4 as described in ServletsWebXml.

When I went to ServletsWebXMl, I found this
------------------------------------------------------------
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<display-name>web app name here</display-name>

<!-- rest of declarations go here -->

</web-app>
---------------------------------------------------------------
Do I put this in every web.xml for each web app my Tomcat installation
supports, or is there some global place I can put it?

It also says to not leave a DOCTYPE statement for an old version, but this doesn't have a DOCTYPE at all. Do I just delete the DOCTYPE that's there?

6. If you have a JSP prelude declared in your web.xml, that's a great place to put the taglib declarations as opposed to declaring them on each page.

That sounds like a good idea and would eliminate a lot of redundant coding. What is it, and what does it mean? What's a "JSP prelude"?

OK, I know I'm new to this, but I DID read the FAQ first;-).
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reading the faq

About web.xml, just copy paste the sample in every web.xml you need, and remove the DOCTYPE if there's one..

What's a "JSP prelude"?


Quoting the spec : The include-prelude element is an optional subelement of jsp-property-group.
It has no subelements. Its value is a context-relative path that must correspond to
an element in the Web Application. When the element is present, the given path
will be automatically included (as in an include directive) at the beginning of the
JSP page in the jsp-property-group.


If you set a jsp-property-group in your web.xml, you can add am include-prelude tag to add information at the beginning of every jsp files of this group.
 
Allen Williams
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow! Thanks for the quick reply. I put the JSTL files in the recommended place for global access, $CATALINA_HOME/shared/lib, but that is not in my context path, which is /var/www/webapps/{web-app-name-here}. Will Tomcat find it OK? If I just fire it up and see, and it doesn't find it, I don't think I'd know where to start looking for the problem! ;)

I'm still not sure I fully understand the prelude thing, but your response has given me a start in where to look, so I'll hold that question until I've done a little more research.

Thanks again!
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow! Thanks for the quick reply. I put the JSTL files in the recommended place for global access, $CATALINA_HOME/shared/lib, but that is not in my context path, which is /var/www/webapps/{web-app-name-here}. Will Tomcat find it OK? If I just fire it up and see, and it doesn't find it, I don't think I'd know where to start looking for the problem! ;)

but that is not in my context path

It's ok. Tomcat will import all libraries in shared/lib, so you don't have to worry.
Why do you think it doesn't find it ? Do you get an error message ?


I'm still not sure I fully understand the prelude thing,

To put it simply, imagine you have lots of JSP files. All of them use the same taglib definitions.
For example : <%@ taglib uri="..." prefix="mytag" %>
Putting this line in every JSP is a waste, don't you think ? One way to avoid this is to include a common jsp file containing that one line, using something like <%@ include ... %>
Another way is to use the include-preclude, which will do the same.
 
Allen Williams
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once again, thanks!

I hadn't tried starting it yet, will do so today after I fix the web.xml as per your instructions. I was stating the hypothetical situation that if I started it and it didn't work, I wouldn't know where to start. I have the utmost confidence it will work!

Are these the jars that are also required for EL? I tried to put EL into a jsp a while ago and couldn't get it to work.

Thanks again!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Until your web.xml is set properly, not much will work.

Also, as of JSP 2.0, the JSTL and EL are independent.
[ September 05, 2006: Message edited by: Bear Bibeault ]
 
Allen Williams
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, does that mean I need jars beside jstl.jar and standard.jar in order for the EL to work?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Allen Williams:
So, does that mean I need jars beside jstl.jar and standard.jar in order for the EL to work?


Not if you are using a JSP2.0 compliant container. EL is part of J2EE 1.4.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Satou kurinosuke:
To put it simply, imagine you have lots of JSP files. All of them use the same taglib definitions.
For example : <%@ taglib uri="..." prefix="mytag" %>
Putting this line in every JSP is a waste, don't you think ? One way to avoid this is to include a common jsp file containing that one line, using something like <%@ include ... %>
Another way is to use the include-preclude, which will do the same.


That works great, except I don't think that an IDE will recognized imported taglibs that way. At least the one I use doesn't. So I end up putting it on every page anyway so that I get the code completion and what not. It's not that big of a deal to copy and paste.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!