struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Gainty <mgai...@hotmail.com>
Subject RE: Two quickies; #session, and old "completeStack"
Date Tue, 02 Jul 2013 10:01:38 GMT
 


 
> From: lukaszlenart@apache.org
> Date: Tue, 2 Jul 2013 09:04:20 +0200
> Subject: Re: Two quickies; #session, and old "completeStack"
> To: dev@struts.apache.org
> 
> 2013/6/22 Dave Newton <davelnewton@gmail.com>:
> > 1) Where does #session get set now? It used to happen in the old
> > dispatcher, IIRC. Now the only place I see after cursory inspection is in
> > CreateSessionInterceptor, which isn't in the default stack.
> >
> > Does this mean that #session doesn't contain the current servlet session
> > attribute map any more, or do I just need to take a step back and step
> > through everything again?
> 
> Session isn't created by S2 if not needed ;-) And the context is
> populated with session in Dispatcher class, line 668.
> 
> > 2) Let's deprecate "completeStack" from struts-default.xml for the next
> > "major" release, if nobody minds. I'd like to start taking some cruft out.
> 
> +1
> 
> > 2a) Like the old dispatchers ;)
> 
> WhyMG>at the bank I read the authenticating tokens into a struts app with custom authenticator
MG>after authenticating cert
MG>if HTTP_REFERER GPS coords said Poland I redirect HTTP-301 Location=Warsawza
MG>If HTTP_REFERER GPS coord said Jersey I redirect HTTP-301 Location=NYMG>Take a look
at this
MG> protected void doExecute(String finalLocation, ActionInvocation invocation) throws
Exception {
        ActionContext ctx = invocation.getInvocationContext();
        HttpServletRequest request = (HttpServletRequest) ctx.get(ServletActionContext.HTTP_REQUEST);
        HttpServletResponse response = (HttpServletResponse) ctx.get(ServletActionContext.HTTP_RESPONSE);
       if (isPathUrl(finalLocation)) {
            if (!finalLocation.startsWith("/")) {
                ActionMapping mapping = actionMapper.getMapping(request, Dispatcher.getInstance().getConfigurationManager());
                String namespace = null;
                if (mapping != null) {
                    namespace = mapping.getNamespace();
                }                if ((namespace != null) && (namespace.length() >
0) && (!"/".equals(namespace))) {
                    finalLocation = namespace + "/" + finalLocation;
                } else {
                    finalLocation = "/" + finalLocation;
                }
            }            // if the URL's are relative to the servlet context, append the servlet
context path
            if (prependServletContext && (request.getContextPath() != null) &&
(request.getContextPath().length() > 0)) {
                finalLocation = request.getContextPath() + finalLocation;
            }            ResultConfig resultConfig = invocation.getProxy().getConfig().getResults().get(invocation.getResultCode());
            if (resultConfig != null) {
                Map<String, String> resultConfigParams = resultConfig.getParams(); 
              for (Map.Entry<String, String> e : resultConfigParams.entrySet()) {
                    if (!getProhibitedResultParams().contains(e.getKey())) {
                        String potentialValue = e.getValue() == null ? "" : conditionalParse(e.getValue(),
invocation);
                        if (!suppressEmptyParameters || ((potentialValue != null) &&
(potentialValue.length() > 0))) {
                            requestParameters.put(e.getKey(), potentialValue);
                        }
                    }
                }
            }            StringBuilder tmpLocation = new StringBuilder(finalLocation);
            urlHelper.buildParametersString(requestParameters, tmpLocation, "&");    
       // add the anchor
            if (anchor != null) {
                tmpLocation.append('#').append(anchor);
            }            finalLocation = response.encodeRedirectURL(tmpLocation.toString());
        }        if (LOG.isDebugEnabled()) {
            LOG.debug("Redirecting to finalLocation " + finalLocation);
        }        sendRedirect(response, finalLocation);
    }MG>this confines finalLocations to Struts Universe for actions mapped to only this
server
MG>there is no accomodation for URLS other than the server you are working on
MG>http://warsazwa.bigbank.com/strutsAction.do
ORMG>http://newyork.bigbank.com/strutsAction.do

MG>in this case I had no choice but to access the dispatcher directly
MG>finalLocation = "http://warsazwa.bigbank.com/strutsAction.do";
MG>HttpServletRequest request = ServletActionContext.getRequest();
MG>HttpServletResponse request = ServletActionContext.getResponse();
MG>RequestDispatcher dispatcher = request.getRequestDispatcher(finalLocation);
MG>dispatcher.forward(request, response)
MG>
MG>is there a way to accomplish redirect/forward without accessing the dispatcher?


> 
> Regards
> -- 
> Ɓukasz
> + 48 606 323 122 http://www.lenart.org.pl/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 
 		 	   		  
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message