Results 1 to 7 of 7

Thread: Problem with fmt tag for login page

  1. #1

    Default 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 at 05:12 AM.

  2. #2
    Join Date
    May 2008
    Location
    Haddonfield, NJ 08033
    Posts
    46

    Default

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

  3. #3

    Default

    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 at 10:52 AM.

  4. #4
    Join Date
    Sep 2004
    Location
    Manchester, NH
    Posts
    1,236

    Default

    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.
    Peter Mularien | Blog
    Author, Spring Security 3 (Book) - Packt Publishing, Available in print and eBook form
    SCJP 5, Oracle DBA
    Any postings are my own opinion, and should not be attributed to my employer or clients.


  5. #5

    Default

    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?

  6. #6
    Join Date
    Sep 2004
    Location
    Manchester, NH
    Posts
    1,236

    Default

    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.
    Peter Mularien | Blog
    Author, Spring Security 3 (Book) - Packt Publishing, Available in print and eBook form
    SCJP 5, Oracle DBA
    Any postings are my own opinion, and should not be attributed to my employer or clients.


  7. #7

    Default

    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>

Posting Permissions

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