Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use servlet api 3.0 and jetty 8?

I want to use 3.0 servlet-api with Jetty 8. Currently 2.4 servlet-api is defined in my web.xml. And in the webdefault.xml 2.5 servlet-api is defined. Someone else set this up so they very well might have done something wrong. Which servlet-api version am I actually using? 2.4 or 2.5? I have 3.0 already in my classpath. What do I need to change in web.xml and/or webdefault.xml to get it working?

Thank you in advance.

like image 450
user2029910 Avatar asked Dec 20 '22 10:12

user2029910


1 Answers

You normally don't provide the Servlet API yourself. This is normally to be provided by the target servletcontainer itself. Examples of Servlet 3.0 compatible containers are Tomcat 7.x, Glassfish 3.x, JBoss AS 6.x/7.x and, yes, Jetty 8.x.

You just have to declare the <web-app> root element of web.xml to comply the highest version as supported by the target container.

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    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"
    version="3.0">

</web-app>

See also:

  • Our Servlets wiki page
like image 141
BalusC Avatar answered May 09 '23 06:05

BalusC