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

Asked

Viewed 1,332 times

1

I’m developing a web project for a final college job.

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

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

2 answers

1

In the eclipse if you right-click on your project and go to properties > Java build Path, Voce must find in the source tab a field called 'default output path', this is where the 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 don’t even need you to configure the path to the files. class, and in other Voce you can alternatively set the current path to the . class files instead of changing where the . class is generated.

0

I’m assuming your application server is Tomcat.

The briefcase src is only important to generate the files .class, 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 necessary, create it and throw the files there, respecting the structure of subfolders (ie if there are subfolders in the folder classes of your Eclipse project, keep these folders in WEB-INF/classes). In other words, copy the folder classes of the entire Eclipse project and paste within WEB-INF. By the way, the folder is called "hidden" because what you have inside WEB-INF is not accessible by your web application.

A book that explains perfectly the whole process is the "Use Head: Servlets & JSP". Maybe you’ll find him around...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.