开发者

Bean error with jsp:include

I have a page which is too long to process in one block (code too long in try statement) so I wanted to cut into different jsp. But now i can't access my bean in the included jsp and I receive Cannot find bean: "org.apache.struts.taglib.html.BEAN" in any scope.

I looked over the internet and found only one page that talk about it, it says that my action definition must not be of page scope, and my scope is request right now.

Here is a sample of my page1.jsp

<html:form action="editFooBarAction">
  <jsp:include page=page2.jsp/>
开发者_运维技巧</html:form>

page2.jsp contains some html: tags and use of the form bean.

here is the definition of my action

<action
  path="/edit*"
  type="com.sham.web.action.{1}Action"
  name="{1}Form"
  scope="request"
  validate="true"
  input="edit.{1}">
  <forward name="edit" path="edit.{1}"/>
  <forward name="view" path="view.{1}"/>
</action>

Is there anyway to use jsp:include like that ?


The jsp:include element is processed when a JSP page is executed. The include action allows you to include either a static or dynamic resource in a JSP file. The results of including static and dynamic resources are quite different. If the resource is static, its content is inserted into the calling JSP file. If the resource is dynamic, the request is sent to the included resource, the included page is executed, and then the result is included in the response from the calling JSP page. - [reference]

Solution:

Try making your included page a JSP Fragment (.jspf). JSP Fragments are there to be statically included in another JSP. And they are not get compiled on their own.

Further Reading:

  • JSP Refactoring via Static Includes


Try putting the bean in the session scope....

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜