I tried to develop some application with Struts, and found that there was no Struts-like way to handle ActionForward with query string, e.g. index.jsp?pid=1. Mainly what I confronted was the following:
ActionForward homeForward = new ActionForward("/portal/index.jsp?pid=" + pageSrno, true); I needed to redirect to a URL, /portal/index.jsp with pid parameter. Simultaneously, there was a global forward correspondent to the URL. <forward name="welcome" path="/portal/index.jsp" redirect="true" /> What I wanted to do is to avoid a hardcoded URL but use an appropriate ActionForward from ActionMapping. For example, ActionForward homeForward = mapping.findForward("welcome"); .. However, in this case it's not possible to attach a parameter in terms of query string. (It is evident that you can use request.setAttribute for passing data to JSPs, but when it comes to redirection, it's useless and query string is necessary for the job.) What I'd like to propose comes from a question, "What if ActionForward has some property for query string?" For instance, homeForward.setQueryString("pid=" + pageSrno); actually means "/portal/index.jsp?pid=1" by combining the global forward and a programmatic query string. For implementing this feature, I added some codes to two classes: In org.apache.struts.config.ForwardConfig protected String queryString = null; public String getQueryString() { return (this.queryString); } public void setQueryString(String queryString) { /* This property can be set dynamically, so the freezing is not demanded. if (configured) { throw new IllegalStateException("Configuration is frozen"); */ } this.queryString = queryString; } In org.apache.struts.action.RequestProcessor protected void processForwardConfig(HttpServletRequest request, HttpServletResponse response, ForwardConfig forward) throws IOException, ServletException { ... // paths not starting with / should be passed through without any processing // (ie. they're absolute) if (forwardPath.startsWith("/")) { uri = RequestUtils.forwardURL(request, forward); // get module relative uri } else { uri = forwardPath; } // Newly added part-processing queryString String queryString = forward.getQueryString(); if (queryString != null) { uri += "?" + queryString; } if (forward.getRedirect()) { // only prepend context path for relative uri if (uri.startsWith("/")) { uri = request.getContextPath() + uri; } response.sendRedirect(response.encodeRedirectURL(uri)); } else { doForward(uri, request, response); } } In conclusion, you can take advantage of global forwards and forwards in actions with redirected parameters like ActionForward homeForward = mapping.findForward("welcome"); homeForward.setQueryString("pid=" + pageSrno); Instead of ActionForward homeForward = new ActionForward("/portal/index.jsp?pid=" + pageSrno, true); If you like to get this proposal as a form of patches, I'm willing to make and submit them to bugzilla. Ias =========================================================== Lee, Changshin (Korean name) Ias (International name) Company Web Site: http://www.tmax.co.kr Personal Web Site: http://www.iasandcb.pe.kr --------------------------------------------------------- Senior Researcher & Java Technology Evangelist JCP member - http://jcp.org/en/participation/members/L R&D Institute Tmax Soft, Inc. JCP member - http://jcp.org/en/participation/members/T ========================================================== --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]