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 a development environment, include servlet-api. jar in your Maven pom.xml file.

pom.xml

  <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.

7 comments on “Get HttpServletRequest via Maven repository

  1. They changed the artifact id…

    javax.servlet
    javax.servlet-api
    3.1.0
    provided

    Reply
  2. It is still using the servlet from jdk. This is causing problem for me.

    Reply
  3. Thanks A LOT!
    I fogot the scope provided.

    A hug.
    Doug

    Reply
  4. Hi,

    Whenever we use the Maven install command, will get the .war file without having the lib folder.

    I’ve some doubts to deploy the WAR file into some other Development, Test or Production server where ill get those supported files and run my application.

    could you please kindly give me some details.

    Reply

Leave a Comment

Your email address will not be published. Required fields are marked *