facebook

JSTL headaches

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #251396 Reply

    fermataintl
    Member

    I have a struts/jstl enabled project that somehow lost the ability to process jstl. I’m sure I did something to cause this to happen, but I don’t know what it is or how to undo it. In order to prove that the jstl processing was broken, I created an Action that stuffed a String into the request as follows: request.setAttribute(“foobar”, “This is foobar”); And I created a bogus jsp file that had the following: <c:out value=”${foobar}”> in it, and it printed out ${foobar} literally.

    I also ran into another problem while trying to solve this one. I created a new project with just the Action and JSP I referred to above in it. It worked like its supposed to so I started floating all of the code from the original project into the new project. I use a few extra jars, such as lucene, so I put those into the new project main directory and added them via the project properties dialog. There were no errors showing, but when I deployed to tomcat via myeclipse, I noticed that the extra jars (e.g., lucene) did not get copied into the lib directory. Somehow, in the original project, I had it set up so that the extra jars got copied into the deployment lib directory.

    Can someone explain how to fix these?

    Thanks.
    Dean

    #251408

    Riyad Kalla
    Member

    Dean,
    The difference most likely could be that one project is J2EE 1.3 and the other is J2EE 1.4. By default EL is ignored in 1.3 projects and processed in 1.4 projects. More specifically, if your web.xml file uses a DTD (version 2.3) at the top EL is ignored unless specified to be processed, in Web 2.4 (schema) the EL is processed.

    Now, as to why your libs aren’t being copied, make sure your projects are fully refreshed from the root (right click, refresh). Also make sure they rebuild cleanly without errors (Project > Clean). Lastly, make sure that the deployment settings are the same, under Project Properties > MyEclipse-Web > Deployment. You could have had your first project setup to deploy external libs and the second one not to, or something like that.

    #251411

    fermataintl
    Member

    Thanks for the quick reply. Regarding the web.xml (in the original project) I removed the DOCTYPE statement in the web.xml file. It it still outputing ${foobar}. I am running eclipse 3.1 on windows Xp with MyEclipseIde version 4.1.1 GA. Here are the important parts:

    <web-app>
      <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
        <init-param>
          <param-name>config</param-name>
          <param-value>/WEB-INF/struts-config.xml</param-value>
        </init-param>
        <init-param>
          <param-name>debug</param-name>
          <param-value>3</param-value>
        </init-param>
        <init-param>
          <param-name>detail</param-name>
          <param-value>3</param-value>
        </init-param>
        <load-on-startup>0</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
      </servlet-mapping>
      
     ...
    
    </web-app>

    Here’s my Action:

       public ActionForward execute(
            ActionMapping mapping,
            ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response) {
    
            // TODO Auto-generated method stub
            request.setAttribute("foobar", "This is foobar");
            return mapping.findForward("go");
        }

    My JSP:

    <%@ page language="java" pageEncoding="UTF-8"%>
    <%@ taglib uri="/tags/struts-html" prefix="html" %>
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
    <html:html xhtml="true">
    <html:xhtml/>
    <head> 
    <title>bar.jsp</title>
    </head>  
    <body>
    <c:out value="${foobar}"/>
    </body>
    </html:html>

    What should I try next?

    Dean

    #251412

    Riyad Kalla
    Member

    You can’t just remove that, it’s an important part of that file.

    But since you already did remove it, try putting this at the top:

    
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    

    But that right at the top, overwrite the <xml> tag if you already have one.

    #251413

    fermataintl
    Member

    I did that put now there are complaints about my taglib tag sets just before the end of </web-app>

    #251414

    Riyad Kalla
    Member

    they need to be wrapped in <jsp-config></jsp-config> tags

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: JSTL headaches

You must be logged in to post in the forum log in