This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Struts and the fly likes Getting error in including JSP file into other JSP file in STRUTS Application?? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "Getting error in including JSP file into other JSP file in STRUTS Application??" Watch "Getting error in including JSP file into other JSP file in STRUTS Application??" New topic
Author

Getting error in including JSP file into other JSP file in STRUTS Application??

Pras Tiwari
Ranch Hand

Joined: Nov 07, 2005
Posts: 185
Hi,

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********
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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.


Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Getting error in including JSP file into other JSP file in STRUTS Application??
 
Similar Threads
Action Form Problem
Cant Access contents of form in forms Action class...
request problems
How to include contents of a JSP into other JSP file?
html select box - values getting lost