title: Cannot find bean: “studentList” in any scope
body: <p>I'm using Struts 1 framework to upload a CSV to the server and save it in database (Mysql). But when I get the data from the database and show it in my JSP, it throws an error:</p>
  
  <blockquote>
    <p>Cannot find bean: “studentList” in any scope </p>
  </blockquote>
  
  <p>What can be the issue?</p>
  
  <p><strong>File struts-config.xml.</strong></p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts 
      Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd"&gt;
      &lt;struts-config&gt;
          &lt;form-beans&gt;
              &lt;form-bean name="fileUploadForm" type="form.FileUploadForm"&gt;
              &lt;/form-bean&gt;        
          &lt;/form-beans&gt;
  
          &lt;action-mappings&gt;
              &lt;action input="/input.jsp" path="/upload" name="fileUploadForm"
                  attribute="fileUploadForm" type="action.FileUploadAction" scope="request"&gt;
                  &lt;forward name="success" path="/pages/studentList.jsp" /&gt;
              &lt;/action&gt;
  
              &lt;action input="/studentList.jsp" path="/listStudentPage"
                  type="action.StudentListPageAction" name="studentList"&gt;
                  &lt;forward name="success" path="/pages/studentList.jsp" /&gt;
              &lt;/action&gt;
              &lt;action path="/listStudentPage" parameter="/pages/studentList.jsp" type="action.StudentListPageAction" /&gt; 
          &lt;/action-mappings&gt;
  
          &lt;message-resources parameter="action.ApplicationResources" /&gt;
      &lt;/struts-config&gt;
  </code></pre>
  
  <p><strong>File UploadForm:</strong></p>
  
  <pre><code>package form;
  
  import javax.servlet.ServletRequest;
  
  import javax.servlet.http.HttpServletRequest;
  
  import org.apache.struts.action.ActionErrors;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.action.ActionMessage;
  import org.apache.struts.upload.FormFile;
  
  public class FileUploadForm extends ActionForm{
  
  
      private FormFile file;
  
      public FormFile getFile() {
          return file;
      }
  
      public void setFile(FormFile file) {
          this.file = file;
      }
  }
  //  @Override
  //  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
  //       ActionErrors errors = new ActionErrors();
  //          if (file.getFileSize() == 0) {
  //              errors.add("file", new ActionMessage("error.file.required"));
  //          } else if (!file.getContentType().equals("application/csv")) {
  //              errors.add("file", new ActionMessage("error.file.type"));
  //          }
  //        //logs debug
  //          if(logger.isDebugEnabled()){
  //              logger.debug("WelcomeAction.execute()");
  //          }
  //
  //          //logs exception
  //          logger.error("This is Error message", new Exception("Testing"));
  //
  //          return mapping.findForward("success");
  //          /**
  //          * If the file size is greater than 20kb.
  //          */
  //          else if (file.getFileSize() &gt; 20480) {
  //              errors.add("file", new ActionMessage("error.file.size"));
  //          }
  //          return errors;
  //  
  //}}
  </code></pre>
  
  <p><strong>File StudentList:</strong></p>
  
  <pre><code>package action;
  
  import java.util.ArrayList;
  import java.util.List;
  
  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 bean.Student;
  import dao.StudentDAO;
  import pagination.Pages;
  
  public class StudentListPageAction extends Action {
  
      @Override
      public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
              HttpServletResponse response) throws Exception {
  
          StudentDAO studentDAO = new StudentDAO();       
          List&lt;Student&gt; studentList = new ArrayList&lt;&gt;();
  
          //get page current. if param is empty, set current is 1
          String selPage = (String) request.getParameter("selPage");
          if("".equals(selPage) || selPage == null){
              selPage = "1";
          }
  
          //get all list actor
          studentList = studentDAO.getallUser();
  
          //set paging for list actor
          if (studentList != null &amp;&amp; !studentList.isEmpty()) {
              Pages page = new Pages();
              page.setTotalSize(studentList.size());
              page.setCurrPage(Integer.parseInt(selPage));
              int min = page.minIndex();
              int max = 0;
              max = page.maxIndex(studentList.size());
              request.setAttribute("studentList",studentList.subList(min, max));
              request.setAttribute("page", page);
          }
          return mapping.findForward("success");
      }
  }
  </code></pre>
  
  <p><strong>File StudentList.jsp</strong></p>
  
  <pre><code> &lt;%@ page language="java" contentType="text/html; charset=UTF-8"
      pageEncoding="UTF-8"%&gt;
  &lt;%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%&gt;
  &lt;%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%&gt;
  &lt;%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;This is all information&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;table class="table table-hover"&gt;
      &lt;tr&gt;
          &lt;th&gt;UserID&lt;/th&gt;
          &lt;th&gt;firstName&lt;/th&gt;
          &lt;th&gt;lastName&lt;/th&gt;
          &lt;th&gt;email&lt;/th&gt;
          &lt;th&gt;password&lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
      &lt;/tr&gt;
      &lt;logic:iterate name="studentList" id="studentListId"&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;bean:write name="studentListId" property="userId" /&gt;&lt;/td&gt;
              &lt;td&gt;&lt;bean:write name="studentListId" property="fistName" /&gt;&lt;/td&gt;
              &lt;td&gt;&lt;bean:write name="studentListId" property="lastName" /&gt;&lt;/td&gt;
              &lt;td&gt;&lt;bean:write name="studentListId" property="email" /&gt;&lt;/td&gt;
              &lt;td&gt;&lt;bean:write name="studentListId" property="password" /&gt;&lt;/td&gt;
  
          &lt;/tr&gt;
      &lt;/logic:iterate&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p><strong>File Student</strong></p>
  
  <pre><code>package bean;
  
  public class Student {
      private String userId;
      private String firstName;
      private String lastName;
      private String email;
      private String password;
      public String getUserId() {
          return userId;
      }
      public void setUserId(String userId) {
          this.userId = userId;
      }
      public String getFirstName() {
          return firstName;
      }
      public void setFirstName(String firstName) {
          this.firstName = firstName;
      }
      public String getLastName() {
          return lastName;
      }
      public void setLastName(String lastName) {
          this.lastName = lastName;
      }
      public String getEmail() {
          return email;
      }
      public void setEmail(String email) {
          this.email = email;
      }
      public String getPassword() {
          return password;
      }
      public void setPassword(String password) {
          this.password = password;
      }
      @Override
      public String toString() {
          return "Student [userId=" + userId + ", firstName=" + firstName + ", lastName=" + lastName + ", email=" + email
              + ", password=" + password + "]";
      }
  }
  </code></pre>