Solved

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

Posted on 2004-08-10
6
933 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
When Does RestAdapter establishes HttpConnection 5 199
method inner class 6 81
memory representation of int[][][] a=new int[2][][]; 10 59
spring JDBC Template example error 26 206
Often, people trade privacy and security for convenience. However in today's concrete jungle, this is an extremely foolish decision considering the vast amount of technologies being used against consumer interest. First off, I won't waste any time e…
Scenario: Your operations manager has discovered an anomaly in your security system. The business will start to suffer within 15 minutes if it is a major IT incident. What should she do? We have 6 recommendations for managing major incidents (https:…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

932 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now