Foren

get full url from HttpServletRequest

Adrian Pol, geändert vor 7 Jahren.

get full url from HttpServletRequest

Junior Member Beiträge: 49 Beitrittsdatum: 14.03.17 Neueste Beiträge
When do that:

private String getFullURL(HttpServletRequest request) {
String url = request.getRequestURL().toString();
return url;
}

it always return 'http://localhost:8080/c' always i try to loging from other page for example this 'http://localhost:8080/web/web-test/ofertas' the return is 'http://localhost:8080/c'...

I'am in Hook event pre of login this is the class:

import javax.portlet.PortletRequest;
import javax.portlet.RenderRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.liferay.portal.kernel.events.ActionException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.theme.ThemeDisplay;
import com.liferay.portal.util.PortalUtil;
import com.liferay.portlet.PortletURLUtil;

public class CurrentPageLuncher extends Action {
private final static Log log = LogFactoryUtil.getLog(CurrentPageLuncher.class);
/* (non-Java-doc)
* @see com.liferay.portal.kernel.events.Action#Action()
*/
public CurrentPageLuncher() {
super();
}

/* (non-Java-doc)
* @see com.liferay.portal.kernel.events.Action#run(HttpServletRequest arg0, HttpServletResponse arg1)
*/
public void run(HttpServletRequest arg0, HttpServletResponse arg1) throws ActionException {
String url = getFullURL(arg0);
log.info("you're in: " + url + "!!!!!!!!!!!!!!!!!!!!");
}

private String getFullURL(HttpServletRequest request) {
String url = request.getRequestURL().toString();
return url;
}

}
thumbnail
Olaf Kock, geändert vor 7 Jahren.

RE: get full url from HttpServletRequest

Liferay Legend Beiträge: 6396 Beitrittsdatum: 23.09.08 Neueste Beiträge
Adrian Pol:
When do that:
...
it always return 'http://localhost:8080/c' always i try to loging from other page for example this 'http://localhost:8080/web/web-test/ofertas' the return is 'http://localhost:8080/c'...

I'am in Hook event pre of login this is the class:


In a pre-login-event you're not in the request for a particular page. That page might be protected, with the user currently logging in not having access to it. Thus the request is a different one than the page that it later will be redirected to.

That opens the standard question: What are you actually trying to achieve?
Adrian Pol, geändert vor 7 Jahren.

RE: get full url from HttpServletRequest

Junior Member Beiträge: 49 Beitrittsdatum: 14.03.17 Neueste Beiträge
Okay, nothing really, was a exercise that should return for console (Log) The current page that you are login emoticon