• United States
IBM?
  • Site map
IBM?
  • Marketplace

  • Close
    Search
  • Sign in
    • Sign in
    • Register
  • IBM Navigation
IBM Developer Answers
  • Spaces
    • Blockchain
    • IBM Cloud platform
    • Internet of Things
    • Predictive Analytics
    • Watson
    • See all spaces
  • Tags
  • Users
  • Badges
  • FAQ
  • Help
Close

Name

Community

  • Learn
  • Develop
  • Connect

Discover IBM

  • ConnectMarketplace
  • Products
  • Services
  • Industries
  • Careers
  • Partners
  • Support
10.190.13.206

Refine your search by using the following advanced search options.

Criteria Usage
Questions with keyword1 or keyword2 keyword1 keyword2
Questions with a mandatory word, e.g. keyword2 keyword1 +keyword2
Questions excluding a word, e.g. keyword2 keyword1 -keyword2
Questions with keyword(s) and a specific tag keyword1 [tag1]
Questions with keyword(s) and either of two or more specific tags keyword1 [tag1] [tag2]
To search for all posts by a user or all posts with a specific tag, start typing and choose from the suggestion list. Do not use a plus or minus sign with a tag, e.g., +[tag1].
  • Ask a question

JSP cannot resolve java.util.List,JSP Compile Cannot resolve java.util.List

310000CADH gravatar image
Question by JoshuaBurns  (1) | Mar 31, 2015 at 09:44 AM wasdevjsp

I am migrating a web application from Weblogic to Liberty Profile. I get the error "List cannot be resolved to a type " When I look at the java class that was generated from the JSP, its missing the import for java.util.List.

This seems to be an issue with collections without generics: List alphabetIndexList = new ArrayList();

If I rewrite this to use generics, the error goes away: List alphabetIndexList = new ArrayList();

However, there is also a problem when using List and initializing to a List: List = getList(); (getList() return List)

So in this case it seems like the JSP precompiler is not adding the import for List, which may have something to do with the fact that its an interface.

There does not seem to be any setting in the element to control this behavior, perhaps its a bug?

THis worked with Weblogic and Tomcat.

People who like this

  0   Show 3
Comment
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
1000007WV4 gravatar image Alasdair (2407)   Mar 31, 2015 at 09:49 AM 0
Share

I assume you meant that List alphabetIndexList = new ArrayList(); works?

Does the jsp have at the top?

Edit: meant to ask if it had this at the top, but the editor keeps throwing it away:

 <%@page import="java.util.*"%>
310000CADH gravatar image JoshuaBurns (1)   Mar 31, 2015 at 09:57 AM 0
Share

YEs,

 List<String> alphabetIndexList = new  ArrayList<String>();

works.

310000CADH gravatar image JoshuaBurns (1)   Mar 31, 2015 at 09:59 AM 0
Share

HEre are the imports: package com.ibm._jsp;

import javax.servlet.; import javax.servlet.http.; import javax.servlet.jsp.*;

import com.dbo2.pipeline.view.util.PaginatedResultListVO; import com.dbo2.pipeline.view.contact.ContactListRowVO; import com.dbo2.pipeline.controller.contact.ContactAlterListAction; import com.dbo2.pipeline.view.company.CompanyForm;

1 reply

  • Sort: 
110000E92M gravatar image

Answer by gas (897) | Mar 31, 2015 at 10:49 AM

You need to add in your jsp files the following import directive (can be either with * or with explicit java.util.List and java.util.ArrayList):

 <%@page import="java.util.*"%>

WebLogic imports java.util.* package implicitly in JSP which is not compliant with the JSP specification (see JSP.1.10.1 The page Directive) :

 Packages java.lang.*, javax.servlet.*,  javax.servlet.jsp.*, and javax.servlet.http.* are imported
 implicitly by the JSP container. No other packages may be part of this implicitly imported list.
Comment
Eric Covener

People who like this

  1   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

Follow this question

62 people are following this question.

Answers

Answers & comments

Related questions

RAD 9.1.1 Jsp tags validation broken 1 Answer

How to embed jsp:expression in JSP XML 4 Answers

JSP compilation fails when I use double quotes. 1 Answer

Why Modifing JSP Dynamically not Detected in the deployed Web Module of an Enterprise App? 4 Answers

StackOverflow on Portal 8.0 1 Answer

  • Contact
  • Privacy
  • IBM Developer Terms of use
  • Accessibility
  • Report Abuse
  • Cookie Preferences

Powered by AnswerHub

Authentication check. Please ignore.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • API Connect
  • Analytic Hybrid Cloud Core
  • Application Performance Management
  • Appsecdev
  • BPM
  • Blockchain
  • Business Transaction Intelligence
  • CAPI
  • CAPI SNAP
  • CICS
  • Cloud Analytics
  • Cloud Automation
  • Cloud Object Storage
  • Cloud marketplace
  • Collaboration
  • Content Services (ECM)
  • Continuous Testing
  • Courses
  • Customer Experience Analytics
  • DB2 LUW
  • DataPower
  • Decision Optimization
  • DevOps Services
  • Developers IBM MX
  • Digital Commerce
  • Digital Experience
  • Finance
  • Global Entrepreneur Program
  • Hadoop
  • Hybrid Cloud Core
  • IBM Cloud platform
  • IBM Design
  • IBM Forms Experience Builder
  • IBM Maximo Developer
  • IBM StoredIQ
  • IBM StoredIQ-Cartridges
  • IIDR
  • ITOA
  • InformationServer
  • Integration Bus
  • Internet of Things
  • Kenexa
  • Linux on Power
  • LinuxONE
  • MDM
  • Mainframe
  • Messaging
  • Node.js
  • ODM
  • Open
  • PowerAI
  • PowerVC
  • Predictive Analytics
  • Product Insights
  • PureData for Analytics
  • Push
  • QRadar App Development
  • Run Book Automation
  • Search Insights
  • Security Core
  • Storage
  • Storage Core
  • Streamsdev
  • Supply Chain Business Network
  • Supply Chain Insights
  • Swift
  • UBX Capture
  • Universal Behavior Exchange
  • UrbanCode
  • WASdev
  • WSRR
  • Watson
  • Watson Campaign Automation
  • Watson Content Hub
  • Watson Marketing Insights
  • dW Answers Help
  • dW Premium
  • developerWorks Sandbox
  • developerWorks Team
  • Watson Health
  • More
  • Tags
  • Questions
  • Users
  • Badges