participate


Reflections & Reference Objects - Struts problem
<<   Back to Forum  |   Give us Feedback
This topic has 3 replies on 1 page.
danielsobrado
Posts:32
Registered: 12/2/02
Struts problem   
Dec 17, 2002 3:46 AM

 
I have some problems with STRUTS and TOMCAT 4.0.6, the examples are running, I have this directory:

NewForm/
WEB-INF/
classes/
Daniel/
ApplicationResources.PROPERTIES
TenantForm1.class
lib/
struts.jar
app.tld
struts-bean.tld
struts-form.tld
struts-form.tld
struts-html.tld
struts-logic.tld
struts-template.tld
struts-config.xml
web.xml
Form1.jsp

In Form1.jsp I have this:
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/app.tld" prefix="app" %>
<%@ 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>
Tenant
</title>
</head>

<body>
<html:errors/>
<html:text property="firstname" size="16"/>
<html:text property="surname" size="16"/>
<html:text property="position" size="16"/>
<html:text property="email" size="16"/>
</body>
</html:html>

I get this error:
javax.servlet.ServletException: Cannot find bean org.apache.struts.taglib.html.BEAN in scope null

AnyOne can help me????

Here 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>

<!-- Action Servlet Configuration -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>TenantForm1</param-name>
<param-value>Daniel.TenantForm1</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>


<!-- Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

<!-- 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>



And struts-config.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">

<struts-config>

<!-- ========== Form Bean Definitions =================================== -->
<form-beans>

<!-- Registration form bean -->
<form-bean name="TenantForm1"
type="Daniel.TenantForm1"/>
</form-beans>
<!-- ========== Action Mapping Definitions ============================== -->
<action-mappings>

<!-- Save user registration -->
<action path="/TenantForm1"
type="Daniel.TenantForm1"
name="TenantForm1"
scope="request"
input="/Form1.jsp"/>

</action-mappings>

</struts-config>
 
RMacM
Posts:17
Registered: 8/8/02
Re: Struts problem   
Dec 17, 2002 4:20 AM (reply 1 of 3)  (In reply to original post )

 
From your directory structure it seems that you have not stored your struts-.tld files in WEB-INF but in the root directory. It seems that when referencing your tag libraries in your JSP it is not able to locate them. Move all of the struts-.tld into WEB-INF and try again.
 
sage_sam
Posts:380
Registered: 3/10/00
Re: Struts problem   
Dec 17, 2002 9:48 AM (reply 2 of 3)  (In reply to original post )

 
The input field tags (such as <html:text />) MUST be used within
a form object, i.e.

<html:form>
<html:text />
</html:form>

Otherwise, the input field tag will not be able to find the bean
whose property they are to retrieve for their default value, or set
when the form is submitted. Otherwise, you will have the exact
problem you describe. It can't invoke (or look up) methods on a
null object. =)

In your case, your form should be

<html:form action="/TenantForm1.do">
 
ergindemirel
Posts:13
Registered: 7/22/04
Re: Struts problem solutions   
Jul 26, 2004 1:51 AM (reply 3 of 3)  (In reply to #2 )

 
I used to have same problem in my database application , But I fixed it.
I have some advice to you ;

1-) Be careful about naming conventions of variables : In struts you should define your form elements in lower case letters. Otherwise there will be errors on your getters and setter.
Example : You should define private String VehicleType as private String vehicletype (***)

2-) you have to indicate form tag before your text tags .
Example :
<html:form action="detail.do">
Id <html:text property="employeeid"/><br>
Name and Surname <html:text property="employeename"/><br>
</html:form>
, not like
Id <html:text property="employeeid"/><br>
Name and Surname <html:text property="employeename"/><br>

Even these seems as silly mistakes ,these are very important for struts programmers .
that's all I've tell about it.

Good Luck ..
 
This topic has 3 replies on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics

About Sun forums
  • Oracle Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Oracle Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums