Solved

<html:form> tag gives me headache!!!!!

Posted on 2004-08-10
6
978 Views
Last Modified: 2012-06-21
Problem #1
========
I am having a jsp compilation problem when I replace <FORM...>..</FORM> with <html:form...></html:form>. It seems <html:form> looks for struts-config information during the jsp compile time (attempting to link the corresponding ActionForm class). The servlet threw an exception as following:

javax.servlet.ServletException: Cannot find ActionMappings or ActionFormBeans collection
      org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
      org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
      org.apache.jsp.login_jsp._jspService(login_jsp.java:88)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)

root cause

javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
      org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:798)
      org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:506)
      org.apache.jsp.login_jsp._jspx_meth_html_form_0(login_jsp.java:140)
      org.apache.jsp.login_jsp._jspx_meth_html_html_0(login_jsp.java:114)
      org.apache.jsp.login_jsp._jspService(login_jsp.java:78)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)



Problem #2
=========
ok. I am using the old <FORM...>..</FORM. for the monment....

1. I placed the following statement in my jsp file.
<bean:message key="loginForm.label.readerid"/>
2. Add the following statement at the bottom of my struts-config.xml
<message-resources parameter="ApplicationResources" null="false" />
3. create an ApplicationResources.properties and place it into /WEB-INF/classes directory.

the servlet threw a different exception during the jsp compilation...

javax.servlet.ServletException: Cannot find message resources under key org.apache.struts.action.MESSAGE
      org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
      org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
      org.apache.jsp.login_jsp._jspService(login_jsp.java:79)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)

root cause

javax.servlet.jsp.JspException: Cannot find message resources under key org.apache.struts.action.MESSAGE
      org.apache.struts.util.RequestUtils.retrieveMessageResources(RequestUtils.java:1103)
      org.apache.struts.util.RequestUtils.message(RequestUtils.java:1043)
      org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java:294)
      org.apache.jsp.login_jsp._jspx_meth_bean_message_0(login_jsp.java:178)
      org.apache.jsp.login_jsp._jspx_meth_html_html_0(login_jsp.java:115)
      org.apache.jsp.login_jsp._jspService(login_jsp.java:69)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)


Any info would be grateful. Many thanks.
Poor soul
0
Comment
Question by:zollen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 9

Accepted Solution

by:
nimaig earned 100 total points
ID: 11769922
Check for these if you have done it correctly :

1. You must have struts-config.xml
2. The path of the struts-config.xml must be specified in web.xml as init-param for ActionServlet.
            <init-param>
                        <param-name>config</param-name>
                        <param-value>/WEB-INF/struts-config.xml</param-value>
        </init-param>
3. When you use <html:form...> </html:form>, you must have the action property defined.
4. This action entry must be available in struts-config.xml.
5. All the related classes must be in the classpath.
6. If you have only applicationresource.properties file then it is better to specify it in web.xml
            <init-param>
                  <param-name>application</param-name>
                  <param-value>com.resource.ApplicationResources</param-value>
    </init-param>
   
    You can put it in struts config.xml aswell
   
    <message-resources key="MESSAGE_KEY" parameter="com.resource.ApplicationResources"/>
   
    here ApplicationResources.properties is lying in 'WEB-INF/classes/com/resource' directory.
    Don't put ApplicationResources.properties directly in the classes as struts fails to pick it up.
    Put it in some directory under classes.
7. The message you are trying to get in .jsp page but be defined in ApplicationResources.properties.
   
   

0
 
LVL 1

Expert Comment

by:quddhus
ID: 11772492
<%@ taglib uri="WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri = "WEB-INF/struts-logic.tld" prefix = "logic"%>

<html>
<title>Test Form</title>
<body>
    <html:form name='UserLoginForm' action='/processForm.do' method='post'>
     ................
     ................
     </html:form>
</body>
</html>

The UserLoginForm.java should be defined in struts-config.xml
<form-bean name="UserLoginForm" type="com.test.UserLoginForm"/>

Also action tagshould be defined
<action name="UserLoginForm" path="/processForm"
             scope="request" type="com.test.UserLoginAction">
             <forward name="success" path="/welcome.jsp"/>
             <forward name="failure" path="/relogin.jsp"/>
</action>

All the best...


0
 
LVL 9

Expert Comment

by:nimaig
ID: 11773320
Check for 'WEB-INF' directory. It must be uppercase and not 'web-inf'
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:KarcOrigin
ID: 11780360
Hi,
Could you please send struts-config file contents.
Karc
0
 

Author Comment

by:zollen
ID: 11784956
I have solved the problems! struts-config information must be availabe before the execution of <html:form> tag. Therefore ActionServlet must be loaded on startup first.


Login authentication is obviously done in LoginAction class. If a "login failure" msg need to be printed by <html:errors/>, can I create an ActionError object in LoginAction class? if so, how to use ActionError object in LoginAction class?

 
0
 

Author Comment

by:zollen
ID: 11785032
How could I use ActionMessage object in LoginAction??
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here's how to start interacting with our community through Post.
Microsoft is moving in-place eDiscovery & hold from ECP to EOP console under Content Search in Search and Investigation Options.  In this post, I will be showing you how to export emails to a PST file using the Content Search Options.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question