You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Luc Foisy <Lu...@technical-magic.com> on 2004/04/07 16:35:30 UTC

handling page redirects

I have the following in a jsp file

<%@ include file="applicationimports.inc" %>
<%@ include file="connection.inc" %>
<%@ include file="sessioncheck.inc" %>

<%
	CustomerHTTPManagementScreen customerHTTPManagementScreen = (CustomerHTTPManagementScreen)session.getAttribute("customerHTTPManagementScreen");
	if( customerHTTPManagementScreen == null )
	{
		response.sendRedirect(tmWebApp.getTMTokenizedPageProcessor().tokenizeLink("main.jsp"));
		return;
	}
	if( request.getParameter("submit") != null )
	{
		if( request.getParameter("submit").equals("Modify Order") )
		{
			response.sendRedirect(tmWebApp.getTMTokenizedPageProcessor().tokenizeLink("orderentry.jsp?OpenOrder=" + customerHTTPManagementScreen.getOrderHeaderID()));
			return;
		}
		String key;
		Hashtable parameters = new Hashtable();
		for( Enumeration e = request.getParameterNames(); e.hasMoreElements() ;)
		{
			key = (String)e.nextElement();
			parameters.put(key, request.getParameter(key));
		}
		customerHTTPManagementScreen.processPerformed( new ProcessEvent(request.getParameter("submit"), parameters) );
	}
	response.sendRedirect(tmWebApp.getTMTokenizedPageProcessor().tokenizeLink("customer.jsp"));
%>

This file handles the processing for its connected jsp page (it is directed here to do the processing).
As you can see near the end is calls processPerformed, that sends the submit to the parent class. The parent class then does most of the process, then it is redirected back to the connected parent jsp (in this case custoner.jsp)
What I want to do here is get the submit of "Modify Order" to be handled by my web application. My web application main class is tmWebApp, it already has response and request available to it, so I could call the redirect from there.

The problem is, this jsp file will then try to redirect the page again on the last call. How do I determine if the application already redirected this?

Is my only option to catch an IllegalStateException or check isCommited()? Not as if that is a bad idea, but would there be anything else here that would get in my way, like is there anything else that would set that response to be commited?

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org