views:

232

answers:

2

I'm running Eclipse 3.4 java enterprise adition and writing JSP pages with it. It does not appear to support quick fix, for example ArrayList ourList; comes up as an error but there isn't a quick fix option to add the import java.util.ArrayList statement. Is there a way to improve quick fix capabilities, or another set of Eclipse Plugins that provides quick fix for jsp?

+1  A: 

I tried the Ctrl+spacebar and it automatically added the import for me. Maybe that's good enough?

MyEclipse is something that you could try for improved JSP editing. I think it's only about $30 for a version with the JSP editing.

Michael Sharek
+1 for solving his particular problem (the import)
Jorn
A: 

Apart from this particular problem (which you could solve by using Eclipse for Java EE which has the WTP integrated), this implies that you're writing raw Java code inside a JSP file. This is considered bad practice. JSP is a view technology wherein you ought to control the flow and output using taglibs (e.g. JSTL) and to access the data using EL. Raw Java code actually belongs in a real Java class, like a Servlet, Filter, Javabean, DAO, Utility, etcetera. Keep the JSP clean from scriptlets. If you ever need to do something which isn't doable using taglibs/EL, then the particular code most likely belongs in a Java class.

Creating an ArrayList ought to be done inside a Servlet class, either directly or indirectly (business class). Use the doGet() to preprocess data for display and use the doPost() to postprocess data after submit. Inside the JSP you can iterate over an ArrayList using the JSTL c:forEach tag.

Good luck.

BalusC