Package org.apache.struts.chain.contexts

Examples of org.apache.struts.chain.contexts.ServletActionContext


        MockActionServlet servlet =
            new MockActionServlet(servletContext, servletConfig);

        servlet.initInternal();

        ServletActionContext saContext =
            new ServletActionContext(servletContext, request,
                new MockHttpServletResponse());

        saContext.setActionServlet(servlet);

        boolean result = command.execute(saContext);

        assertTrue(!result);
View Full Code Here


            new MockActionServlet(servletContext, servletConfig);

        servlet.initInternal();

        this.saContext =
            new ServletActionContext(servletContext, request,
                new MockHttpServletResponse());

        this.saContext.setActionServlet(servlet);
        this.command = new PerformForward();
    }
View Full Code Here

*          $
*/
public class SetContentType extends AbstractSetContentType {
    // ------------------------------------------------------- Protected Methods
    protected void setContentType(ActionContext context, String contentType) {
        ServletActionContext swcontext = (ServletActionContext) context;
        HttpServletResponse response = swcontext.getResponse();

        response.setContentType(contentType);
    }
View Full Code Here

    // ------------------------------------------------------- Protected Methods
    protected void populate(ActionContext context, ActionConfig actionConfig,
        ActionForm actionForm)
        throws Exception {
        ServletActionContext saContext = (ServletActionContext) context;

        RequestUtils.populate(actionForm, actionConfig.getPrefix(),
            actionConfig.getSuffix(), saContext.getRequest());
    }
View Full Code Here

            actionConfig.getSuffix(), saContext.getRequest());
    }

    protected void reset(ActionContext context, ActionConfig actionConfig,
        ActionForm actionForm) {
        ServletActionContext saContext = (ServletActionContext) context;

        actionForm.reset((ActionMapping) actionConfig, saContext.getRequest());

        // Set the multipart class
        if (actionConfig.getMultipartClass() != null) {
            saContext.getRequestScope().put(Globals.MULTIPART_KEY,
                actionConfig.getMultipartClass());
        }
    }
View Full Code Here

*          $
*/
public class SelectAction extends AbstractSelectAction {
    // ------------------------------------------------------- Protected Methods
    protected String getPath(ActionContext context) {
        ServletActionContext saContext = (ServletActionContext) context;
        HttpServletRequest request = saContext.getRequest();
        String path = null;
        boolean extension = false;

        // For prefix matching, match on the path info
        path = (String) request.getAttribute(Constants.INCLUDE_PATH_INFO);

        if (path == null) {
            path = request.getPathInfo();
        }

        // For extension matching, match on the servlet path
        if (path == null) {
            path =
                (String) request.getAttribute(Constants.INCLUDE_SERVLET_PATH);

            if (path == null) {
                path = request.getServletPath();
            }

            if (path == null) {
                throw new IllegalArgumentException(
                    "No path information in request");
            }

            extension = true;
        }

        // Strip the module prefix and extension (if any)
        ModuleConfig moduleConfig = saContext.getModuleConfig();
        String prefix = moduleConfig.getPrefix();

        if (!path.startsWith(prefix)) {
            throw new IllegalArgumentException("Path does not start with '"
                + prefix + "'");
View Full Code Here

*          $
*/
public class SetOriginalURI extends AbstractSetOriginalURI {
    // ------------------------------------------------------- Protected Methods
    protected void setOriginalURI(ActionContext context) {
        ServletActionContext swcontext = (ServletActionContext) context;
        HttpServletRequest request = swcontext.getRequest();

        request.setAttribute(Globals.ORIGINAL_URI_KEY, request.getServletPath());
    }
View Full Code Here

     * <p>Return the <code>Locale</code> to be used for this request.</p>
     *
     * @param context The <code>Context</code> for this request
     */
    protected Locale getLocale(ActionContext context) {
        ServletActionContext saContext = (ServletActionContext) context;

        // Has a Locale already been selected?
        HttpSession session = saContext.getRequest().getSession();
        Locale locale = (Locale) session.getAttribute(Globals.LOCALE_KEY);

        if (locale != null) {
            return (locale);
        }

        // Select and cache the Locale to be used
        locale = saContext.getRequest().getLocale();

        if (locale == null) {
            locale = Locale.getDefault();
        }

View Full Code Here

*/
public class SelectModule extends AbstractSelectModule {
    // ------------------------------------------------------- Protected Methods
    protected String getPrefix(ActionContext context) {
        // Identify the URI from which we will match a module prefix
        ServletActionContext sacontext = (ServletActionContext) context;
        HttpServletRequest request = sacontext.getRequest();
        String uri =
            (String) request.getAttribute(Constants.INCLUDE_SERVLET_PATH);

        if (uri == null) {
            uri = request.getServletPath();
        }

        if (uri == null) {
            throw new IllegalArgumentException("No path information in request");
        }

        // Identify the module prefix for the current module
        String prefix = ""; // Initialize to default prefix
        String[] prefixes =
            (String[]) sacontext.getApplicationScope().get(Globals.MODULE_PREFIXES_KEY);
        int lastSlash = 0;

        while (prefix.equals("") && ((lastSlash = uri.lastIndexOf("/")) > 0)) {
            uri = uri.substring(0, lastSlash);

View Full Code Here

*          $
*/
public class RequestNoCache extends AbstractRequestNoCache {
    // ------------------------------------------------------- Protected Methods
    protected void requestNoCache(ActionContext context) {
        ServletActionContext sacontext = (ServletActionContext) context;
        HttpServletResponse response = sacontext.getResponse();

        response.setHeader("Pragma", "No-cache");
        response.setHeader("Cache-Control", "no-cache,no-store,max-age=0");
        response.setDateHeader("Expires", 1);
    }
View Full Code Here

TOP

Related Classes of org.apache.struts.chain.contexts.ServletActionContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.