Announcement Announcement Module
Collapse
No announcement yet.
Step-by-step tutorial - wrong output Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Step-by-step tutorial - wrong output

    Hello
    I'm exploring the framework by going through the step-by-step tutorial.

    I have completed step 14 (Improve the view and the controller), but it doesn't work as it should.

    I'm positive that i have the right source (used cut'n'paste), but when i try to run the application i get the output

    Greetings, it is now ${now} instead of the time and date which it should display.

    I don't want to continue the tutorial before i've found the sollution for this.
    Can someone give me a hint what may be wrong?

    Regards
    Per

  • #2
    Correct config?

    I got this working yesterday with Tomcat. Have you copied the whole of the updated springapp-servlet.xml? What URL are you using - have you tried not specifying hello.htm (since index.jsp will get run by default)? Does SpringappController put the time in "now" properly? It works for me anyway (Tomcat 5, J2SDK 1.4.2, Spring 1.1 rc2)

    Comment


    • #3
      The index.jsp is redirecting to hello.thm

      The servlet places the time in now

      this is my web.xml:
      <?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>
      <servlet>
      <servlet-name>springapp</servlet-name>
      <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
      <load-on-startup>1</load-on-startup>
      </servlet>

      <servlet-mapping>
      <servlet-name>springapp</servlet-name>
      <url-pattern>/hello.htm</url-pattern>
      </servlet-mapping>

      <welcome-file-list>
      <welcome-file>
      index.jsp
      </welcome-file>
      </welcome-file-list>
      <taglib>
      <taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
      <taglib-location>/WEB-INF/lib/META-INF/fmt.tld</taglib-location>
      </taglib>
      <taglib>
      <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
      <taglib-location>/WEB-INF/lib/META-INF/c.tld</taglib-location>
      </taglib>
      </web-app>

      This is my springapp-servlet.xml:
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

      <!--
      - Application context definition for "springapp" DispatcherServlet.
      -->

      <beans>
      <bean id="springappController" class="SpringappController"/>

      <bean id="urlMapping" class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
      <property name="mappings">
      <props>
      <prop key="/hello.htm">springappController</prop>
      </props>
      </property>
      </bean>
      </beans>

      This is my hello.jsp:
      <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%><%@ include file="/WEB-INF/jsp/include.jsp" %>

      <html>
      <head><title>Hello :: Spring Application</title></head>
      <body>
      <h1>Hello - Spring Application</h1>
      <p>Greetings, it is now <c:out value="${now}" />
      </p>
      </body>
      </html>

      This is my include.jsp:
      <%@ page session="false"%>

      <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
      <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>

      when accessing http://localhost:8080/springapp the browser is redirected to hello.htm which display this output:
      Hello - Spring Application
      Greetings, it is now ${now}

      Comment


      • #4
        Logging?

        Seems ok to me (fellow Spring newbie tho) - have you tried looking in your logs to see if the SpringappController logs ok? Unloaded/cleaned/recompiled/installed your webapp?

        Comment


        • #5
          The logs seems ok and yes, i have reloaded and reinstalled the application many times

          --
          Per

          Comment


          • #6
            can you post your controller code?

            Comment


            • #7
              The controller code is the same as in the tutorial.

              I fount the sollution:
              If using Tomcat 5, you have to put this line in the jsp:

              <%@ page isELIgnored="false"%>

              This did the trick, and i'm now getting the output i want

              Comment


              • #8
                Originally posted by jconsult
                The controller code is the same as in the tutorial.

                I fount the sollution:
                If using Tomcat 5, you have to put this line in the jsp:

                <%@ page isELIgnored="false"%>

                This did the trick, and i'm now getting the output i want
                This is interesting. I am using Tomcat 5 and just completed the tutorial. I do not have this line in any of my jsp pages. Why do you think this helped you, but I didn't need it?

                Comment

                Working...
                X