You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Buland Altaf <bu...@yahoo.com> on 2004/07/17 07:27:50 UTC

RE: javax.servlet.ServletException: Cannot find bean dblist in sc ope request

Hi there,

There may be two solutions:

1. Sometimes this error comes if there is nothing in
the db and your collection is empty. So go and check
it and print collection data before storing it in
request object.

2. if there is some error and you are comming back to
your page, but at this time there will be nothing
dblist in your request object, u need to store it
again in case of an error/or store it in session and
remove it on successfull operation.

Hoep this will might help you.

Regards,
Buland

--- Sunil Sahu <Su...@KeaneIndia.Com> wrote:
> Hi patrick,
> 
> What is the package name for your bean and dao.
> 
> Please have a fresh look at package name u have
> specified for bean and dao.
> U are accessing the page thru
> http://localhost:port/list.do. Am i right.
> 
> Check it "scope="request" including in your mapping
> in struts-config.xml
> file.
> 
> -----Original Message-----
> From: AKEDJO Guy-Patrick [mailto:akpatk@yahoo.com] 
> Sent: Saturday, July 03, 2004 8:52 AM
> To: user@struts.apache.org
> Subject: javax.servlet.ServletException: Cannot find
> bean dblist in scope
> request
> 
> I've been trying to solve that issue for 3 days now
> I went also to the Net
> trying to find all information related to this but
> no way. I tried
> everything I know and all I found out but the error
> still the same.
> Can you help me please.
> Here are some information you need to check my code.
>  
> ============================= The error
> message=====================
> javax.servlet.ServletException: Cannot find bean
> dblist in scope request
>  
>
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextI
> mpl.java:867)
>  
>
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
> l.java:800)
> 
>
org.apache.jsp.form.list_jsp._jspService(list_jsp.java:129)
> 
>
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
> 
>
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
>  
>
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
> 11)
> 
>
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
> 
>
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
> 
>
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
> 
> root cause 
> javax.servlet.jsp.JspException: Cannot find bean
> dblist in scope request
> 
>
org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:940)
> 
>
org.apache.struts.taglib.logic.IterateTag.doStartTag(IterateTag.java:277)
> 
>
org.apache.jsp.form.list_jsp._jspService(list_jsp.java:85)
> 
>
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
> 
>
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
>  
>
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
> 11)
> 
>
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
> 
>
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
> 
>
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
>  
> ====================Action class XML
> config================
> <action path="/list"
> type="com.youcompany.struts.action.ListAction"
> validate="false">
> <forward name="listok" path="/form/list.jsp" />
> </action>
> ========================my Action
> class==================
>  
> package com.youcompany.struts.action;
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
> import org.apache.struts.action.Action;
> import org.apache.struts.action.ActionForm;
> import org.apache.struts.action.ActionForward;
> import org.apache.struts.action.ActionMapping;
> import com.youcompany.struts.bean.*;
> import javax.sql.*;
> import org.apache.struts.action.ActionError;
> import org.apache.struts.action.ActionErrors;
> import java.util.ArrayList;
> import java.util.Collection;
>  
> public class ListAction extends Action {
> //
>
---------------------------------------------------------
> Instance
> Variables
> //
>
---------------------------------------------------------
> Methods
> /** 
> * Method execute
> * @param ActionMapping mapping
> * @param ActionForm form
> * @param HttpServletRequest request
> * @param HttpServletResponse response
> * @return ActionForward
> * @throws Exception
> */
> public ActionForward execute(
> ActionMapping mapping,
> ActionForm form,
> HttpServletRequest request,
> HttpServletResponse response)
> throws Exception {
> // throw new
> UnsupportedOperationException("Generated method
> 'execute(...)'
> not implemented.");
>  
> // Get the datasource 
> ActionErrors errors = new ActionErrors();
> DatabaseDVDManager DAOdvd = new
> DatabaseDVDManager();
> DataSource dataSource =
>
(DataSource)servlet.getServletContext().getAttribute("org.apache.struts.acti
> on.DATA_SOURCE");
> Collection c = new ArrayList();
> 
> try {
> // connection
> DAOdvd.setDataSource(dataSource);
> c = DAOdvd.getAll();
>  
> 
> } catch (DAOException e) {
> // Message for the user:
> errors.add("label", new
> ActionError("error.listfailed"));
> saveErrors(request, errors);
> 
> // Logging the error:
> String message = "DVDs could not be listed";
> 
> // Save the chained exceptions:
> request.setAttribute("MYEXCEPTION", new
> DAOException(message, e));
> 
> }
> 
> request.setAttribute("dblist",c);
> 
> return (mapping.findForward("listok"));
>  
> }
> }
> ===================================My Jsp for the
> view ==============
> <%@ taglib uri="/WEB-INF/struts-logic.tld"
> prefix="logic" %>
> <%@ taglib uri="/WEB-INF/struts-bean.tld"
> prefix="bean" %>
> <%@ taglib uri="/WEB-INF/struts-tiles.tld"
> prefix="tiles" %>
>  
> <h2>DVD library</h2>
> <p>
> Click on Id to edit DVD.</p>
> <table border=1 bgcolor="#FFFFCC">
> <tr>
> <th>Id</th>
> <th>Title</th>
> </tr>
> <logic:iterate id="dvd" name="dblist"
> scope="request"
> type="com.youcompany.struts.bean.DVD">
> <tr>
> <td><a href="list.do?id=<bean:write name="dvd"
> property="id"/>">
> <bean:write name="dvd" property="id"/></a></td>
> <td><bean:write name="dvd" property="title"/></td>
> </tr>
> </logic:iterate>
> </table>
>  
> =============My DVD bean:==========================
> 
> import java.io.Serializable;
> /*
> * This a bean - and also a Value - or Data Transfer
> Object 
=== message truncated ===>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
user-help@struts.apache.org


=====

Buland Altaf Malik,
Software Engineer, 
Softech System's(pvt)Ltd. 
10/25 asad jan road lahore,cantt - 54810 Pakistan
Tel: 92-42-6665812 , 92-42-6660802

Mob: 0333-4344113
Fax: 92-42-6665792

http://www.softech.com.pk
buland_altaf@hotmail.com




	
		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org