Get HttpServletRequest Via Maven Repository
Problem
Using Maven build tool, which jar should include to use
HttpServletRequest
or HttpServletResponse
?
Solution
To use
HttpServletRequest
or HttpServletResponse
in development environment, include “serlvet-api.jar” in your Maven pom.xml
file. <dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
Put scope as “provided“, because most j2ee containers have this jar. You need this for complication only, not deployment.
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
</dependency>