We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,259 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Need help debugging MVC Tutorial

Hi All,
I'm getting the following "Undefined type: ArrayList" for the following line of code "<jsp:useBean id="students" type="ArrayList<beans.UserBean>" scope="session" />"

Could someone tell me what I did / didn't do the get this error and what I have to do to resolve it.

Many thanks,
AK

2
Contributors
7
Replies
2 Weeks
Discussion Span
1 Year Ago
Last Updated
8
Views
Question
Answered
arden_k
Newbie Poster
16 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Did you provided import for ArrayList and the bean?

<%@ page import="java.util.ArrayList"%>
<%@ page import="beans.UserBean"%>
peter_budo
Code tags enforcer
Moderator
15,789 posts since Dec 2004
Reputation Points: 2,867
Solved Threads: 944
Skill Endorsements: 50

Hi Peter,
Yes, I did not change the demo code, see below.

<%@ page import="java.util.ArrayList"%>
<%@ page import="beans.UserBean"%>

The user bean is ok
<jsp:useBean id="userBean" class="beans.UserBean" scope="session" />

but the following line gets tagged with an error "Undefined type: ArrayList"
<jsp:useBean id="students" type="ArrayList<beans.UserBean>" scope="session" />


Thank you for your assistance.
AK

arden_k
Newbie Poster
16 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Is your project folder structure as per tutorial? If so please put your ZIP file and attach to next reply I will try to have look at it (you need to click "Use Advanced Editor" and bellow text editing area will be Manage Attachment options to attach ZIP of the project)
Also please let me know what IDE you use.

peter_budo
Code tags enforcer
Moderator
15,789 posts since Dec 2004
Reputation Points: 2,867
Solved Threads: 944
Skill Endorsements: 50

Hi,
I attached the project I created using the given directory structure.

Here are the errors warningd I'm getting:

web.xml

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
	 version="2.4">

Error:
Multiple annotations found at this line:
- Attribute "xmlns:xsi" must be declared for element type "web-app".
- Attribute "version" must be declared for element type "web-app".
- Attribute "xsi:schemaLocation" must be declared for element type
"web-app".


teacher.jsp

<%@ page import="beans.UserBean"%>

Error:
<%@ page import="beans.UserBean"%>


student.jsp

<jsp:useBean id="userBean" class="beans.UserBean" scope="session" />

Error:
Undefined type: beans.UserBean

<td class="bold"><%= userBean.getFirstName() %> <%= userBean.getLastName() %></td>

Error:
Multiple annotations found at this line:
- userBean cannot be resolved


index.jsp

<c:if test="${error != null}">
	${error}
	<c:set var="error" scope="request" value="${null}"/>
</c:if>

Warning:
The tag handler class for "c:if" (org.apache.taglibs.standard.tag.rt.core.IfTag) was not found on the Java Build Path

The tag handler class for "c:set" (org.apache.taglibs.standard.tag.rt.core.SetTag) was not found on the Java Build Path

Thanks again for your assistance.
AK

Attachments danijsptutorial.zip (1126.56KB)
arden_k
Newbie Poster
16 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

For first I expect schema update values will fix, when tutorial was written Sun Microsystems was in charge of Java now is Oracle so that will need to change.
I will have look and post back

peter_budo
Code tags enforcer
Moderator
15,789 posts since Dec 2004
Reputation Points: 2,867
Solved Threads: 944
Skill Endorsements: 50

I was correct in regards of schema locations, you need to update web.xml and replace

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
	 version="2.4">

with

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
version="2.5">

Given that you did project development in IDE instead of command line build as I did in original tutorial project folder structure is slightly different. Mainly the contenten of "classes" folder is moved to 'src" (you can see in attached file).

However as hard as I tried I couldn't get rid of error about <jsp:useBean id="students" type="ArrayList<beans.UserBean>" scope="session" /> . Page imports are fine, UsrBean is found I guess since there is no error on the line above this that retrieve userBean object from session.

Can some Eclipse user have look and check attached project folder to see if he/she will be wiser why Eclipse is moaning so much?

PS: Cascading style sheets and image is missing from there, but that is not important at the moment.

Attachments MVC-Test.zip (1127.13KB)
peter_budo
Code tags enforcer
Moderator
15,789 posts since Dec 2004
Reputation Points: 2,867
Solved Threads: 944
Skill Endorsements: 50

Thanks Peter.
I'll check it out

arden_k
Newbie Poster
16 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 1 Year Ago by peter_budo

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0832 seconds using 2.66MB