Announcement Announcement Module
Collapse
No announcement yet.
Problem with fmt tag for login page Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with fmt tag for login page

    In my app I am using a fmt tag to display the title of the webpages. The title is the same for all the pages. My problem is that I get an error when the login page is displayed. The error that is displayed in the title is {code}???title???{code}.

    I have put some relevant code for login.jsp below:

    Code:
    <%@ include file="include.jsp" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
       <title><fmt:message key="title" /></title>
    </head>
    include.jsp
    Code:
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    web.xml

    Code:
    <jsp-config>  
        <taglib>
          <taglib-uri>/fmt</taglib-uri>
          <taglib-location>/WEB-INF/tld/fmt.tld</taglib-location>
        </taglib>
      </jsp-config>

    I have put fmt.tld in the /WEB-INF/tld folder.

    My messages are located in WEB-INF/classes/messages.properties

    All the other titles are OK...

    Can anyone understand why this happens?

    I am using netbeans 6.1, spring 2.5 and acegi.
    Last edited by vator; Aug 23rd, 2008, 05:12 AM.

  • #2
    where do you say that "messages" is the basename of your resource?

    Comment


    • #3
      I have declared it in my dispatcher-servlet

      dispather-servlet.xml

      Code:
      <bean id="messageSource" 
              class="org.springframework.context.support.ResourceBundleMessageSource">
          <property name="basename"><value>messages</value></property>
        </bean>
      Is that where it should be?

      I kind of got the feeling that when the the login page is first shown the code above is not run. It's a bit weird that the title is set correctly when I log in...
      Last edited by vator; Sep 3rd, 2008, 10:52 AM.

      Comment


      • #4
        It's probably that your call to login.jsp (via Acegi) is not configured to go through the Spring Dispatcher servlet. Try configuring Acegi to use "login.do" or whatever URL is appropriate for your Spring configuration.

        Comment


        • #5
          I guess you're right...
          web.xml initializes the applicationContext-acegi-security.xml.

          web.xml
          Code:
          <context-param>
              <param-name>contextConfigLocation</param-name>
              <param-value>
                /WEB-INF/applicationContext-acegi-security.xml
                /WEB-INF/applicationContext-jdbc.xml
              </param-value>
            </context-param>
          Then the exceptionTranslationFilterit redirects to /jsp/user/login.jsp. And on the way the dispatcher-servlet is not executed?

          applicationContext-acegi-security.xml
          Code:
          <bean id="exceptionTranslationFilter" 
          class="org.acegisecurity.ui.ExceptionTranslationFilter">
              <property name="authenticationEntryPoint">
                <bean 
          class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint">
                  <property name="loginFormUrl" value="/jsp/user/login.jsp"/>
                  <property name="forceHttps" value="false"/>
                </bean>
              </property>
            </bean>
          dispatcher-servlet
          Code:
           <bean id="messageSource" 
           class="org.springframework.context.support.ResourceBundleMessageSource">
              <property name="basename"><value>messages</value></property>
            </bean>
          where messageSource is initialized...
          Is that right? What can I do to fix it?

          Comment


          • #6
            That's right (and, in my experience, a very common issue with Spring MVC + Acegi apps). Just like any other JSP, you'll need to map it to a controller. Just be careful about how you configure Acegi authentication so that this controller and/or URL is accessible to non-authenticated users and you should be fine.

            Comment


            • #7
              I just changed the loginFormUrl to /login.do.
              I think it works!!! Thanks.

              Code:
              <bean id="exceptionTranslationFilter" class="org.acegisecurity.ui.ExceptionTranslationFilter">
                  <property name="authenticationEntryPoint">
                    <bean class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint">
                      <property name="loginFormUrl" value="/login.do"/>
                      <property name="forceHttps" value="false"/>
                    </bean>
                  </property>
                </bean>

              Comment

              Working...
              X