![]() |
![]() |
||||
At line 126 added 30 lines. |
!How to use a Servlet as your main page in Servlets 2.3 and lower |
If you are using servlets 2.3 or lower, you can point to a JSP file instead, and make that file redirect to your servlet. eg: |
File redirect.jsp (where /CMS is mapped to your servlet, as in the above examples) |
{{{ |
<% |
response.sendRedirect("http://yoursite.com/CMS"); |
%> |
}}} |
Welcome-file list in web.xml: |
{{{ |
<!-- The main page for the site will be redirect.jsp servlet, which redirects --> |
<!-- to the MyCMS servlet (http://yoursite.com/CMS) --> |
<!-- No mapping is defined for other folders (http://website/someFolder/CMS), --> |
<!-- so one of the other files will be displayed (index.html, index.htm, index.jsp) --> |
<welcome-file-list> |
<welcome-file>redirect.jsp</welcome-file> |
<welcome-file>index.html</welcome-file> |
<welcome-file>index.htm</welcome-file> |
<welcome-file>index.jsp</welcome-file> |
</welcome-file-list> |
}}} |
!Troubleshooting |
* Make sure you don't use leading slashes on your <[welcome-file-list|web.xml.WelcomeFileList]> files (eg: use CMS, not /CMS) |
* If using the servlet in a <[welcome-file-list|web.xml.WelcomeFileList]>, make sure your [web.xml] version is 2.4 or above (see [web.xml - DTD and XSD]), and that you are using a 2.4 compliant container or above (eg: Tomcat 5.5 or above) |
\\ |