• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts tags not working: html tag & bean tag

 
Jay Reddy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<bean:message> tag is not working
(<html:link > is also not working either)


--------------------------ENVIRNOMENT
Eclipse Version: 3.3.2 (J2EE Preview server)
jakarta-struts-1.2.2
jre1.6.0 (1.5? in the build path)


--------------------------struts-config.xml
.....
<message-resources parameter="/com.main.MessageResources.properties" null="false" />

</struts-config>


KEY in the (MessageResources.properties) file:
prompt.customer.firstname=First Namelabel

-------------------------- web.xml
...
<jsp-config>

<taglib>
<taglib-uri>/tags/struts-bean</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/tags/struts-html</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld </taglib-location>
</taglib>
.......
</jsp-config>


</web-app>

-------------------------- error message:
Apr 19, 2008 5:09:46 PM org.mortbay.jetty.servlet.ServletHandler handle
WARNING: EXCEPTION
org.apache.jasper.JasperException: Exception in JSP: /customerDetails.jsp:19

16:
17: <form name="custFrom" action= "/Struts1/submitCustomerForm.do" />
19: <bean:message key="prompt.customer.firstname"/>:
<!-- the below normal html tag works fine-->

First name: <input type="text" name="firsttName" calue = "">
<input type="text" name="firstName" value ="" />
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In some version of Struts, the name attribute of the html:form tag is deprecated. I'd suggest you remove it.
 
mahmoud allam
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
could you please put the complete jsp code
 
Ilari Moilanen
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm only guessing here since the exception is not very informative but maybe the messageresources file is not found. Tomcat would show better exception where it would read what the problem is.

In any case your config file looks like this
<message-resources parameter="/com.main.MessageResources.properties" null="false" />

whereas in one application I'm developing it looks like this
<message-resources parameter="MessageResources" />

so there are no leading "/" or "com.main" and the ".properties" is omitted also. My MessageResources.properties file is located in classes folder.

Hope this helps.
 
Jay Reddy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mahmoud, here is the JSP code:

//----------------
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

<html:html>
<head> <html:base/> </head>
<html:errors/>
<body>
(- tags-no ) This is custoemrformDetails2-jsp

<html:form action="submitCustomerForm2.do" method="POST">

<bean:message key= "prompt.customer.firstname"/>
<html:text property="firstName"/>

<bean:message key= "prompt.customer.lastname"/>
<html:text property="lastName"/>

<html:submit>
<bean:message key= "button.submit" />
</html:submit>

<html:cancel>
<bean:message key= "button.cancel" />
</html:cancel>

</html:form>

</body>
</html:html>
//-------------------------- Error message


Apr 23, 2008 10:00:48 PM org.mortbay.jetty.servlet.ServletHandler handle
WARNING: EXCEPTION
org.apache.jasper.JasperException: Exception in JSP: /customerDetails2.jsp:14

11: <body>
12: (- tags-no ) This is custoemrformDetails2-jsp
13:
14: <html:form action="submitCustomerForm2.do" method="POST">
15:
16: <bean:message key= "prompt.customer.firstname"/>
17: <html:text property="firstName"/>


Stacktrace:
Stacktrace:
at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
...
WARNING: EXCEPTION
javax.servlet.ServletException: Cannot find ActionMappings or ActionFormBeans collection
at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
at org.apache.jsp.customerDetails2_jsp._jspService(customerDetails2_jsp.java:94)
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See question 13 of this forum's FAQ.
 
Jay Reddy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Merril Thanks a lot.
I fixed the Action mapping issue based on Struts-FAQs 13 you suggested.
But still uable to display the values of the keys

----------Bean:message is displaying(key names, not the values):

???en_US.prompt.customer.firstname??? ???en_US.prompt.customer.lastname???
???en_US.button.submitt???
???en_US.button.cancel???

----------in the properties file:
prompt.customer.firstname=First Namelabel
prompt.customer.lastname=Last Namelabel
button.submit= Submit ME
button.cancel= Cancel ME

----------Stuts-config.xml:
<message-resources parameter="com/main/MessageResources.properties" null="false" />

-------------- JSP
<html:form action="submitCustomerForm2.do" method="POST">

<bean:message key= "prompt.customer.firstname"/>
<html:text property="firstName"/>

<bean:message key= "prompt.customer.lastname"/>
<html:text property="lastName"/>

<html:submit>
<bean:message key= "button.submit" />
</html:submit>

<html:cancel>
<bean:message key= "button.cancel" />
</html:cancel>

</html:form>


Thanks,
Jay
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's your entry in the struts-config.xml file that's causing the problem. Omit the ".properties" from the parameter value, even though the file itself should have ".properties" extension. Then make sure that the MessageResources.properties file is in the WEB-INF/classes/com/main folder.
 
Jay Reddy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Merrill,
Thank you very much.
The application is working fine after I removed (.properteis) suffix in the struts-config.xml file.
JAY
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic