I haven't touched this project in a long time, but I could swear it worked the last time I tried it. Now, of course, it doesn't.
It's a
java servlet that takes some java code, compiles it and returns some html with the results (either "compile successful" or "compile error at line xxx"). It's built with only 2 classes: "Compiler" that extends from HttpServlet, and "JavaObjectFromString" that extends from SimpleJavaFileObject.
Class JavaObjectFromString looks like this:
Class Compiler looks like this:
I had compiled those two into .class files in an older Eclipse version (I haven't re-compiled since then).
I also have this form in an html file, that I suppose calls the servlet and passes it the "usercodefromhtml" parameter with the code the user writes in that textarea:
(I also tried "/compiler" and "Compiler" as the action value, but no luck).
This is how I installed and configured
tomcat:
1. I downloaded the 64 bit windows version from
http://tomcat.apache.org/download-70.cgi
2. I added two environment variables: JAVA_HOME -> path to JDK (in my case it's C:\Program Files\Java\jdk1.7.0_40) CATALINA_HOME -> path to tomcat (in my case it's C:\apache-tomcat-7.0.53)
3. I edited environment Path and added %JAVA_HOME%\jre\bin. I then ran configtest.bat from tomcat and it threw no errors.
4. In the webapps folder in tomcat, I created a folder for my project, where I placed my html containing the form code (as shown above).
5. In the project folder inside "webapps", I created a WEB-INF folder where I placed the web.xml and a "classes" folder with a subfolder named "servlet" containing the 2 compiled classes (.class files) I showed above.
My web.xml is as follows:
Then, from cmd I ran startup.bat from tomcat folder. I opened the html file in my browser, entered some random code in the textarea and pressed the submit button. Nothing. No class file (as a result of compilation task) is created in c: either.
I believe the two classes were working correctly the last time I tested them, so I'm more inclined to think this is a configuration problem... But where? Thanks!