Transfer .class files to the / web-inf folder in Eclipse

1

I am developing a web project for a final college job.

When creating .jsp files for the application, it fails because it does not find the servlet class. Classes and .class files must be inside a hidden folder called classes. Do I have to create this folder? Well I did not find it.

I would like to know if I have to copy the whole src folder, which is in 'Java Resources' and / or I have to transfer the location of the .class files to the / web-inf / classes folder.     

asked by anonymous 21.05.2014 / 01:24

2 answers

1

In eclipse if you right-click on your project and go to properties > Java build Path, you should find in the source tab a field called 'default output path', this is where eclipse generates .class files when the project is compiled.

In this case it would be enough to set this field for web-inf / classes.

However depending on the case, it may not be necessary to change the eclipse folder, in most cases just export to WAR (external server case), or if you are using a plugin, some plugins do not even need to configure the path for the .class files, and in others you can alternatively configure the current path to the .class files instead of changing where the .class is generated.

    
21.05.2014 / 22:37
0

I'm assuming that your application server is Tomcat.

The src folder is only important for generating .class files, but src files are not required to run the application on the application server, so you do not need to copy this folder.

The WEB-INF/classes folder is required, create it, and play the files there, respecting the subfolders structure (that is, if there are subfolders in the classes folder of your Eclipse project, keep those folders in WEB-INF/classes ). In other words, copy the classes folder from the entire Eclipse project and paste it into WEB-INF. By the way, the folder is said to be "hidden" because what you have inside WEB-INF is not accessible by your web application.

A book that explains the whole process right is the "Use Head: Servlets & JSP" . Maybe you think he's out there ...

    
21.05.2014 / 01:33