Question

I get different behaviours regarding the starting url in jsp files when I deploy the application or when I test it using mvn tomcat:run

Here is the jsp code that works fine in deploying the application on cloudbees

    <form method="post" action="/import" enctype="multipart/form-data">
        <input type="file" name="file"/>
        <input type="submit"/>
    </form>

whereas when I use mvn tomcat:run I need to add the maven artifact Id as the start of the url for the action part of the form :

    <form method="post" action="my-application/import" enctype="multipart/form-data">
        <input type="file" name="file"/>
        <input type="submit"/>
    </form>

Any help on what kind of configuration parameters I should look at for that would be appreciated. Thanks

Was it helpful?

Solution

This is controlled under the maven tomcat plugin section in the pom.xml through the path parameter as stated in This documentation link.

Setting the path at / will ensure you have the same behaviour of urls when you try on your PC with mvn tomcat7:run and after deployment on cloudbees. Here is the pom.xml excerpt :

<build>
       <plugins>
            ...
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.1</version>
            <configuration>
                <path>/</path>
            </configuration>
        </plugin>
    </plugins>
</build>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top