Foros de discusión

Redirect from one jsp to another

Seeya S Kudtarker, modificado hace 11 años.

Redirect from one jsp to another

Regular Member Mensajes: 187 Fecha de incorporación: 16/01/13 Mensajes recientes
I am using view.jsp for adding data and I want to redirect to another jsp page to see my data.
This is what i have done in view. jsp to redirect to another jsp

<portlet:renderURL var="viewEmployeeDataURL">
<portlet:param name="viewEmployeeData" value="/admin/viewEmployeeData.jsp" />

</portlet:renderURL>

<a href="<%= viewEmployeeDataURL %>">View Employee Details</a>


The above code I have written after </aui:form>

But when I run this code and click on "View Employee Details" I get the same view.jsp page instead of getting redirected to viewEmployeeData.jsp page

What changes should I make to the code to jump to viewEmployeeData jsp page?
Dhvanil Reshamwala, modificado hace 11 años.

RE: Redirect from one jsp to another

New Member Mensajes: 13 Fecha de incorporación: 23/12/11 Mensajes recientes
Hi Seeya,
I think you will have to provide param name as 'redirect'. Then Liferay will automatically redirect to the JSP provided.
thumbnail
Gnaniyar Zubair, modificado hace 11 años.

RE: Redirect from one jsp to another

Liferay Master Mensajes: 722 Fecha de incorporación: 19/12/07 Mensajes recientes
Try this:

<portlet:param name="jspPage" value="/admin/viewEmployeeData.jsp" />
Seeya S Kudtarker, modificado hace 11 años.

RE: Redirect from one jsp to another

Regular Member Mensajes: 187 Fecha de incorporación: 16/01/13 Mensajes recientes
Gnaniyar Zubair:

Thanks!! It works now
Himanshu Arora, modificado hace 10 años.

RE: Redirect from one jsp to another

New Member Mensajes: 5 Fecha de incorporación: 16/05/12 Mensajes recientes
i am not able to redirect to other jsp.
I have the following code in my view.jsp :-


<portlet:renderURL var="anotherURL">
<portlet:param name="jspPage" value="WEB-INF/jsp/register.jsp" />
</portlet:renderURL>
<%= anotherURL %>
<h3>Click <a href="<%=anotherURL %>>" >here</a> to register
</h3>


but in anotherUrl i am getting the following link :-

"http://localhost:8080/web/guest/home?p_p_id=SpringPortlet_WAR_SpringPortletportlet&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=2&_SpringPortlet_WAR_SpringPortletportlet_jspPage=WEB-INF%2Fjsp%2Fregister.jsp"
thumbnail
Zsigmond Rab, modificado hace 10 años.

RE: Redirect from one jsp to another

Liferay Master Mensajes: 728 Fecha de incorporación: 5/01/10 Mensajes recientes
Hi Himanshu,

which version of Liferay are you using and which type of portlet do you have? In later versions the parameter name is mvcPath.

On the other hand, the value of this have to be a relative path to the file. Are you sure about that the value is fine. It's suspicious for me.

Regards,
Zsigmond
Himanshu Arora, modificado hace 10 años.

RE: Redirect from one jsp to another

New Member Mensajes: 5 Fecha de incorporación: 16/05/12 Mensajes recientes
Hi Zsigmond ,
I am using Liferay 6.1 CE and i have created spring mvc protlet without doview and processaction method. I want to redirect to another jsp register.jsp just like we can redirect in spring mvc application using <a>.
As suggested by you i have changed the code to :-

<portlet:renderURL var="anotherURL">
<portlet:param name="mvcPath" value="/register.jsp" />
</portlet:renderURL>
<%= anotherURL %>
<h3>Click <a href="<%=anotherURL %>>" >here</a> to register
</h3>

and i am getting the following value in anotherURL= "http://localhost:8080/web/guest/home?p_p_id=SpringPortlet_WAR_SpringPortletportlet&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=2&_SpringPortlet_WAR_SpringPortletportlet_mvcPath=%2Fregister.jsp "

Thanks for your help. :-)
thumbnail
Zsigmond Rab, modificado hace 10 años.

RE: Redirect from one jsp to another

Liferay Master Mensajes: 728 Fecha de incorporación: 5/01/10 Mensajes recientes
Hi Himanshu,

is it working then?

Regards,
Zsigmond
Himanshu Arora, modificado hace 10 años.

RE: Redirect from one jsp to another

New Member Mensajes: 5 Fecha de incorporación: 16/05/12 Mensajes recientes
But still it is not working.
thumbnail
Ahmed Hasan, modificado hace 10 años.

RE: Redirect from one jsp to another

Expert Mensajes: 306 Fecha de incorporación: 13/04/07 Mensajes recientes
Hi Himanshu,

I ve covered this in simple steps in chapter number 4 of my free eBook on Liferay development. You can download a free copy and refer there. Also give your feedback and comments.

Yours truly,
Ahamed Hasan
Author, Liferay Portlet Cookbook
Arun Kumar S, modificado hace 10 años.

RE: Redirect from one jsp to another

Regular Member Mensajes: 182 Fecha de incorporación: 23/06/08 Mensajes recientes
Hi,

<portlet:param name="mvcPath" value="/register.jsp" />
will not work in Spring MVC Portlet.

Add following code into jsp file.

<portlet:renderurl var="renderjspURL">
 <portlet:param name="action" value="renderjsp"></portlet:param>
</portlet:renderurl>

<a href="${renderjspURL}">Click here</a>

Add following code in Controller class

@RenderMapping(params = "action=renderjsp")
public String renderjsp(RenderRequest request, RenderResponse response, Model model){
  return "test";
 }


Result :-
test.jsp will display


Hope this helps.
Thanks,
Arun!
thumbnail
Manupoti Subrahmanyam, modificado hace 8 años.

Re: [Liferay Forums][General] RE: Redirect from one jsp to another

Junior Member Mensajes: 39 Fecha de incorporación: 12/04/13 Mensajes recientes
Hi,

Create Render URL :
It has parameter name "jspPage" and value as "/jsp/register.jsp".

<portlet:renderURL var="anotherURL">
<portlet:param name="jspPage" value="/jsp/register.
jsp" />
</portlet:renderURL>
<%= anotherURL..toString() %>

On click of Button :

<aui:button
type="cancel"
value="Cancel"
onClick="<%= anotherURL.toString() %>"
/>

On click of Link :

<a href="<%= anotherURL.toString() %>" >to register </a>

If you are using MVCPortlet then you need to do
response.setRenderParameter("jspPage","/jsp/register.jsp")

but if you are using GenericPortlet (means extending that in your custom
portlet) override doView() and can write following code:
include(your-jsp, renderRequest, renderResponse);


Regards
Subrahmanyam


On Wed, Aug 28, 2013 at 11:24 AM, Himanshu Arora from liferay.com <
forums@liferay.com> wrote:

> i am not able to redirect to other jsp.
> I have the following code in my view.jsp :-
>
>
> <portlet:renderURL var="anotherURL">
> <portlet:param name="jspPage" value="WEB-INF/jsp/register.jsp" />
> </portlet:renderURL>
> <%= anotherURL %>
> <h3>Click <a href="<%=anotherURL %>>" >here</a> to register
> </h3>
>
>
> but in anotherUrl i am getting the following link :-
>
> "
> http://localhost:8080/web/guest/home?p_p_id=SpringPortlet_WAR_SpringPortletportlet&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=2&_SpringPortlet_WAR_SpringPortletportlet_jspPage=WEB-INF%2Fjsp%2Fregister.jsp"
>
>
>
> To view the thread, follow the link below:
>
> http://www.liferay.com/community/forums/-/message_boards/view_message/27747151
> --
> Liferay.com <http://www.liferay.com>