Why can't I create packages and classes in a webapp

I am trying to use IntelliJ for the forst time to create a Webapp, but it's acting 'weird'. When I right-click on WEB-INF folder in my project, I only get

new file
new directory
new jsp
new jspx

why not new package or new class??

Another thing is that I have a folder inside WEB-INF called classes and inside that, I want my package, so I tried to just create a folder there, but that is 'invisible' in the tree view. I don't understand this


1 comment
Comment actions Permalink

Well, normally, you shouldn't keep your source files (your java packages and files) in WEB-INF. This folder should contain your XML configuratino files, TLDs, and, possibly, the output directory for your compiled classes. The WEB-INF folder should be within your Web Root folder. The Web Root should also contain folder for your JSPs, JS files, images, etc. - all the web app related stuff. Your Java sources may be - and should be - elswhere, in a dedicated source (e.g. "/myApp/src") folder. So, you could have something like this:

/myapp/src/.... (java source packages tree)

Note that all these source folders don't need to be under your server. This is your work area. You need to configure your webapp so it properly deploys under your server, and your classes are compiled into the proper output folder where they will be seen by the server.


Please sign in to leave a comment.