You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Craig McDonald <Cr...@canberra.edu.au> on 2005/06/01 03:41:09 UTC
Portlet context root - accessing other webapp contexts
Does anybody know how to reference other tomcat webapp contexts from
within a portlet?
For example, I have "/webapp1" already installed on tomcat, that serves
out webpages in a specific way. Then I have a portlet where I want to
"call" this webapp context within a JSR-168 portlet.
So within my java file I have: PortletRequestDispatcher rd =
getPortletContext().getRequestDispatcher("/webapp1/view.jsp");
But in this case, the portlet thinks the root is actually at
"/myportlet/", so calling the above code, it tries to find "view.jsp" at
"/myportlet/webapp1/" rather than from the "real" tomcat webroot.
Does this make sense? Essentially I need to know how (if possible) I can
call instances of pages *outside* of the portlet context root.
Any help would be much appreciated.
Cheers,
Craig
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org
AW: Portlet context root - accessing other webapp contexts
Posted by Sven Thiergen <s....@itcampus.de>.
> Does anybody know how to reference other tomcat webapp contexts
> from within a portlet?
> For example, I have "/webapp1" already installed on tomcat, that serves
> out webpages in a specific way. Then I have a portlet where I want to
> "call" this webapp context within a JSR-168 portlet.
> So within my java file I have: PortletRequestDispatcher rd =
> getPortletContext().getRequestDispatcher("/webapp1/view.jsp");
You probably need to switch the Context to the target tomcat webapp, first.
When programming Servlets you have the option to first get the context (->
the folder under "webapps/") where your servlet runs at:
ServletContext myContext = getServletConfig().getServletContext();
The from this ServletContext object you can switch to other context's:
ServletContext otherContext = myContext.getContext("/other");
if the directory structure below "webapps/" e.g. contains the folder
"other/". If it is allowed to switch to a certain context depends on
security constraints (whether a context is marked as "shareable" etc.). At
least I think so, this may not be 100% correct.
Anyway, once you could switch the Context you get a RequestDispatcher to the
desired JSP resource. When working with Portlets you probably need to do
same. Unfortunately I cannot see a comparable method "getContext()" in the
class "PortletContext". Or maybe not unfortunately - this is how the Portlet
API is designed.
Sven.
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org