Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Cannot get a simple JSTL example to work .(robr)

843836Mar 22 2005 — edited Mar 23 2005
I am trying to use IntelliJ with JBOSS integrated into the ide as a J2EE container. JBOSS uses Tomcat for it's web server.

Intelli J version 4.5.4.
JBOSS 4.01 which uses Tomcat 5.0x.
Java 1.4.2.


Here is my simple program called JSTLExample.jsp
<%--
  Created by IntelliJ IDEA.
  User: Roland
  Date: Mar 10, 2005
  Time: 9:25:36 PM
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix = "c" %>
 
<%!
  String[] names = {"Ruth", "Matilda", "Millicent", "Micah"};
%>
 
<HTML>
  <HEAD><TITLE>Chapter 2 - Embedding Code</TITLE></HEAD>
  <BODY>
  test
      <c:forEach var="person" items="<%= names %>">
        <c:out value="${person}" />
      </c:forEach>
  </BODY>
</HTML>
Here is my web.xml file.
<?xml version="1.0" encoding="UTF-8"?>
 
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<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 http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd">
    <context-param>
        <param-name>name</param-name>
        <param-value>John Doe</param-value>
    </context-param>
    <context-param>
        <param-name>password</param-name>
        <param-value>password</param-value>
    </context-param>
    <servlet>
        <servlet-name>HelloServlet</servlet-name>
        <servlet-class>sample.HelloServlet</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>BasicServlet</servlet-name>
        <servlet-class>sample.BasicServlet</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>BasicFormProcessor</servlet-name>
        <servlet-class>sample.BasicFormProcessor</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>ParameterServlet</servlet-name>
        <servlet-class>sample.ParameterServlet</servlet-class>
        <init-param>
            <param-name>password</param-name>
            <param-value>1234cassidy</param-value>
        </init-param>
        <init-param>
            <param-name>name</param-name>
            <param-value>cassidy</param-value>
        </init-param>
    </servlet>
    <servlet>
        <servlet-name>testServlet</servlet-name>
        <servlet-class>testServlet</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>LoggerServlet</servlet-name>
        <servlet-class>sample.LoggerServlet</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>ForwardingServlet</servlet-name>
        <servlet-class>sample.ForwardingServlet</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>IncludeServlet</servlet-name>
        <servlet-class>sample.IncludeServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>HelloServlet</servlet-name>
        <url-pattern>/greeting</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>BasicServlet</servlet-name>
        <url-pattern>/myServlet</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>BasicFormProcessor</servlet-name>
        <url-pattern>/basicform</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>ParameterServlet</servlet-name>
        <url-pattern>/ParameterServlet</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>testServlet</servlet-name>
        <url-pattern>/testServlet</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>LoggerServlet</servlet-name>
        <url-pattern>/logger</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>ForwardingServlet</servlet-name>
        <url-pattern>/forward</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>IncludeServlet</servlet-name>
        <url-pattern>/include</url-pattern>
    </servlet-mapping>
    <ejb-ref>
        <ejb-ref-name>ejb/hello</ejb-ref-name>
        <ejb-ref-type>Session</ejb-ref-type>
        <home>sample.HelloHome</home>
        <remote>sample.Hello</remote>
    </ejb-ref>
 
    <jsp-config>
    <taglib>
      <taglib-uri>http://java.sun.com/jsp/jstl/fmt</taglib-uri>
      <taglib-location>/WEB-INF/tld/fmt.tld</taglib-location>
    </taglib>
    <taglib>
      <taglib-uri>http://java.sun.com/jsp/jstl/fmt-rt</taglib-uri>
      <taglib-location>/WEB-INF/tld/fmt-rt.tld</taglib-location>
    </taglib>
    <taglib>
      <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
      <taglib-location>/WEB-INF/tld/c.tld</taglib-location>
    </taglib>
    <taglib>
      <taglib-uri>http://java.sun.com/jsp/jstl/core-rt</taglib-uri>
      <taglib-location>/WEB-INF/tld/c-rt.tld</taglib-location>
    </taglib>
    <taglib>
      <taglib-uri>http://java.sun.com/jsp/jstl/sql</taglib-uri>
      <taglib-location>/WEB-INF/tld/sql.tld</taglib-location>
    </taglib>
    <taglib>
      <taglib-uri>http://java.sun.com/jsp/jstl/sql-rt</taglib-uri>
      <taglib-location>/WEB-INF/tld/sql-rt.tld</taglib-location>
    </taglib>
    <taglib>
      <taglib-uri>http://java.sun.com/jsp/jstl/x</taglib-uri>
      <taglib-location>/WEB-INF/tld/x.tld</taglib-location>
    </taglib>
    <taglib>
      <taglib-uri>http://java.sun.com/jsp/jstl/x-rt</taglib-uri>
      <taglib-location>/WEB-INF/tld/x-rt.tld</taglib-location>
    </taglib>
    </jsp-config>
 
</web-app>
The program compiles. No parts are red. My JBOSS local environment runs without any errors or exceptions.

When I try using the JSTExample.jsp I get the following output.
test ${person} ${person} ${person} ${person}

The code treats {${person}" like it is a string instead of a variable.

I completed the following steps to do this.

1.Downloaded JSTL 1.1
2. Unzipped JSTL1.1.
3. Copies the standard.jar and jstl.jar file into the jboss/server/default/lib folder.
4. Added standard.jar and jstl.jar to the web module libraries.
5. In the libraries classpath I have created a library by adding the jakarta-taglibs-standard-1.1.2\tld directory. The contents of this directory get copies to relative path of /WEB-INF/tld.
6. Created the app.ear file by starting up JBOSS in IntelliJ.

I unzipped the app.ear file and extracted the web.war file. The web.war file contains all the .tld files in the WEB-INF\tld\ folder. The uri in the .tld files match the taglib directive I am using in the JSTLExample.jsp file.

I don't know what more I can do with this code. I have worked on it for over a week trying everything I could think of. I even tried including the text of the c.tld file directly into the the jsp. That didn't work.

Maybe the code just cannot be integrated with a J2EE container. Maybe it can only be integrated with a webserver like TomCat directly????

Any help on this would be appreciatted. My work address is rbrown@dynix and that is where I would like mail to go to. Thanks.

I tried to post this once. Don't think it worked so I read a few posts. One post recommended taking the taglib directives out of the web.xml file. I tried that. It didn't make a difference. The code acts like it knows about jstl.jar and standard.jar but does not know where the .tld files are but doesn't complain at compile time. M apologies if this posts twice.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 20 2005
Added on Mar 22 2005
9 comments
288 views