Folks,
for posterity, I solved the problem using the request header fields.
1. the host header field is always guaranteed (according to the HTTP
spec http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23) to
exist.
2. The referer header field is always there because I'm handling a form
submit request from my Tap5 Login page, and therefore, the referer is my
login page.
3. I inject the RequestGlobals into my page class to get access to the
HttpServletRequest object. I could have used an injected Request object
to get the header fields and context path, but my page also needed the
underlying HttpSession and ServletContext objects.
Because I'm paranoid, I wrote the following code
HttpServletRequest req =
_requestGlobals.getHTTPServletRequest();
String referer = req.getHeader( "referer" );
String host = req.getHeader( "host" );
String contextPath = req.getContextPath();
String page = "";
if (referer != null && contextPath != null &&
referer.contains( contextPath )) {
page = referer.substring( 0, referer.indexOf(
contextPath ) ) + contextPath + "/customerSearch.jsp";
} else if (referer == null) {
page = "http://" + host + contextPath +
"/customerSearch.jsp";
}
_logger.info( "Jumping to: " + page );
return new URL(page);
Hope this helps anyone in the same boat as I was,
Jonathan
On 03/01/2009 20:22, Howard Lewis Ship wrote:
You can return a URL no problem. The trick is to generate a proper
URL even when behind a firewall.
On Fri, Jan 2, 2009 at 9:51 AM, Jonathan O'Connor<ninki...@eircom.net> wrote:
Hi,
it must be too much Christmas cheer, but I am not sure how to jump to a
non-Tapestry URL in the same web app.
A little background: We have an old application written in Struts 1.1. I
have written my own Login page, called the old code to the user validation
and updating of the session.
This all works ala Kent Tong's eBook on Tap4. Now I want to jump to main
struts page of my app.
My onSuccess() method needs to return a Link or a URL, but according to the
docs, the URL should be used for completely external addresses (e.g.
google.com).
Can I inject a Link (LinkImpl is in the internal package, and so unusable)?
Or should I generate a relative URL?
Thanks and Happy New Year to one and all,
Jonathan O'Connor
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org