4 Replies Latest reply on Jun 23, 2006 3:47 AM by Martin Thorpe

    jsp 2 output a variable

    Martin Thorpe Newbie

      Hello I am totally new to JSP and JBoss and am running through a good tutorial that I have found.

      I can get it all to work apart from outputting a variable using JSTL/jsp 2.. not sure what part it is that is not working:

      I am outputting this:
      <c:out value="${emp.name}"/>

      but all that is displayed to the screen is ${emp.name}

      I get no errors just no display.

      I asked on Java Ranch and was told to update the declaration in my web-xml file to enable JSP2, which I have done to this:

      <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
       xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">

      But now when starting the server I get deployment errors such as this:
      org.xml.SAXParseException: The prefix "xsi" for attribute "xsi:schemaLocation" associated with element "web-app" is not bound.
      at org.apache.xerces.parsers.DOMparser.parse (Unknown source)
      at org.apache.xerces.jaxp.DocumentBuilderImpl.parse (Unknown source)
      at org.jboss.metadata.XMLFileLoader.getDocument(XMLFileLoader.java:328)

      I am running J-Boss 4.0.4 on a windows machine.

      Thanks for reading.


        • 1. Re: jsp 2 output a variable
          Peter Johnson Master

          I am using jstl in my jsps. I don't have any extra stuff added to the web-app token in my web.xml file. But the following works for me.

          In my jsps, I have the lines:

          <%@ taglib prefix="f" uri="http://java.sun.com/jstl/fmt"%>
          <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
          <h1><c:out value="${some.text}" /></h1>

          In my servlet, I have some code that looks like:

          request.setAttribute("some", obj);

          where obj is an object of a class that has a getText method.

          Then, I have both standard.jar and jstl.jar in my WEB-INF/lib directory.

          • 2. Re: jsp 2 output a variable
            Martin Thorpe Newbie

            Hello I got it sorted in the end, the declaration I had in web.xml was incorrect.

            Thank you for taking the time to read and reply though.


            • 3. Re: jsp 2 output a variable
              Peter Johnson Master

              Just out of curiousity, what did you have in web.xml and how did you correct it? What I am wondering is if you have any taglib descriptors and if that is what you changed. The reason I ask is that you really don't need any taglib descriptors in web.xml, the two lines declaring the taglib in the jsp files are sufficient.

              • 4. Re: jsp 2 output a variable
                Martin Thorpe Newbie


                Yes I do have taglib descriptors in the web.xml, but, I did not change these. The problem was that I had a typo in the declaration, when copy pasting it the typo was corrected.

                I am using the JSTL style of output being

                <c:out value="${message}"/>

                and it is working fine.

                Thanks for replying