forward() across webapps
http://hoare.cs.umsl.edu/servlet/j-siegel/contextTest
META-INF and context
contextServlet.java in j-siegel
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class contextServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
res.setContentType("text/html;charset=UTF-8");
ServletContext src = req.getSession().getServletContext();
ServletContext target = src.getContext("/siegel");
RequestDispatcher rd = target.getRequestDispatcher("/Hij-siegel.jsp");
rd.forward(req, res);
}
}
Hij-siegel.jsp in siegel
<html>
<head>
<title>Hi j-siegel</title>
</head>
<body>
<center>
<font size="+3"><b>Hi: j-siegel<br />from siegel</b></font>
</center>
</body>
</html>
context.xml in both /webapp/META-INF and
the contextServlet reference in j-siegel/WEB-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context crossContext="true" crossAuth="true">
</Context>
----------------------------------------
<servlet>
<servlet-name>contextTest</servlet-name>
<servlet-class>contextServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>contextTest</servlet-name>
<url-pattern>/contextTest</url-pattern>
</servlet-mapping>