Maven « Development « JSP-Servlet Q&A

1. EL in a JSP stopped evaluating

In a JSP page(index.jsp):

${requestContext.requestURL} is the URL
just shows the expression itself. It used to be evaluated to something like "http://.../somerset/" I created the Maven project with maven-archetype-webapp archetype in Eclipse. The Jetty ...

2. maven, jsp files in dependency

I'm using maven2 for dependency management. I have one project that contains some Java files and some jsp files and another project, a web project, that depends on the first project. ...

3. Is it possible to read a properties file from all .war files deployed in a JBoss container

I've managed to deploy a .war to the Jboss web container containing and read the located under /META-INF/groupid-dir/artifactid-dir/ To access the file I've used the following code inside a JSP ...

4. How do I package multiple WAR files in one Maven project?

I am writing an application that integrates Geoserver with a custom component, intended to be hosted on a single servlet engine. Both are Maven based projects, and I would ...

5. how to add the servlet api to my pom.xml

How do I add the servlets API to my project's pom.xml has lots of servlet api and similarly named projects, that I don't know which is the right one. Or are ...

6. maven webapp to place jsps in /WEB-INF/jsp

I have inherited a webapp built using NetBean's internal ant. All jsps reside in:

And the web.xml has hardcoded links to /WEB-INF/jsp/somefile.jsp How can I use the maven war plugin to place the JSP ...

7. Maven dependency for Servlet 3.0 API?

How can I tell Maven 2 to load the Servlet 3.0 API? I tried:

I use

8. A Java web project created with Maven is not recognized as such by Eclipse

I created a web project with maven like this: mvn archetype:create -DartifactId=my-webapp -DarchetypeArtifactId=maven-archetype-webapp Then I run mvn eclipse:eclipse so that an eclipse project is built. Eclipse recognizes all the features of the ...

9. Maven archetype for simple Servlet application

Is there a Maven 2 archetype for a simple Servlet (2.5) web application?

10. Can't instantiate javax.servlet.ServletException

I am trying to create instance of class javax.servlet.ServletException with following code

public class MyTroubleViewer {
 public static void main(String[] args) {
  javax.servlet.ServletException servletException = new javax.servlet.ServletException("Hello");
But I ...

11. How can I use use JSP 2.1 with Cargo maven plugin and Jetty6x embedded?

I have a webapp that is using JSP 2.1, Servlets 2.5 and JSTL 1.2 on Java 6. I do my testing using the maven-jetty-plugin 6.1.1rc1 without any problems. From this link: ...

12. maven + eclipse + servlet-api.jar

I'm using Eclipse along with plugin m2eclipse to build and manage my project. In POM, I have included entry for servlet-api:


13. JSP hot-swap in Maven glassfish embedded plugin

I am trying to setup embedded glassfish maven plugin and I succeeded, but I can't make jsp files to be hot-swapped. Here is my config:


14. Should Maven package different WARs for different application servers?

I am just starting to package my web application project as a WAR file and am running into differences between the configuration for Tomcat vs Jetty vs JBoss vs Websphere, etc. ...

15. maven jetty plug in mvn:jetty ServletContext.getRealPath("") and ServletRequest.getRealPath("") to point to target _instead_ of source folders?

SUMMARY: The goal is to find the path to the WEB-INF folder in the target folder for maven-jetty-plugin that is compatible with other servers as well. The ServletContext.getRealPath("") works beautifully for, ...

16. How to create an war file in Eclipse without ant or maven?

I am using Eclipse IDE for Java Developers Helios. I have mainly done desktop applications before but now I would like to learn about Servlets. I have installed Jetty on my ...

17. Why servlet-api.jar turns its status from test to compile?

This is what I have in pom.xml:

This is what I see after mvn --debug war:war:
[DEBUG]    com.sun.jersey.jersey-test-framework:jersey-test-framework-grizzly:jar:1.4:test
[DEBUG]     ...

18. Guice Servlet config doesn't work without Servlet API

The following Guice Servlet configuration doesn't work when I remove the Maven dependency to the Servlet API:

The compiler tells me:
cannot access javax.servlet.Filter
class file for javax.servlet.Filter not found 
Any ...

19. jetty-maven-plugin does not work with Maven 3

When I try to run my project with Maven 3 instead of Maven 2.1, I get an exception from the jetty-maven-plugin. Everything is fine with Maven 2.1. The config looks like this:


20. I have servlet-api 2.5 provided, but want to use it during integration tests. Is this possible?

I am using the Jersey Test Framework, that includes servlet-api 2.5 in the test scope. Unfortunately, I have also written my own custom filter that requires me to have access ...

21. Configuring Jetty JSP support in embedded mode in Maven project

I can visit .html pages with Jetty, but when I visit a .jsp page I get:

0 13:21:13 / [INFO] No JSP support. Check that JSP jars are ...

22. How to share jars between JnlpDownloadServlet and other servlets

I have a webapp that has two servlets:

  1. A server for my application
  2. A JnlpDownloadServlet that serves a webstart app that is a swing client to my server
The two servlets share many of ...

23. How to get eclipse+maven to find and use servlet api source code or javadoc

Recently, I downloaded the latest elcipse with everything in it, and added the sonatype maven plugin. We setup a number of servlet projects using the mavel eclipse plugin web archtypes to generate ...

24. how to remove .jsp from .jar files after overlay is processed

I've a maven module named views containing one .jsp file \Calendar.jsp. I've another maven module named core, which is dependent on views module. The packaging type of views module is jar ...

25. Why Jetty use different context path in different environment

When I am in development environment, and use maven to start jetty (run mvn jetty:run), the context path is "/". But when I deploy it to production, and start jetty, the ...

26. How to manage dependency on servlet-api?

We have a web maven module that is compiled to a war, and thus doesn't need to include the servlet-api jar directly. We use <scope>provided</scope> for this. The problem arises when I ...

27. Using Maven Profiles with a WAR-Packaged Product

We have a Maven build (version 2.2.1) that currently produces a WAR file. Our output directory is target/, so we end up with a build artifact target/MyWar.WAR. I'm adding two profiles to ...

28. Specifying the classpath in Maven's jspc-maven-plugin plugin

I am trying to use Maven's jspc-maven-plugin to compile my JSPs. The problem I am encountering is that it is refusing to compile any JSPs that reference a class that is ...

29. Is it possible to get Maven to test compile JSP's?

I just converted one of our web projects from NetBeans ANT to Maven 2 in order to ease our dependency management, this has proved brilliant, however I didn't realise that Maven ...

30. How to specify the contextPath within contexts/foo.xml to run one servlet for any context (i.e. /*)

I want to get one servlet running under Jetty to handle all requests sent to the Jetty server. And I have to use Webapps Deployment. So I'm looking for solution similar ...

31. Maven web project - source locations for JSPs, JavaScript, CSS, Images

I need to convert a traditional J2EE web application into a new Maven web project. In traditional project, JSPs are under WebApp/jsps folder. JavaScript and CSS files under WebApp/scripts folder. Images ...

32. Problems with servlets and maven

i am trying to build my first servlet using maven but don't know what i should add to the POM so the servlet I have tried to add the below dependencies to ...

33. Maven loads Servlet API twice

I am getting a ClassCastException for In the logs I see that my javax.servlet.Filter is loaded twice. Once from my local maven repository

[Loaded javax.servlet.Filter from file:/C:/Users/xxxx/.m2/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar]
And another one from tomcat
[Loaded javax.servlet.Filter from ...

34. How to prevent duplicate servlet jar using eclipse+m2eclipse

I'm using Eclipse + Maven + m2eclipse to build and test a web application in Apache Tomcat. I've configured a Tomcat server inside Eclipse, and configured the deployment assembly for my web ...

35. What is the fastest way to develop a servlet using Maven, Glassfish, and JRebel?

Just using the command line, what is the fastest way to fire up the embedded glassfish server make a change to a file, recompile, then redeploy the code? I'm using:

  • mvn embedded-glassfish:run
  • change ...

36. Does the Jetty Maven Plugin 8.0.0.M3 support all of Servlet 3?

I have the following in my web.xml:

However, according to OWASP's Zed Attack Proxy (, cookies ...

37. Rename to web.xml when packaging using Eclipse

I have a J2EE application which has two web.xml files. One is called another is I am building this application with maven using profiles. So maven knows which file ...

38. Repository to download servlet-api.jar 3.0

Possible Duplicate:
Maven dependency for Servlet 3.0 API?
Repository to download servlet-api.jar:3.0 for the dependency provided.

39. Reliable Excel API for handling complex Excel report (parsing & writing ~10,000 lines) that works with Java

i know some similar question already exists, but I haven't found any satisfying answer yet. I found several library such as Apache POI and JExcelAPI, however as I don't have any previous ...

40. Maven: JspC should use external JSP-files

We're using Maven 3 and I'm facing a project that has JSP-files and also uses "global" JSP-files stored in a different project. This works nicely when using maven-war-plugin and ...

41. Jetty: declare servlets in java in stead of web.xml when using maven

Is it possible to use the embedded java code to add servlets:

Server server = new Server(8080);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.getInitParams().put("useFileMappedBuffer", "false");
context.addServlet(new ServletHolder(new MyServlet()), "/myurl");
in stead of the lengthy web.xml way:

42. Liferay Portlet Taglib Cast Exception

Here's a stacktrace I get when trying to run a portlet in Liferay Portal 6.0.6. Anyone has a clue what is going on?

12:40:00,146 ERROR [PortletServlet:96] javax.portlet.PortletException: javax.servlet.ServletException: javax.servlet.jsp
  .JspException: com.liferay.taglib.aui.LayoutTag cannot ...

43. java ee api is missing on project classpath while using httpunit for servlet testing in maven

I want to run the servlet testing example available here using maven. Javaee web api should be declared as provided:


44. Taglib inside Maven dependency jar. How do I configure this taglib inside the web.xml?

So I used to configure my taglib like that:

   </taglib> ...

45. Why packaging JAR files into WAR archive if they are available in Maven Central?

I wonder whether it's possible somehow to inform Servlet Container to download required JAR archives from Maven Central during deployment, instead of packaging them into WAR (in WEB-INF/lib). As far as ...

46. Can I debug jsp/servlet using mvn:jetty

I can start the web server using mn:jetty, but don't know if I can debug using it. Is there any attach functionality in Eclipse?

47. Maven JSP taglib archetype

I am creating a custom JSP tag. It's quite easy to write the Java class, as well as defining the TLD. My problem is that I don't know how to configure ...

48. Maven Jetty Plugin - Servlets Aren't Working

I have the following servlet coded in /src/main/java/examples/web/

package examples.web;


import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class SimpleServlet extends HttpServlet {
    public void goGet(HttpServletRequest req, HttpServletResponse res) throws IOException {

49. JSP in Maven Java Application

I have created a Maven Java Application in NetBeans 7.0.1 and need to be able to create jsp files inside of it. Since this is not a Maven Web Application, NetBeans does not recognize the jsp extension and code completion will not work. I have the appropriate jsp-api jars included as dependencies and as soon as I change the packaging node ...

50. Adding properties files to EAR classpath (Bonus points for including maven!)

Greetings all, My google-fu has failed, so I thought I'd ask around and see if anyone would be kind enough to offer any helpful advice. I'm struggling to add a properties file to my EAR's classpath. I have (for the sake of argument) a log4j.xml which lives @ META-INF/log4j.xml. I create a META-INF/MANIFEST.MF file inside my EAR with the following contents: ...

51. OpenEJB maven EAR

52. Ear module redeployment with maven and glassfish 3.1

Hi guys I am in a need of fast solution to my probably not unique problem. I am developing intranet application based on the Java EE6 standard and I've found myself in problematic situation. In this project maven is used as default build tool, and within this maven project I have defined other maven projects that represent EAR modules. Now the ...