* "/")) newResPath = newResPath.replaceFirst("/" +
* activator.getServiceNSPrefix() + "/", "/");
*/
// Get a poolled servlet to process jsp file.
JasperServletWrapper jspServlet = JspServletPool.getInstance(webApp
.getBundleServletContext());
// ClassLoader c = jspServlet.getClass().getClassLoader();
// if newResPath is the same, the jasper may not compile the jsp
// just use the form class
// file. here set the servlet name to virtual name to hint that
// these are different.
// get the target bundle's servlet config.
// ServletConfig newConfig = new
// BundledServletConfig(targetBundle,getJspServletConfig(),
// virtualPath);
// jspServlet.init(newConfig);
BundledHttpServletRequestWrapper topReq = (BundledHttpServletRequestWrapper) webContainer
.getReqThreadVariants().get(OSGiWebContainer.THREAD_V_REQUEST);
HttpServletRequest req = (HttpServletRequest) threadScope.get().get(
RESPONSE_REQ);
ServletResponse resp = (ServletResponse) threadScope.get().get(
RESPONSE_RESP);
BundledHttpServletRequestWrapper wrapper = BundledHttpServletRequestWrapper
.getHttpServletRequestWrapper(req, targetBundle);
Bundle oldBundle = topReq.getBundle();
String oldServletPath = topReq.getServletPath();
String oldPathInfo = topReq.getPathInfo();
try {
// Switch to another bundled servelt request.
// No need to swith thread context class loader, coz Jsp Servlet's
// class loader has been changed.
topReq.setBundle(targetBundle);
// wrapper.setBundle(targetBundle);
wrapper.setServletPath(virtualPath);
wrapper.setPathInfo(null);
jspServlet.service(wrapper, resp);
// jspServlet.destroy();
} finally {
if (topReq.equals(wrapper)) {
topReq.setBundle(oldBundle);
topReq.setServletPath(oldServletPath);