Forums de discussion

Protlet that link to a JSP

Ciccio Pasticcio, modifié il y a 14 années.

Protlet that link to a JSP

Junior Member Publications: 39 Date d'inscription: 22/10/09 Publications récentes
Hi all,
I have a portlet that theoretically it must see to me a link that open a new jsp.

But pratically it dont's work.

The result when I click in the link to JSP is that appear a new liferay windows that show the original portlet of the link.

My code is this:


<%@ page import="com.liferay.portal.model.User" %>
<%@page import="com.liferay.portal.theme.ThemeDisplay" %>
<%@page import="com.liferay.portal.util.WebKeys" %>
<%@page import="com.liferay.portal.util.PortalUtil" %>
<%@page import="javax.portlet.PortletRequest" %>

<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<portlet:defineobjects />


<p> Portlet che permette di aprire come pop-up
    l'applicazione PBO.</p>

<br>
<br>

<p align="center">
    <a href="............" target="_blank">PBO</a>
</p>

<p align="center">
    <a href="/SSO_PBO.jsp" target="_blank">SSO_PBO</a>
    <br>
    <a href="<portlet:actionURL><portlet:param name=" jspPage" value="/SSO_PBO.jsp"></a>" target="_blank"&gt;SSO PBO
</p>


Can i give me a solution?

VERY THANKS
thumbnail
Tarun S. Kayasth, modifié il y a 14 années.

RE: Protlet that link to a JSP

Regular Member Publications: 162 Date d'inscription: 08/06/07 Publications récentes
Hi Ciccio,

what tis the physical location of "SSO_PBO.jsp" in tomcat?
In liferay the path "/SSO_PBO" refurs to friendly url of the page created.

Thanks,
Tarun Kayasth
Ciccio Pasticcio, modifié il y a 14 années.

RE: Protlet that link to a JSP

Junior Member Publications: 39 Date d'inscription: 22/10/09 Publications récentes
Tarun S. Kayasth:
Hi Ciccio,

what tis the physical location of "SSO_PBO.jsp" in tomcat?
In liferay the path "/SSO_PBO" refurs to friendly url of the page created.

Thanks,
Tarun Kayasth


Hi Tarun,
thank for the replay.

The SSO_PBO.jsp is under the portlet project, so in this path :
C:\liferay\server\tomcat\webapps\pbo-5.2.3.1\html\SSO_PBO.jsp
... It's wrong,right?

Where must I put it?
THANKS
thumbnail
Ziggy ., modifié il y a 14 années.

RE: Protlet that link to a JSP

Expert Publications: 293 Date d'inscription: 08/06/08 Publications récentes
Should it not be in C:\liferay\server\tomcat\webapps\ROOT\SSO_PBO.jsp ? I could be wrong.. emoticon
Ciccio Pasticcio, modifié il y a 14 années.

RE: Protlet that link to a JSP

Junior Member Publications: 39 Date d'inscription: 22/10/09 Publications récentes
Ziggy .:
Should it not be in C:\liferay\server\tomcat\webapps\ROOT\SSO_PBO.jsp ? I could be wrong.. emoticon


Thanks for the response...
But I try to put SSO_PBO.jsp in this folder C:\liferay\server\tomcat\webapps\ROOT, but the response is the same....

The requested resource was not found. 

http://localhost:8080/web/guest/SSO_PBO.jsp 


HELP PLEASE

THANKS
thumbnail
Dhrutika parekh, modifié il y a 14 années.

RE: Protlet that link to a JSP

Expert Publications: 435 Date d'inscription: 09/02/09 Publications récentes
Ciccio Pasticcio:
Ziggy .:
Should it not be in C:\liferay\server\tomcat\webapps\ROOT\SSO_PBO.jsp ? I could be wrong.. emoticon


Thanks for the response...
But I try to put SSO_PBO.jsp in this folder C:\liferay\server\tomcat\webapps\ROOT, but the response is the same....

The requested resource was not found. 

http://localhost:8080/web/guest/SSO_PBO.jsp 


HELP PLEASE

THANKS



Hi,

If you put your jsp at C:\liferay\server\tomcat\webapps\ROOT,
then you can access it by http://localhost:8080/SSO_PBO.jsp ,so this will open your jsp file.
So you need to remove /web/guest.

Try it out,hope it helps..

Thanks,
Dhrutika Parekh

Cignex Technologies Pvt Ltd.
thumbnail
Giri P, modifié il y a 14 années.

RE: Protlet that link to a JSP

Regular Member Publications: 137 Date d'inscription: 20/08/09 Publications récentes
Hi CISCO,
I'm also facing the same problem.
If you find the solution for this please let me know.

Please have a look at hera

Thanks in advance,
Giri
thumbnail
Tarun S. Kayasth, modifié il y a 14 années.

RE: Protlet that link to a JSP

Regular Member Publications: 162 Date d'inscription: 08/06/07 Publications récentes
Hi CISCO/Giri,

If your jsp file location is "\tomcat-6.0.18\webapps\ROOT\html\portlet\ext\test.jsp"
then you can have a link like "<a href="/html/portlet/ext/test.jsp">Link to test.jsp</a>"

Thanks,

Tarun Kayasth
thumbnail
Giri P, modifié il y a 14 années.

RE: Protlet that link to a JSP

Regular Member Publications: 137 Date d'inscription: 20/08/09 Publications récentes
Hi Kayasth,
Thanks for your reply. Actually my jsp is in the same portlet i.e in the same directory of calling jsp.(NOT IN ROOT)

The following is my code, Please have a look.


 
 &lt;%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %&gt;
 <portlet:defineobjects />
 &lt;% response.addHeader("Refresh","60"); %&gt;
 
 &lt;%--
 <meta HTTP-EQUIV="Refresh" CONTENT="3">
--%&gt;

<title>URL TEST PORTLET</title>


<a href="<portlet:renderURL><portlet:param name=" jspPage" value="test.jsp"></a>"&gt;Click Me



Please advice me.
Thanks in advance.
Giri
thumbnail
Dhrutika parekh, modifié il y a 14 années.

RE: Protlet that link to a JSP

Expert Publications: 435 Date d'inscription: 09/02/09 Publications récentes
Hi,

Just replace your href tag by this.

<A href="<portlet:renderURL><portlet:param name="jspPage" value="/test.jsp" /></portlet:renderURL>">Click Me</A>

This will work.


Thanks,
Dhrutika Parekh

Cignex Technologies Pvt Ltd.
thumbnail
Giri P, modifié il y a 14 années.

RE: Protlet that link to a JSP

Regular Member Publications: 137 Date d'inscription: 20/08/09 Publications récentes
Hi Dhrutika,
Thanks for your reply.

I have been updated this link but still not working. Whenever I click on this link, Then the page is just refreshed.

here is my view.jsp



 
 &lt;%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %&gt;
 <portlet:defineobjects />
 &lt;% response.addHeader("Refresh","60"); %&gt;
 


<title>URL TEST PORTLET</title>



<a href="<portlet:renderURL><portlet:param name=" jspPage" value="/test.jsp"></a>"&gt;Click Me 




Do I need to put any code in MyPortlet.java or portlet.xml?

The following is MyPortlet.java

public class MyPortlet extends GenericPortlet {
	protected void doView(RenderRequest rRequest, RenderResponse rResponse)
			throws PortletException, IOException, UnavailableException {
		rResponse.setContentType("text/html");
		PortletRequestDispatcher prd = getPortletContext()
				.getRequestDispatcher("/jsp/view.jsp");
		prd.include(rRequest, rResponse);
	
		
	}


ones again thanks for your support.

giri
thumbnail
Dhrutika parekh, modifié il y a 14 années.

RE: Protlet that link to a JSP

Expert Publications: 435 Date d'inscription: 09/02/09 Publications récentes
Hi,

I dont know what problem is there,because I have sample jsp portlet in which

View.jsp:

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

This is the <b>Sample JSP Portlet</b>. Use this as a quick way to include JSPs.

<A href="<portlet:renderURL><portlet:param name="jspPage" value="/test.jsp" /></portlet:renderURL>">Click Me</A>

and
test.jsp:

Inside Test JSP

And JSP's location is under /sample-portlet/docroot/view.jsp and /sample-portlet/docroot/test.jsp


Thanks,
Dhrutika Parekh
thumbnail
Giri P, modifié il y a 14 années.

RE: Protlet that link to a JSP

Regular Member Publications: 137 Date d'inscription: 20/08/09 Publications récentes
Hi Dhrutka,
Same thin i'm also doing..

Can you attache your sample portlet here...

Thanks for your support.
Giri
thumbnail
Dhrutika parekh, modifié il y a 14 années.

RE: Protlet that link to a JSP

Expert Publications: 435 Date d'inscription: 09/02/09 Publications récentes
Hi,

I have attached my sample-portlet. I have devloped using plugins sdk

Thanks,
Dhrutika Parekh
thumbnail
Giri P, modifié il y a 14 années.

RE: Protlet that link to a JSP

Regular Member Publications: 137 Date d'inscription: 20/08/09 Publications récentes
Hi Dhrutika,
this helps a lot.
Now my problem is resolved.
Thanks for contributing your code.

Regards,
Giri
thumbnail
Dhrutika parekh, modifié il y a 14 années.

RE: Protlet that link to a JSP

Expert Publications: 435 Date d'inscription: 09/02/09 Publications récentes
Hi,

Welcome.So where you were making mistake??
thumbnail
Giri P, modifié il y a 14 années.

RE: Protlet that link to a JSP

Regular Member Publications: 137 Date d'inscription: 20/08/09 Publications récentes
Hi Dhrutika,
Thanks for your contribution and support for over comming this problem.
Actually, I have not used the method doDispatch() in my Portlet.

public void doDispatch(RenderRequest renderRequest,
			RenderResponse renderResponse) throws IOException, PortletException {

		String jspPage = renderRequest.getParameter("jspPage");

		if (jspPage != null) {
			include(jspPage, renderRequest, renderResponse);
		} else {
			super.doDispatch(renderRequest, renderResponse);
		}
		System.out.println("Inside doDispatch");
	}


So, This causing me the problem.

Regards,
Giri
Mau COMBE, modifié il y a 13 années.

RE: Protlet that link to a JSP

New Member Publications: 16 Date d'inscription: 10/03/11 Publications récentes
I hope it can help


public class CtrlPort extends MVCPortlet {

	// An processAction method
	@SuppressWarnings("unchecked")
	public void myProcessAction(ActionRequest actionRequest, ActionResponse actionResponse)
			throws IOException, PortletException {


		String jspPage = actionRequest.getParameter("jspPage");

		if (jspPage != null) {
			[color=#F30C0C]actionResponse.setRenderParameter("_view",jspPage);[/color]//Send view to "render" phase
		
                          }

	}//End of myProcessAction

	
	 // Dispatch to a jsp method.
	protected void dispatch(RenderRequest renderRequest, RenderResponse renderResponse, String path)
			throws PortletException, IOException {

		[color=#F30C0C]PortletContext ctx = getPortletContext();
		PortletRequestDispatcher dispatcher = ctx.getRequestDispatcher(path);
		dispatcher.include(renderRequest, renderResponse);[/color]

	}

	@Override
	public void doDispatch(RenderRequest renderRequest, RenderResponse renderResponse)
			throws PortletException, IOException {
		
		[color=#F30A0A]if (renderRequest.getParameter("_view") != null) {
			dispatch(renderRequest, renderResponse, renderRequest.getParameter("_view"));//Get view from Action
		} else {
			super.doDispatch(renderRequest, renderResponse);//Default view if "_view" doesn't exist
		}[/color]
	}

}// End of portlet