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. How do I access the jsp files from the web project?
I can see that the jsp files are added to 1-0-SNAPSHOT-sources.jar
and not 1-0-SNAPSHOT.jar
(which is added as a dependency in the web projects pom.xml).
As per convention, we place our JSP files in the ${project. basedir}/main/webapp/WEB-INF/jsp/ directory.
For creating a jsp file explore the project by clicking the + icon -> right click on WebContent -> New -> jsp -> write your jsp file name e.g. index -> next -> Finish. Now JSP file is created, let's write some code.
groupId This element indicates the unique identifier of the organization or group that created the project. The groupId is one of the key identifiers of a project and is typically based on the fully qualified domain name of your organization. For example org. apache. maven.
I think the correct Maven-way to do it would be to put the JSP files in your web project under /src/main/webapp. If that for some reason is not possible, you could use the Maven Dependency Plugin to copy the needed files into your webapp. Or, if you have a WAR project anyway, you could use an Overlay to copy the JSP-Files. The second option (which I'd recommend), would look something like this:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<overlays>
<overlay>
<groupId>myGroupId</groupId>
<artifactId>myArtifactId</artifactId>
<type>jar</type>
<includes>
<include>**/*.jsp</include>
</includes>
<targetPath>WEB-INF/pages</targetPath>
</overlay>
</overlays>
</configuration>
</plugin>
</plugins>
</build>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With