0

I've recently tried to use part of a code of a JSP file, found online, which starts by importing:

<%@ page import = "org.apache.commons.fileupload.*" %>
<%@ page import = "org.apache.commons.fileupload.disk.*" %>
<%@ page import = "org.apache.commons.fileupload.servlet.*" %>
<%@ page import = "org.apache.commons.io.output.*" %>

but Eclipse warns me with the error: " The import org.apache cannot be resolved. "

I tried to copy paste in the path
"C:\Users\MyPc\Downloads\apache-tomcat-7.0.96-windows-x64\apache-tomcat-7.0.96\webapps\SL2\WEB-INF\lib

the folder "commons-fileupload-1.4" once extracted, downloaded by the link: http://commons.apache.org/proper/commons-fileupload/download_fileupload.cgi

and yet the error keep remaining. What do I mistake?

  • Are the jars with those packages on the project's Java Build Path? Shouldn't the jars be in the `WEB-INF/lib` directory directly, and nothing else? – nitind Dec 09 '19 at 11:42
  • @nitind the folder that I've downloaded at that link (the latest one) has different files inside (not only the jars), even other folders. Should I put all those files directly in WEB-INF/lib? – Stone Cutter Dec 09 '19 at 11:52
  • The JAR files in the `C:\Users\MyPc\Downloads\apache-tomcat-7.0.96-windows-x64\apache-tomcat-7.0.96\webapps\SL2\WEB-INF\lib` are needed to run you web application, but for development you need to tell your IDE (Eclipse) that you are using them. As nitind states above, you have to add them to the Java Build Path of your project. – Jozef Chocholacek Dec 09 '19 at 11:53
  • See https://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.stardust.docs.wst%2Fhtml%2Fwst-integration%2Fdynamic-web-proj.html or better https://stackoverflow.com/questions/4440479/how-can-i-add-jar-files-to-the-web-inf-lib-folder-in-eclipse – Jozef Chocholacek Dec 09 '19 at 11:54
  • @JozefChocholacek you were right, thank you :) – Stone Cutter Dec 09 '19 at 15:10

1 Answers1

0

You should be putting the jar files from that zip, and only the jar files, into the project's WEB-INF/lib folder. The server has no use for the rest, and expects nothing more complicated in the layout there.

nitind
  • 19,089
  • 4
  • 34
  • 43