First, I'd would like to mention that I've checked the forum and found a lot of topics about FTP implementation but I do not think my issue is related to the org.apache.commons.net.ftp. but rather me not knowing enough to import it properly or something along those lines.
I'm willing to read in order to make my code work but I think I need a bit of help.
I'm trying to upload a file via FTP. I'm sure by now you had guessed that's what I was trying to achieve.
The jar file is in both WEB-INF/lib/ and I'm running TOMCAT5.5.
To Import the jar file I use
<%@ page import ="org.apache.commons.net.ftp.*" %>
If I refresh my page I get no error, I now assume that it's normal to not get any error if I do not use the class.
As soon as I try to soemthing like
FTPClient ftp = new org.apache.commons.net.ftp.FTPClient();
private static String FTP_SERVER = "ftp.foo.com";
private static String FTP_USER = "foobar";
private static String FTP_PASSWORD = "barfoo";
private static String FTP_DIRECTORY = "/public_html/";
ftp.connect(FTP_SERVER);
I sometimes get the rest of my page or I get this error
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 5 in the jsp file: /admin/question_add.jsp
Generated servlet error:
Syntax error on token(s), misplaced construct(s)
An error occurred at line: 5 in the jsp file: /admin/question_add.jsp
Generated servlet error:
Syntax error on token "FTP_SERVER", VariableDeclaratorId expected after this token
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
sun.reflect.GeneratedMethodAccessor51.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:243)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:275)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:161)
root cause
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 5 in the jsp file: /admin/question_add.jsp
Generated servlet error:
Syntax error on token(s), misplaced construct(s)
An error occurred at line: 5 in the jsp file: /admin/question_add.jsp
Generated servlet error:
Syntax error on token "FTP_SERVER", VariableDeclaratorId expected after this token
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
sun.reflect.GeneratedMethodAccessor51.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:243)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:275)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:161)
Now, I've tried two different jar file and I always get the same strange behavior.
How come I get an error about compiling the class once every 5 refreshes or so?