Monday, March 14, 2011

404 page not found error

Question :

really need your help here,
I have a simple struts portlet "MNPPortlet" it contains some JSPs as the below hirearchy

MNPPortlet
WebContent
pages
A.jsp
B.jsp

I just want to open B.jsp in a popup window or in an iframe from A.jsp, I have tried the following
1- window.open("B.jsp")
2

but it doesn't seem to work, I always get 404 page not found error, since it generates wrong URLs, any ideas how can i get the right URIs generated ?
P.S. it's working fine as struts application, not portlet

Answer :
In order to run something as a portlet, you need to create all non-external URLs using appropriate Portal tags so that the portal can re-write the URLs as needed. This allows the portal framework to re-write the URLs depending on how the portlet is being run (for example, over WSRP or not).

In this particular case, where you're trying to access another JSP file directly (not running it through the portal framework, as it is inside an IFrame or in a pop-up window), a "resource URL" would be the appropriate way to go. The render tag library's resourceURL tag should fix your issue:

http://download.oracle.com/docs/cd/E13155_01/wlp/docs103/javadocjsp/framework/render/resourceUrl.html




1 comment: