1.11M Members

Need help debugging MVC Tutorial

 
0
 

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

 
0
 

Did you provided import for ArrayList and the bean?

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

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

 
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.

 
0
 

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)
 
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

 
0
 

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)
 
0
 

Thanks Peter.
I'll check it out

Question Answered as of 2 Years Ago by peter_budo
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article