Results 1 to 8 of 8

Thread: Step-by-step tutorial - wrong output

  1. #1
    Join Date
    Sep 2004
    Posts
    5

    Default 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. #2
    Join Date
    Aug 2004
    Posts
    15

    Default 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)

  3. #3
    Join Date
    Sep 2004
    Posts
    5

    Default

    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}

  4. #4
    Join Date
    Aug 2004
    Posts
    15

    Default 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?

  5. #5
    Join Date
    Sep 2004
    Posts
    5

    Default

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

    --
    Per

  6. #6
    Join Date
    Aug 2004
    Location
    London, UK
    Posts
    339

    Default

    can you post your controller code?
    Darren Davison.
    Public Key: 0xE855B3EA

  7. #7
    Join Date
    Sep 2004
    Posts
    5

    Default

    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

  8. #8
    Join Date
    Sep 2004
    Location
    North Carolina
    Posts
    38

    Default

    Quote 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?

Similar Threads

  1. Replies: 7
    Last Post: Nov 24th, 2008, 04:59 AM
  2. Step By Step Tutorial and NetBeans
    By spamblot in forum Web
    Replies: 3
    Last Post: Apr 4th, 2007, 11:07 AM
  3. Beandoc crashing (on its samples!)
    By aaime in forum Container
    Replies: 17
    Last Post: Oct 7th, 2005, 07:21 AM
  4. MVC step by step
    By jfarango in forum Web
    Replies: 4
    Last Post: Jul 15th, 2005, 02:43 PM
  5. newbie question MVC Step by step errors
    By mcgyver5 in forum Web
    Replies: 4
    Last Post: Feb 11th, 2005, 12:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •