java - API to edit web.xml from Eclipse plugin? -


What is the easiest way to edit web.xml from the Eclipse plugin? (I am looking for an API - as opposed to using print worders etc.)

The simplest way I've found is to capture the webpage object. For example, to add servlet to web.xml:

  import org.eclipse.jst.j2ee.model.ModelProviderManager; Import org.eclipse.jst.javaee.web.WebApp; WebPage webapp = (WebApp) ModelProviderManager.getModelProvider (project) .getModelObject (); Servlet servlet = webfinetica IINSTANCE.createServlet (); Servlet.setServletName ("myServlet"); // $ non-NLS-1 $ servlet.SetsCarcast ("org.my.class.path"); // $ non-NLS-1 $ webApp.getServlets (). Add (servlet);  

Any other tag can be added such as servlet-mapping and filter in such a way.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -