Page 1 of 2 12 LastLast
Results 1 to 10 of 13

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

  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,791

    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,791

    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,791

    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

  7. #7

    Default

    No changing it also didn't worked.
    Is there any problems related with JSP documents(.jspx file)???I am guessing this because when both of these pages were in.jsp form they worked nicely.

    When i converted to .jspx the problems are arising.This is the same thing i am facing using form tag library in my .jspx page.There is a thread posted by me for the same in this forum for same.The same form tag library when i am using in a .jsp page it is working fine...

    Please let me know are there any problems in using .jspx pages over .jsp
    pages.

    Thanks

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

    Default

    sorry about that

    i never worked with .jspx files so i cant help you here,

    BTW when you work only with jsp files you said that works, tell me, which uri you use???

    a suggestion, maybe the <bean id="viewResolver" needs a special class for the jspx, really i dont know, i am telling you this, because the examples is for jsp files and not for jspx files, maybe you need one change or add something else

    and i dont know if is correct that 2 jsp files can work with 2 differents uri's, if i try this, i recieve an error message

    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

  9. #9

    Default

    Hello ,

    I thing i got it where problem is .

    See this is the snippet in my xxx-servlet.xml application configuration file.:

    Code:
    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    		<property name="viewClass">
    			<value>org.springframework.web.servlet.view.JstlView</value>
    		</property>
    		<property name="prefix">
    			<value>/usermodule/jsps/</value>
    		</property>		<property name="suffix">
    			<value>.jspx</value>
    		</property>
    	</bean>


    I think the line in the bold is causing index.jspx to not to use internationalization messages.

    Because i have project structure like this:

    Code:
    AppName
        index.jspx
        usermodule
             jsps
             js
        WEB-INF
             classes
             lib
             tlds
    ...

    So if my guess is correct then how to rectify this thing...
    Last edited by j.gohel; Jan 30th, 2007 at 02:21 AM.

  10. #10
    Join Date
    Feb 2007
    Posts
    4

    Default

    J.gohel

    I think I got the same problem as you describen in this thread.
    I'm not sure if I understood finally what was the problem and what the solution.
    Please, tell me if I got it right:
    - The problem is that ONLY the JSPs that are located in the folder specified in the "prefix" property of the "viewResolver" bean get the <fmt:message> resolved right??

    - The solution is to place all JSPs under the same folder specified in that property?


    Thank you in advance,
    Geez

Posting Permissions

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