Reputation: 53
I have created Dynamic web project in eclipse, when i run the project on browser the URL is http://localhost:8080/magicmonitor/panels.jsp it's work fine, but my requirement is i want to change the URL dynamically, in the above URL magicmonitor is my project name, it's tomcat behavior it's take the default url is http://localhost:8080/magicmonitor (Host:Port/Projectname) i want to execute same on http://localhost:8080/dev/magicmonitor/panels.jsp how to do that?
Upvotes: 1
Views: 5198
Reputation: 17383
To change the URL you need to do three things:
Step 1 of 3: Change the context root:
Step 2 of 3: Add a mapping for the JSP:
Edit the project's WebContent/WEB-INF/web.xml to add a mapping for your JSP between the submitted URL and the JSP file:
<servlet>
<servlet-name>PanelsJsp</servlet-name>
<jsp-file>/panels.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>PanelsJsp</servlet-name>
<url-pattern>/magicmonitor/panels.jsp</url-pattern>
</servlet-mapping>
That <url-pattern> will be appended to the context root (which is now dev) when matching the URL you submit. If the URL submitted from the browser matches the <url-pattern> the <jsp-file> will be called.
Step 3: To republish:
You should now be able to access your JSP page using the URL http://localhost:8080/dev/magicmonitor/panels.jsp
Upvotes: 1