Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-08-10
6
Medium Priority
?
1,036 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 400 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
There can be many situations demanding the conversion of Outlook OST files to PST format and as such, there is no shortage of automated tools to perform this conversion. However, what makes Stellar OST to PST converter stand above the rest? Let us e…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Loops Section Overview

916 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