Results 1 to 10 of 13

Thread: <fmt:message> tag problem in my JSP document

Hybrid View

  1. #1

    Default <fmt:message> tag problem in my JSP document

    In my spring MVC application i have provided i18n option by providing a messageSource in the form of a properties file.

    And i am using the keys provided in this properties file in my jsp pages using the jstl's custom tag library having URI : http://java.sun.com/jsp/jstl/fmt, i.e
    with the following syntax :<fmt:message key="key1" />

    Now i am using this in my welcome page as well as one of my forms.

    The problem i am facing is in my welcome.jsp page i am not getting the key1's value instead i am getting the value as ???key1???.

    While in my second form i am getting the key2's value without any problem.

    Can anybody please let me know what is getting wrong??

    Thanks.

  2. #2
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    Hello j.gohel

    i had the same problem, first check this
    you should have the bold line

    Code:
    <bean id="viewResolver"
       	class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    	<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> 
        	<property name="prefix" value="/WEB-INF/jsp/" />
        	<property name="suffix" value=".jsp"/>
      	</bean>
    second, try with this uri <%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %> (i work with it) , notice that no has the jsp part, instead of your uri

    While in my second form i am getting the key2's value without any problem.
    maybe this use my uri

    regards
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  3. #3

    Default

    Hello,

    I already have that content in bold in my xxx-servlet.xml file for spring application.And i tried second option also but still the problem persists that is in the index page the key's value form the messageSource is not getting displayed while in other form it is..
    How to solve this...

    Thanks.

  4. #4
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    Hello j.gohel

    can you copy your 2 jsp files and the messageSource file?

    it is weird

    regards
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  5. #5

    Default <fmt:message> tag

    This is my index.jspx page
    Code:
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0" 
    		  xmlns:c="http://java.sun.com/jsp/jstl/core"
    		  xmlns:fmt="http://java.sun.com/jstl/fmt"	>
        <jsp:directive.page language="java"
            contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" />
        <jsp:text>
            <![CDATA[ <?xml version="1.0" encoding="ISO-8859-1" ?> ]]>
        </jsp:text>
        <jsp:text>
            <![CDATA[ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> ]]>
        </jsp:text>
        
    
    	<html xmlns="http://www.w3.org/1999/xhtml">
    	<head>
    	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    	<title><fmt:message key="indexPageTitle"/></title>
    	</head>
    	<body>
    		<h3>Welcome </h3>
    		<c:set var="url" value="./usermngr.htm"></c:set>
    		<a href="${url}">Users</a>
    	</body>
    	</html>
    </jsp:root>

    This is my another registrationForm.jspx file(In this the keys' values are getting displayed getting ):

    Code:
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
    		   xmlns:c="http://java.sun.com/jsp/jstl/core"
    		  xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"	
    		  xmlns:spring="/spring">
    
        <jsp:directive.page language="java"
            contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" />
        <jsp:text>
            <![CDATA[ <?xml version="1.0" encoding="ISO-8859-1" ?> ]]>
        </jsp:text>
        <jsp:text>
            <![CDATA[ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> ]]>
        </jsp:text>
        
    	<html xmlns="http://www.w3.org/1999/xhtml">
    	<head>
    		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    	</head>
    	<body>
    		
    		<form action="post" name="userRegistrationForm">
    			<fieldset>
    					<legend><fmt:message key="piLegendLabel"/></legend>
    					<table cellpadding="5%" cellspacing="5%">
    						<tr>
    							<td><fmt:message key="firstNameLabel"/></td>
    									<td> <input type="text" name="emp_firstName" maxlength="100" size="15" /></td>
    								<td><fmt:message key="middleNameLabel"/></td>
    								<td> <input type="text" name="emp_middleName" maxlength="100" size="15" /></td>
    									<td><fmt:message key="lastNameLabel"/></td>
    	<td> <input type="text" name="emp_lastName" maxlength="100" size="15" /></td>
    								</tr>
    			
    	<tr>			
    							<td><fmt:message key="dobLabel"/></td>
    									<td> <input type="text" name="emp_dob" maxlength="11" size="11" readonly="true" /> </td>
    									</tr>
    	</table>
    	</fieldset>
    	</body>
    	</html>
    </jsp:root>

    MessageResourceBundle.properties contents:

    Code:
    indexPageTitle=EIS
    registrationFormTitle=Registration Form
    
    
    #Personal Information Labels
    piLegendLabel=Personal Information
    firstNameLabel=First Name :
    middleNameLabel=Middle Name :
    lastNameLabel=Last Name :
    dobLabel=Date Of Birth :
    Please let me know if anything wrong..

    Thanks

  6. #6
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    ok man

    based in this
    While in my second form i am getting the key2's value without any problem.
    your first jsp use this
    Code:
    xmlns:fmt="http://java.sun.com/jstl/fmt"
    and no works

    and the second use this

    Code:
    xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
    and works

    well in your case instead of me, your uri work with the jsp, so
    use
    Code:
    xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
    in your first jsp file

    it should be enough

    regards
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

Posting Permissions

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