Question : javax.servlet.jsp.JspException: Cannot retrieve definition for form bean null on action

hi,

I am pagination using struts but i am getting some problem.please find the attached files in the zip format.iam getting following error.i am newbie in struts.

my intention is  checked values shoulbe be retrieved in the action class.

javax.servlet.jsp.JspException: Cannot retrieve definition for form bean null on action example.do



example.jsp
*************
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html>
<head>
	<html:base />
	<title>example.jsp</title>
	<script  type="text/javascript" language="javascript">
 
 var temp = new Array();
 
  function checkForm( id ) {
    var form = document.getElementById( id );
    if ( form ) {
      var result = '', comma = '';
      for ( var i = 0; i < form.length; ++i ) {
        var here   = form.elements[ i ];
        if ( ( here.type == 'checkbox' ) && here.checked ) {
          result += comma + here.value;
          comma  = ', ';
        }
      }
      alert( 'Selected: ' + result );
    } else {
      alert( 'Form not found: id = "' + id + '"' );
    }
      document.getElementById("checkboxvalues").value=result;
      
  }
  
  function onPage()
  {
  	alert(document.getElementById("checkboxvalues").value)
  	document.forms[0].action="/example.do?checkboxval="+document.getElementById("checkboxvalues").value;
  	document.forms[0].submit();
  } 
  
  
 </script>
</head>
<body>
<html:form action="example.do">
	<h3>
		Simple paging with struts tags.
	</h3>
	<table  border="1">
		<tr>
			<td>
				<b>&nbsp;</b>
			</td>
			<td>
				<b>ID</b>
			</td>
			<td>
				<b>Name</b>
			</td>
			<td>
				<b>City</b>
			</td>
			<td>
				<b>Phone</b>
			</td>
		</tr>
		<%-- Iteration over the list --%>
		<logic:iterate name="testList" property="listByOffsetAndLength"
			id="var">
			<tr>
			     <td>
				 <html:multibox property="control"  
				 value='<bean:write name="var" property="id"/>' onclick="checkForm('Form')" />

				</td>
				<td>
					<bean:write name="var" property="id" />
				</td>
				<td>
					<bean:write name="var" property="name" />
				</td>
				<td>
					<bean:write name="var" property="city" />
				</td>
				<td>
					<bean:write name="var" property="phone" />
				</td>
			
			</tr>
		</logic:iterate>
		<tr>
			<td colspan="5">
				<logic:iterate name="testList" property="pages" id="varpage">
					<html:link action="/example" paramName="varpage" paramId="page" >
						<bean:write name="varpage" />
						<input type="hidden" name="checkboxval" value="1"/>
					</html:link>
				</logic:iterate>
			</td>
		</tr>
	</table>
	
	</html:form>
</body>
</html:html>
Attachments:
 
struts example
 

Answer : javax.servlet.jsp.JspException: Cannot retrieve definition for form bean null on action

Could you try 2 things
1. Change the form to as shown; struts take care of appending the .do <html:form action="example">
2. Add the name attribute to action definition in struts-config.xml. I understand that you don't want to use the form, but <html:form> tag might require that you have a bean associated
with the form even if you are not going to use it.


<action path="/example" type="de.laliluna.tutorial.paging.action.ExampleAction" name="Customer" >
Random Solutions  
 
programming4us programming4us