Meaningless Drivel is fun!*
The moose likes Tomcat and the fly likes Root context mapping problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Root context mapping problem" Watch "Root context mapping problem" New topic
Author

Root context mapping problem

Mark Fraser
Greenhorn

Joined: Oct 15, 2010
Posts: 11
I'm mapping a servlet to the root of the server. The servlet runs fine but the linked CSS, scripts and images are returned containing the HTML of the page that linked to them instead. I've done many servlets but have seen nothing like this. Is this a specific problem with mapping to the root?

Here's my mapping:
<!-- Home Servlet -->
<servlet>
<servlet-name>HomeServlet</servlet-name>
<servlet-class>com.companyname.inet.servlet.home.HomeServlet</servlet-class>
<init-param>
<param-name>jspRoot</param-name>
<param-value>/WEB-INF/jsp/home/</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>HomeServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- /Home Servlet -->

Thanks for any help you can provide.
Mark Fraser
Greenhorn

Joined: Oct 15, 2010
Posts: 11
I found my own answer. Sorry for the distraction.
Here's what I had to do:
<!-- Home Servlet -->
<servlet>
<servlet-name>HomeServlet</servlet-name>
<servlet-class>com.companyname.inet.servlet.home.HomeServlet</servlet-class>
<init-param>
<param-name>jspRoot</param-name>
<param-value>/WEB-INF/jsp/home/</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>HomeServlet</servlet-name>
<url-pattern>/index.jsp</url-pattern>
</servlet-mapping>
<!-- /Home Servlet -->

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

The welcome-file-list entry isn't necessary since it's the defined default in the Tomcat /conf/web.xml, but it illustrates the solution better.
I hope this helps someone else.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Root context mapping problem