Example usage for javax.servlet.jsp PageContext getRequest

List of usage examples for javax.servlet.jsp PageContext getRequest

Introduction

In this page you can find the example usage for javax.servlet.jsp PageContext getRequest.

Prototype


abstract public ServletRequest getRequest();

Source Link

Document

The current value of the request object (a ServletRequest).

Usage

From source file:ar.com.zauber.commons.web.uri.UriJspFunctions.java

/** Construye un uri */
public static String buildVarArgs(final PageContext ctx, final String uriKey, final String bean,
        final Object... params) {
    return buildVarArgs(ctx.getRequest(), uriKey, bean, params);

}

From source file:de.laures.cewolf.taglib.tags.ChartImgTag.java

/**
 * Same as the other fixAbsolutURL, convinience only.
 * @param url The url to fix//  w w w .ja  v  a  2s .com
 * @param pageContext The page context
 * @return Fixed url contains the full path
 */
public static String fixAbsolutURL(String url, PageContext pageContext) {
    return fixAbsolutURL(url, (HttpServletRequest) pageContext.getRequest());
}

From source file:dk.netarkivet.harvester.webinterface.TrapAction.java

/**
 * This method processes the request to determine which action it corresponds to and passes the request along
 * accordingly. If it is a multipart post then it is passed along to a create-or-update instance. Otherwise if no
 * action is specified, none is taken. Otherwise the request is passed on to a specific concrete instance of this
 * class for further processing./* w w w  .  jav  a 2s  .  com*/
 *
 * @param context the original servlet context of the request.
 * @param i18n the internationalisation to be used.
 * @throws ForwardedToErrorPage if an exception is thrown while carrying out the action.
 */
public static void processRequest(PageContext context, I18n i18n) throws ForwardedToErrorPage {
    ArgumentNotValid.checkNotNull(context, "PageContext context");
    ArgumentNotValid.checkNotNull(i18n, "I18n i18n");
    log.debug("Processing request");
    HttpServletRequest request = (HttpServletRequest) context.getRequest();

    try {
        if (ServletFileUpload.isMultipartContent(request)) {
            TrapActionEnum.CREATE_OR_UPDATE.getTrapAction().doAction(context, i18n);
        } else {
            String requestType = request.getParameter(Constants.TRAP_ACTION);
            if (requestType == null || requestType.isEmpty()) {
                TrapActionEnum.NULL_ACTION.getTrapAction().doAction(context, i18n);
            } else {
                TrapActionEnum actionType = TrapActionEnum.valueOf(requestType);
                actionType.getTrapAction().doAction(context, i18n);
            }
        }
    } catch (Throwable e) {
        log.warn("Error in Global Crawler Traps", e);
        HTMLUtils.forwardWithErrorMessage(context, i18n, e, "errormsg;crawlertrap.action.error");
        throw new ForwardedToErrorPage("Error in Global Crawler Traps", e);
    }
}

From source file:de.innovationgate.wgpublisher.bi.BiBase.java

public static de.innovationgate.wgpublisher.jsputils.JspHelper getHelper(
        javax.servlet.jsp.PageContext pageContext) {

    //pageContext.getSession().setAttribute(de.innovationgate.wgpublisher.WGPDispatcher.ATTRIB_BROWSERINTERFACE,new Boolean(true));

    Object oTmp = pageContext.getRequest().getAttribute("usedRequest");

    if (oTmp == null) {
        pageContext.getRequest().setAttribute("usedRequest", "yes");
        helper = new de.innovationgate.wgpublisher.jsputils.JspHelper(pageContext);

    }/*from  ww w  .  j  a va2  s.  c o  m*/

    return helper;
}

From source file:dk.netarkivet.harvester.webinterface.HarvestChannelAction.java

/**
 * This method processes the request to determine which action it corresponds to and passes the request along
 * accordingly. Available actions are://from   w  w  w  . j  a  va2  s . co m
 * <ul>
 * <li>create harvest channel</li>
 * <li>map harvest definition to channel</li>
 * </ul>
 *
 * @param context the original servlet context of the request.
 * @param i18n the internationalisation to be used.
 * @throws ForwardedToErrorPage if an exception is thrown while carrying out the action.
 */
public static void processRequest(PageContext context, I18n i18n) throws ForwardedToErrorPage {
    ArgumentNotValid.checkNotNull(context, "PageContext context");
    ArgumentNotValid.checkNotNull(i18n, "I18n i18n");
    log.debug("Processing request");
    HttpServletRequest request = (HttpServletRequest) context.getRequest();
    try {
        String action = request.getParameter(ACTION);
        if (action == null || action.isEmpty()) {
            return;
        }
        switch (ActionType.valueOf(action)) {
        case createHarvestChannel:
            String name = request.getParameter(CHANNEL_NAME);
            HTMLUtils.forwardOnEmptyParameter(context, CHANNEL_NAME);
            HarvestChannelDAO dao = HarvestChannelDAO.getInstance();
            dao.create(new HarvestChannel(name, false, false, request.getParameter(COMMENTS)));
            break;
        case mapHarvestToChannel:
            long harvestId = Long.parseLong(request.getParameter(HARVEST_ID));
            long channelId = Long.parseLong(request.getParameter(CHANNEL_ID));
            HarvestChannelDAO hcDao = HarvestChannelDAO.getInstance();
            HarvestDefinitionDAO hdDao = HarvestDefinitionDAO.getInstance();
            hdDao.mapToHarvestChannel(harvestId, hcDao.getById(channelId));
            break;
        default:
        }
    } catch (Throwable e) {
        HTMLUtils.forwardWithErrorMessage(context, i18n, e, "errormsg;harvest.channel.create.error");
        throw new ForwardedToErrorPage("Error in Harvest Channels", e);
    }
}

From source file:net.sourceforge.vulcan.web.JstlFunctions.java

private static String formatMessage(PageContext pageContext, String key, boolean plural) {
    if (plural) {
        key += "s";
    }//from  www. j av  a2s  .  c  o  m

    return webApplicationContext.getMessage(key, null, pageContext.getRequest().getLocale());
}

From source file:net.ontopia.topicmaps.nav2.utils.FrameworkUtils.java

/**
 * INTERNAL: Create new user object in given scope.
 *///from ww w .  j  ava  2s .c o  m
public static UserIF createUserSession(PageContext pageContext, int scope) {

    NavigatorConfigurationIF navConf = NavigatorUtils.getNavigatorApplication(pageContext).getConfiguration();
    // try to retrieve the user name from the request, otherwise null
    String username = null;
    if (pageContext.getRequest() instanceof HttpServletRequest)
        username = ((HttpServletRequest) pageContext.getRequest()).getRemoteUser();
    // create new user object
    UserIF user = new User(username, navConf);
    // set MVS settings
    user = setDefaultMVS(navConf, user);
    // set user object to session scope
    pageContext.setAttribute(NavigatorApplicationIF.USER_KEY, user, scope);
    log.debug("New user object ('" + user.getId() + "') created and bound in scope ( " + scope + ").");
    return user;
}

From source file:dk.netarkivet.harvester.webinterface.ExtendedFieldValueDefinition.java

public static void processRequest(PageContext context, I18n i18n, ExtendableEntity entity, int type) {
    ArgumentNotValid.checkNotNull(context, "PageContext context");
    ArgumentNotValid.checkNotNull(i18n, "I18n i18n");

    ExtendedFieldDAO extdao = ExtendedFieldDBDAO.getInstance();
    Iterator<ExtendedField> it = extdao.getAll(type).iterator();

    ServletRequest request = context.getRequest();

    while (it.hasNext()) {
        String value = "";

        ExtendedField ef = it.next();/*from  w w w .ja  v a2s  . c om*/
        String parameterName = ef.getJspFieldname();
        switch (ef.getDatatype()) {
        case ExtendedFieldDataTypes.BOOLEAN:
            String[] parb = request.getParameterValues(parameterName);
            if (parb != null && parb.length > 0) {
                value = ExtendedFieldConstants.TRUE;
            } else {
                value = ExtendedFieldConstants.FALSE;
            }
            break;
        case ExtendedFieldDataTypes.SELECT:
            String[] pars = request.getParameterValues(parameterName);
            if (pars != null && pars.length > 0) {
                value = pars[0];
            } else {
                value = "";
            }

            break;
        default:
            value = request.getParameter(parameterName);
            if (ef.isMandatory()) {
                if (value == null || value.length() == 0) {
                    value = ef.getDefaultValue();
                }

                if (value == null || value.length() == 0) {
                    HTMLUtils.forwardWithErrorMessage(context, i18n,
                            "errormsg;extendedfields.field.0.is.empty." + "but.mandatory", ef.getName());
                    throw new ForwardedToErrorPage("Mandatory field " + ef.getName() + " is empty.");
                }
            }

            ExtendedFieldDefaultValue def = new ExtendedFieldDefaultValue(value, ef.getFormattingPattern(),
                    ef.getDatatype());
            if (!def.isValid()) {
                HTMLUtils.forwardWithRawErrorMessage(context, i18n, "errormsg;extendedfields.value.invalid");
                throw new ForwardedToErrorPage("errormsg;extendedfields.value.invalid");
            }
            value = def.getDBValue();
            break;
        }

        entity.updateExtendedFieldValue(ef.getExtendedFieldID(), value);
    }
}

From source file:dk.netarkivet.harvester.webinterface.HarvestStatus.java

/**
 * Process a request from Harveststatus-alljobs.
 * <p>/*  w w w  . j av a  2 s  . c  om*/
 * Will resubmit a job if requested, otherwise do nothing.
 *
 * @param context The web context used for processing
 * @param i18n The resource i18n context.
 * @throws ForwardedToErrorPage If an error occurs that stops processing and forwards the user to an error page.
 */
public static void processRequest(PageContext context, I18n i18n) throws ForwardedToErrorPage {
    ArgumentNotValid.checkNotNull(context, "PageContext context");
    ArgumentNotValid.checkNotNull(i18n, "I18n i18n");

    // Check if it's a multiple resubmit query
    String resubmitJobIds = UI_FIELD.RESUBMIT_JOB_IDS.getValue(context.getRequest());
    Long resubmitJobID = HTMLUtils.parseOptionalLong(context, Constants.JOB_RESUBMIT_PARAM, null);
    Long rejectJobID = HTMLUtils.parseOptionalLong(context, Constants.JOB_REJECT_PARAM, null);
    Long unrejectJobID = HTMLUtils.parseOptionalLong(context, Constants.JOB_UNREJECT_PARAM, null);
    if (!resubmitJobIds.isEmpty()) {
        String[] ids = resubmitJobIds.split(";");
        for (String idStr : ids) {
            resubmitJob(context, i18n, Long.parseLong(idStr));
        }
    } else if (resubmitJobID != null) {
        resubmitJob(context, i18n, resubmitJobID);
    } else if (rejectJobID != null) {
        rejectFailedJob(context, i18n, rejectJobID);
    } else if (unrejectJobID != null) {
        unrejectRejectedJob(context, i18n, unrejectJobID);
    }
}

From source file:de.iteratec.iteraplan.businesslogic.common.URLBuilder.java

/**
 * Returns the absolute URL of the object's flow page by extracting the server and application url
 * out of the pageContext and adding name, id and flow specific String elements.
 * /*w w  w  . jav  a2 s.  com*/
 * @param pageContext
 *          The current PageContext.
 * @param dialog
 *          The object's name.
 * @param objectId
 *          The object's id.
 * @return The absolute URL of the flow.
 */
public static String getAbsoluteURLforFlow(PageContext pageContext, String dialog, Integer objectId) {
    String applicationUrl = getApplicationURL((HttpServletRequest) pageContext.getRequest());

    return getRelativeURLforFlow(applicationUrl, dialog, objectId);
}