0

In my home.JSP file, I am trying to use an ArrayList after putting the correct package name in the @page directive. The code is executing properly but I am getting error in the JSP editor window saying "ArrayList can not be resolved to a type.

here is the code snippet (Look at the last line where the array list is created that is where I am getting the error.)

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" import="java.util.Scanner, java.util.ArrayList" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body bgcolor = "green" > hey this is coming from file <% int i = Integer.parseInt(request.getParameter("num1")); int j = Integer.parseInt(request.getParameter("num2")); int k= i+j; out.println("output: "+k); String str = "hello"; ArrayList<String> ls = new ArrayList<String>(); %> 
2

1 Answer 1

0

Try put ArrayList's import in another line, using one import by line

<%@page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@page import="java.util.ArrayList" %> <%@page import="java.util.Scanner" %> 

Other issue can be there is a space between @ and "page" in first directive line

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.