• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Problem facing in Form bean

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 37
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you keep the TLDs inside /WEB-INF/..
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic