This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

linking jsp pages in a liferay portlet  RSS feed

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to make a very basic portlet where 1 jsp page links to another. Nothing more. I create a war file and deploy in liferay. The portlet displays fine. The problem is that the pages I try to link to can not be found. For example,
When the portlet loads, page1.jsp is displayed. It contains the code:

page1.jsp and page2.jsp are both located in the same place, the WebContent folder.

When I click on the link which I expect will load page1 in the portlet, I get the error:

The requested resource was not found: http://xxx.xxx.x.xx/web/guest/page2.jsp

My portlet.xml file to initialize the portlet contains the code:

As page1 and page2 are both in the same directory, I am puzzled why page2 can not be found.
Perhaps there is some directory or context structure I should be specifying in the portlet.xml file?

Any help greatly appreciated.
Thanks
e
 
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is a common question.

In your case, it is looking for page2.jsp in the whole portal (as you might see from the address bar after you click that link)

to make it link to and find page2.jsp within your portlet, use the portlet tags that come with javax.portlet:


 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have similar problems using links in portlets.
Do I need to change anything in doView() or processAction method after using the renderURL in the _view.jsp
In which folder does the "page2.jsp" have to be in when using value="/page2.jsp"?

I have searched for a while for any working solution but I didn`t get it by now..
thanks
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the same issue when trying to link to a page that is in a subfolder. How can this be done? I have a Spring portlet in Liferay I'm trying to link to. here is the code I have:


Thanks
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Julian Hee wrote:Hi,
I have similar problems using links in portlets.
Do I need to change anything in doView() or processAction method after using the renderURL in the _view.jsp
In which folder does the "page2.jsp" have to be in when using value="/page2.jsp"?

I have searched for a while for any working solution but I didn`t get it by now..
thanks



Hi Julian,

here is my doView method:


viewJSP and page2JSP are simply strings that end up being
/page-two.jsp
and
/view.jsp

respectively

if page-two were in a child folder, then the value of page2JSP should be "/childFolder/page-two.jsp"
 
Julian Hee
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
thanks for you response...but it doesnt work :/

In my view.jsp i got this link


my original doView looks like this



i changed it to:


My folder structure is somethin like this:
Project
- Java Sources
-classes
- WebContent
-Web-Inf
-jsp
-new.jsp
-view.jsp
.....


Probably its quite simple but I dont get it.. do i have do change something in processAction()..or whats the problem...
thanks
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Julian Hee wrote:


My folder structure is somethin like this:
Project
- Java Sources
-classes
- WebContent
-Web-Inf
-jsp
-new.jsp
-view.jsp



the root of your web content is where your jsps should be. Try putting them in the webContent directory.

I notice that you are creating the parameter in your init-params in portlet.xml, you can instead use view-jsp or new-jsp in as the value in the renderURL tag as these are defined already. in the jspPortlet.java, these have to be brought in with the init method:

but maybe it is more clear to just use the string "/jsp/new.jsp"

Note that using the liferay plugins sdk will make all this much easier as it sets up your directory structure, xml files, and java files, allowing you to deploy easiliy with ant commands. Check it out, you will be thankful.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!