Migrating to Websphere Portal 6.1,ServletContext

Prior to 6.1 ServletContext could be retived like

PortletContext context = (PortletContext)FacesContext.getCurrentInstance().getExternalContext().getContext();
PortletUtils.getInternalContext(context ).getServletContext();

But this won't work any more.Instead

PortletContextWrapper contextWrapper = new PortletContextWrapper(config.getPortletContext());
//config is PortletConfig
ServletContext servletContext=contextWrapper;

PortletContextWrapper implements ServletContext , so this will work with out any issues.

No comments:

Post a Comment