Foros de discusión

Linking to a JSP page in a simple JSP portlet

Thomas Kellerer, modificado hace 14 años.

Linking to a JSP page in a simple JSP portlet

Expert Mensajes: 490 Fecha de incorporación: 9/06/08 Mensajes recientes
I'm trying create a simple JSP portlet (as there is no HTML portlet that displays a bunch of static HTML pages)

The portlet was created using the plugins-sdk (so the portlet class is the JSPPortlet)

In my first JSP page I'm trying to link to another jsp page. What I tried is the following:

<a href="<portlet:renderURL><portlet:param name=" jspPage" value="second.jsp"></a>"&gt;Goto second page

But when I click on the link, I just get a blank portlet display.

The JSPPortlet does check for a parameter "jspPage", so what am I missing here?

Regards
Thomas

P.S.: I would really like to see a portlet where I can throw in a bunch of HTML files and they are "simply" displayed...
Oliver Bayer, modificado hace 14 años.

RE: Linking to a JSP page in a simple JSP portlet

Liferay Master Mensajes: 894 Fecha de incorporación: 18/02/09 Mensajes recientes
Hi Thomas,

I've wrote a portlet with different jsps which are called after process actions (caught by annotations). So inside the JSPPortlet class wrote something like this:
resp.setRenderParameter("jspPage", yourOtherJSP);

with yourOtherJSP defined like this inside the init() method:
String yourOtherJSP= getInitParameter("your-other-jsp");

Inside the "portlet.xml" file of your portlet project inside the sdk insert the following lines:
<init-param>
<name>your-other-jsp</name>
<value>/jsps/yourOtherJSP.jsp</value>
</init-param>

Change the value which is the path to the jsp to fit your folder structure.

Greets Oli
Thomas Kellerer, modificado hace 14 años.

RE: Linking to a JSP page in a simple JSP portlet

Expert Mensajes: 490 Fecha de incorporación: 9/06/08 Mensajes recientes
Thanks, but that doesn't help me in my situation as I need a href pointing to the page.

But in the meantime I found the error. The parameter value for the target jsp page must have a leading /


<portlet:param name="jspPage" value="/second.jsp" />



But now I'm facing a new problem: I did some changes to the portlet and suddenly I cannot deploy my portlet anymore. When doing so I get the following exception:

 com.sample.portlet.JSPPortlet cannot be cast to javax.portlet.Portlet 


The portlet is defined as
JSPPortlet extends GenericPortlet

so I don't understand this ClassCastException....
Tim Mi Midd, modificado hace 14 años.

RE: Linking to a JSP page in a simple JSP portlet

New Member Mensajes: 11 Fecha de incorporación: 16/10/09 Mensajes recientes
I am having the same issues, Thomas have anybody given you any help or have your figured out something that I could possibly use?
thumbnail
Olaf Kock, modificado hace 14 años.

RE: Linking to a JSP page in a simple JSP portlet

Liferay Legend Mensajes: 6403 Fecha de incorporación: 23/09/08 Mensajes recientes
This kind of exception usually happens when some classes are twice on the classpath - e.g. javax.portlet.Portlet in this case. You're inheriting from one but the typecast tries to cast to the other. The message is puzzling, but once you grasp that there are two distinct instances with the same name, it makes a lot more sense.

I guess you deployed too many jars with your own portlet - especially "portlet.jar" should be on the server's classpath, not on the webapp's/portlet's. That's why the default bundle has it in TOMCAT_HOME/lib/ext. It must not go to TOMCAT_HOME/webapps/YOUR_WEBAPP/WEB-INF/lib!
Thomas Kellerer, modificado hace 14 años.

RE: Linking to a JSP page in a simple JSP portlet

Expert Mensajes: 490 Fecha de incorporación: 9/06/08 Mensajes recientes
Olaf Kock:
This kind of exception usually happens when some classes are twice on the classpath - e.g. javax.portlet.Portlet in this case. You're inheriting from one but the typecast tries to cast to the other. The message is puzzling, but once you grasp that there are two distinct instances with the same name, it makes a lot more sense.

I guess you deployed too many jars with your own portlet - especially "portlet.jar" should be on the server's classpath, not on the webapp's/portlet's. That's why the default bundle has it in TOMCAT_HOME/lib/ext. It must not go to TOMCAT_HOME/webapps/YOUR_WEBAPP/WEB-INF/lib!


Thanks for the answer, that indeed was the reason. In one of my first tries, I accidently added portlet-api.jar to the WEB-INF/lib, but then when getting the error removed it (as I assumed a classpath problem).

For some reason re-deploying with the new .war file didn't remove copies of the old WEB-INF/lib that were stored in the Tomcat's temp folder (due to the antiJarLocking attribute that was set by Liferay's build script initially). So even when re-deploying with no jars at all, the error showed up.

After deleting everything in Tomcat's temp folder things are working now.

Now if I can only get my language hook to work ;)
Avinash kumar, modificado hace 8 años.

RE: Linking to a JSP page in a simple JSP portlet

New Member Mensajes: 15 Fecha de incorporación: 15/12/15 Mensajes recientes
Hi All ,

I tried the below code to call one jsp from another

<portlet:renderURL var="showjspURL"><portlet:param name="mvcPath" value="/pages/NewFile.jsp" /></portlet:renderURL><a href="<%= showjspURL.toString() %>" >New Page</a>

When I click on the link the jsp page is called but it doesnot dispaly the liferay default theme. Initially while loading the page it displays but when the page complete get loaded it doesnot dispaly the default theme.
It only loads the page in the portlet but the liferay control panel dock , navigation page is not loaded.

I am using liferay 6.2

Can anyone tell me what could be the issue?

Thanks
Avinash