aspose file tools*
The moose likes Struts and the fly likes Problem facing in Form bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem facing in Form bean" Watch "Problem facing in Form bean" New topic
Author

Problem facing in Form bean

lohith mk
Greenhorn

Joined: Nov 30, 2007
Posts: 6
Hi, i am getting an error when i am accessing the jsp page
the error is Cannot find bean: "org.apache.struts.taglib.html.BEAN"
i am sending the Jsp page ,struts-config.xml, and action class.
please help me in solving this.
The jsp page:

<%@ 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:html>
<head>

<title>Welcome</title>
</head>

<script type="text/javascript">


function validate_form ()
{
valid = true;
if ( document[0].username.value == "" )
{
alert ( "Please input username." );
valid = false;
}
if ( document[0].password.value == "" )
{
alert ( "Please input password." );
valid = false;
}
return valid;
}

</script>
<form action="/test">


<h1><marquee>Welcome to mphasis page</marquee></h1>

Current time:
<%=new java.util.Date()%>

<table width="400" border="1">
<tr>

<td align="left">Username:</td>
<td align="right"><html:text property="username"></html:text></td>
</tr>
<tr>
<td align="left">Password:</td>
<td align="right"><html:text property="password"></html:text></td>
</tr>
<tr>
<td align="left"><html:submit>submit</html:submit></td>
</tr>
</table>

</form>
</html:html>


Action class:

package com.mphasis.action;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;


import com.mphasis.form.LeaveForm;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LeaveAction extends Action
{
public ActionForward execute
(
ActionMapping mapping, ActionForm form,
HttpServletRequest req, HttpServletResponse res
)
throws Exception
{
System.out.println("inside the action class");
LeaveForm form1 = (LeaveForm)form;

return mapping.findForward("sucess");
}

}

Action form :
package com.mphasis.form;

import org.apache.struts.action.ActionForm;

public class LeaveForm extends ActionForm
{
private String username;
private String password;
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}

}

Struts-config.xml:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "C:\struts-config_1_2.dtd">

<struts-config>
<form-beans>
<form-bean
name ="Forms"
type="com.mphasis.form.LeaveForm"/>
</form-beans>

<action-mappings>
<action path="/test"
type="com.mphasis.action.LeaveAction"
name="Forms"
input="/Login1.jsp"
scope="request">
<forward name="sucess" path="/sucess.jsp"/>


</action>
</action-mappings>


</struts-config>

WEB.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<web-app>

<!-- Standard Action Servlet Configuration (with debugging) -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
</servlet-class>
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>validate</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>


<!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/Login1.jsp</welcome-file>
</welcome-file-list>

<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>

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

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

</web-app>

Please help in solving this.
Ramu Valivarthi
Ranch Hand

Joined: Apr 24, 2007
Posts: 37

Have you keep the TLDs inside /WEB-INF/..
lohith micheal
Greenhorn

Joined: Jan 07, 2008
Posts: 11
Originally posted by lohith mk:
Hi, i am getting an error when i am accessing the jsp page
the error is Cannot find bean: "org.apache.struts.taglib.html.BEAN"
i am sending the Jsp page ,struts-config.xml, and action class.
please help me in solving this.
The jsp page:

<%@ 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:html>
<head>

<title>Welcome</title>
</head>

<script type="text/javascript">


function validate_form ()
{
valid = true;
if ( document[0].username.value == "" )
{
alert ( "Please input username." );
valid = false;
}
if ( document[0].password.value == "" )
{
alert ( "Please input password." );
valid = false;
}
return valid;
}

</script>
<form action="/test">


<h1><marquee>Welcome to mphasis page</marquee></h1>

Current time:
<%=new java.util.Date()%>

<table width="400" border="1">
<tr>

<td align="left">Username:</td>
<td align="right"><html:text property="username"></html:text></td>
</tr>
<tr>
<td align="left">Password:</td>
<td align="right"><html:text property="password"></html:text></td>
</tr>
<tr>
<td align="left"><html:submit>submit</html:submit></td>
</tr>
</table>

</form>
</html:html>


Action class:

package com.mphasis.action;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;


import com.mphasis.form.LeaveForm;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LeaveAction extends Action
{
public ActionForward execute
(
ActionMapping mapping, ActionForm form,
HttpServletRequest req, HttpServletResponse res
)
throws Exception
{
System.out.println("inside the action class");
LeaveForm form1 = (LeaveForm)form;

return mapping.findForward("sucess");
}

}

Action form :
package com.mphasis.form;

import org.apache.struts.action.ActionForm;

public class LeaveForm extends ActionForm
{
private String username;
private String password;
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}

}

Struts-config.xml:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "C:\struts-config_1_2.dtd">

<struts-config>
<form-beans>
<form-bean
name ="Forms"
type="com.mphasis.form.LeaveForm"/>
</form-beans>

<action-mappings>
<action path="/test"
type="com.mphasis.action.LeaveAction"
name="Forms"
input="/Login1.jsp"
scope="request">
<forward name="sucess" path="/sucess.jsp"/>


</action>
</action-mappings>


</struts-config>

WEB.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<web-app>

<!-- Standard Action Servlet Configuration (with debugging) -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
</servlet-class>
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>validate</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>


<!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/Login1.jsp</welcome-file>
</welcome-file-list>

<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>

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

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

</web-app>

Please help in solving this.


Thanks guys ,
i have solved the problem.
there was a mistake in .class files.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem facing in Form bean