Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
938 views
in Technique[技术] by (71.8m points)

web applications - Java web app - What determines my Servlet API version? Does it get specified in web.xml?

I'm using Eclipse EE Juno and my current web application is using Dynamic web modules 2.4. I'm trying to bump the version up to 3.0 but for some reason I'm unable to. when I try to change the version in project facets I get Cannot change version of project facet Dynamic Web Module to 3.0. Is it possible that there some bunk line in my web.xml file that determines this? How do I change the Dynamic web modules version if not from Eclipse project facet setting alone?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Servlet 2.4 in web.xml:

<web-app version="2.4"
  xmlns="http://java.sun.com/xml/ns/j2ee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="
    http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

Servlet 3.0 in web.xml:

<web-app version="3.0"
  xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="
    http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

That's the only difference. The rest is your IDE configuration. In order to use Servlet 3.0 you must have 3.0 JARs on the CLASSPATH so that new annotations and other classes are available. But do not include servlet JAR in your WAR, the implementation should come from the servlet container.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...