Tuesday, July 29, 2008

Netbeans: where is the servlet-api?

I am currently writing a sample servlet for x2svg. And I am also trying to use NetBeans for it (as you probably remember, I am normally using Eclipse for my daily work). Actually I even downloaded 6.5M1 as Adam Bien sounded enthusiastic about it (and the editor really feels somewhat snappier than the 6.1 one).

To be able to include javax.servlet.* I need the servlet-api.
So I went to Tools->Libraries and expected it to be there. I have downloaded the EE edition of NetBeans, that should have it, but I just can't find it. There are tons of stuff like JSF libs etc. that all depend on it in some way, but I can't just pull in the basic servlet api.

For now I ended up with including the external servlet-api jar from tomcat, but this can't be the real solution.

What am I doing wrong? Where is the servlet-api in the NetBeans distribution?

3 comments:

  1. I think servlet-api is being put on classpath as part of the application server classpath. (when creating new web project, you have to pick an app server). Then all the jars found in the appserver are dumped on your project's classpath.

    For example maven based projects have a bit of a problem with this setup as well, as the basic maven project doesn't usually have it on classpath, but the various file creation wizards assume it's on classpath of every project.

    ReplyDelete
  2. Milos, that sounds reasonable.

    But how can I change a project from 'SE-project' to 'Web-project' or 'EE-project'? I started x2svg as a pure 'SE' project and added the servlet code only later.

    ReplyDelete
  3. I think you need to delete nbproject/ folder and build.xml file and create new web application with existing sources. (to be on the save side, delete the stuff with the IDE not running)

    BTW in Maven it would mean changing packaging from "jar" to "war" for the most part.

    ReplyDelete