Transfer files.class for folder / web-INF in Eclipse

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

When creating files .jsp for the application, gives error because it does not find the servlet class. The classes and files .class must be inside a hidden folder called classes. Do I have to create this folder? Well, I didn't.

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

Author: Math, 2014-05-20

2 answers

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 the files .class when the project is compiled.

In this case it would be enough to set this field to 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 you to configure the path to the files .class, and in others you can alternatively configure the current path to the files .class instead of changing where the .class is generated.

 1
Author: lucas.prestes, 2014-05-22 21:11:47

I'm assuming your application server is Tomcat.

The src Folder is only important to generate the .class files, but the files in src are not required to run the application on the application server, so you do not need to copy that folder.

Already the folder WEB-INF/classes is needed, create it and throw the files there, respecting the structure of subfolders (that is, if there are subfolders in the folder classes of your Eclipse project, keep these folders in WEB-INF/classes). In other words, copy the entire Eclipse project classes folder and paste inside 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 is the "Use the head: Servlets & JSP". Who knows you think he's out there...

 0
Author: Piovezan, 2014-05-20 23:40:08