Author | Message |
---|---|
kevinmowers@yahoo.com
Posts: 49
|
Posted 12:56 Jan 22, 2014 |
I made an ArrayList of the course entries and put it in application scope: getServletContext().setAttribute("courseEntries", courses); When I retrieve it in the same servlet: ArrayList<CourseEntry> entries = (ArrayList<CourseEntry>) getServletContext().getAttribute( "courseEntries" );
It works fine, but when I use getAttribute from a different servlet (ex.AddCourse), the app can't find the ArrayList "courseEntries"
PS: The classes are all under the class folder, I don't know if that would make a difference Last edited by cysun at
12:59 Jan 22, 2014.
|
cysun
Posts: 2935
|
Posted 13:03 Jan 22, 2014 |
First of all, don't post large chunk of code (and obviously, don't attach source code files) in the forum. Doing so will be considered facilitating cheating. As for the problem itself, most likely it's due to something minor like a typo in the attribute name when you do getAttribute() or something like that. |
xytian
Posts: 70
|
Posted 13:12 Jan 22, 2014 |
Or, maybe you don't have loadOnStartup in the WebServlet annotation in the servlet where you have the init method, and ran AddCourse first after the server restarted. Last edited by xytian at
13:12 Jan 22, 2014.
|