I have 2 servlets, \"HomeController\" and \"SearchController\". On the home.jsp I have a form that has a search box and when submitted actions to \"Search\"
<
You can use getNamedDispatcher:
ServletContext context = getServletContext();
RequestDispatcher requestVar = context.getNamedDispatcher("HomeController");
Well, for one your servlet mapping config doesn't quite look right: you have this:
<servlet-mapping>
<servlet-name>SearchController</servlet-name>
<url-pattern>/Search</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-mapping>
<servlet-name>HomeController</servlet-name>
Notice the 2 servlet-mapping
lines?
I expect you just have an error in your web.xml file: your code looks fine.
I think I found your problem, your code is actually ok, the web.xml is the one that has the problem:
<servlet-mapping>
<servlet-name>HomeController</servlet-name>
<url-pattern>/Home</url-pattern>
<url-pattern>/</url-pattern>
</servlet-mapping>
You have there multiple url-patterns in a servlet mapping. Try this instead
<servlet-mapping>
<servlet-name>HomeController</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>HomeController</servlet-name>
<url-pattern>/Home</url-pattern>
</servlet-mapping>
It may resolve your issue, web containers are sometimes very picky with these details.
Source: http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd
The xsd specifies for the servlet-mapping type:
<xsd:sequence>
<xsd:element name="servlet-name"
type="j2ee:servlet-nameType"/>
<xsd:element name="url-pattern"
type="j2ee:url-patternType"/>
</xsd:sequence>
There is no multiple url-patterns there.