The RequestDispatcher class of a servlet package does not have a FORWARD_REQUEST_URI field

I am trying to create a Java EE application using Maven. In my pom.xml, I have the following:

<dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> </dependency> 

According to http://download.oracle.com/javaee/6/api/constant-values.html#javax.servlet.RequestDispatcher.FORWARD_REQUEST_URI , there must be a FORWARD_REQUEST_URI field, but it is not.

 [ERROR] foo.java:[296,53] cannot find symbol symbol : variable FORWARD_REQUEST_URI location: interface javax.servlet.RequestDispatcher 

There are no other cans in the project catalog. I unpacked the jar file found in the ~ / .m2 directory and it has files related to 5/10/2006. When I remove the pom.xml dependency, it does not compile at all. (I have a Glassfish server installed with NetBeans EE, so I can use server banks, I suppose?)

+2
source share
1 answer

This constant was introduced in Servlet 3.0. It is not present in Servlet 2.5; see also Java EE 5 RequestDispatcher javadoc . If you are using Glassfish 3.x, which is a Servlet 3.0 container, you should be able to upgrade your version in pom to 3.0 . However, it must be dependent on <scope>provided</scope> .

+3
source

All Articles