Getting error in including JSP file into other JSP file in STRUTS Application??
Joined: Nov 07, 2005
I have two jsp pages. MemberLogin.jsp & viewcart.jsp. In memberLogin.jsp I want to include viewcart.jsp. I have one action class into my application as "viewcartAction.java" & corresponding formbean as "viecartForm.java" with action having forward value "viewcart" with scope request, which is forwarding to Viewcart.jsp. On Viewcart.jsp page I can display all values from formbean "viewcartform.java" when I am typing in browser as path "viewcart.do". But when I am trying to include this viewcart.jsp file into Memberlogin.jsp, I am getting followin error:- ================================= javax.servlet.ServletException: Cannot find bean viewcartForm in any scope org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781) org.apache.jsp.jsp.MemberLogin_jsp._jspService(org.apache.jsp.jsp.MemberLogin_jsp:556) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) javax.servlet.http.HttpServlet.service(HttpServlet.java:810) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322) ===================================
How to solve this?? What I should do if I want to include viewcart.jsp(which is taking values from its own actioncalss & formbean) into MemberLogin.jsp??
Please tell me.
Thanx in advance. Prash
********Deserve Before You Desire********
Joined: Feb 15, 2005
It's not Viewcart.jsp that you want to include, it's viewCart.do. The viewCart action instantiates the form bean, so if you don't call the action before displaying the JSP, you'll get the message that the form bean doesn't exist.
I'd also use a <jsp:include> rather than <%@ include file="" %>. This ensures that the page gets processed as if it were a separate page before being included in your login page.