本文整理汇总了Java中javax.servlet.jsp.PageContext.getRequest方法的典型用法代码示例。如果您正苦于以下问题:Java PageContext.getRequest方法的具体用法?Java PageContext.getRequest怎么用?Java PageContext.getRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.servlet.jsp.PageContext
的用法示例。
在下文中一共展示了PageContext.getRequest方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCookieMap
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
/**
*
* Creates the Map that maps cookie name to the first matching
* Cookie in request.getCookies().
**/
public static Map<String, Cookie> createCookieMap (PageContext pContext)
{
// Read all the cookies and construct the entire map
HttpServletRequest request = (HttpServletRequest) pContext.getRequest ();
Cookie [] cookies = request.getCookies ();
Map<String, Cookie> ret = new HashMap<String, Cookie> ();
for (int i = 0; cookies != null && i < cookies.length; i++) {
Cookie cookie = cookies [i];
if (cookie != null) {
String name = cookie.getName ();
if (!ret.containsKey (name)) {
ret.put (name, cookie);
}
}
}
return ret;
}
示例2: initialize
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
public final void initialize(PageContext pagecontext)
throws ServletException
{
m_application = pagecontext.getServletContext();
m_request = (HttpServletRequest)pagecontext.getRequest();
m_response = (HttpServletResponse)pagecontext.getResponse();
}
示例3: resolveUrl
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
/** Utility methods
* taken from org.apache.taglibs.standard.tag.common.core.UrlSupport
*/
public static String resolveUrl(
String url, String context, PageContext pageContext)
throws JspException {
// don't touch absolute URLs
if (isAbsoluteUrl(url))
return url;
// normalize relative URLs against a context root
HttpServletRequest request =
(HttpServletRequest) pageContext.getRequest();
if (context == null) {
if (url.startsWith("/"))
return (request.getContextPath() + url);
else
return url;
} else {
if (!context.startsWith("/") || !url.startsWith("/")) {
throw new JspTagException(
"In URL tags, when the \"context\" attribute is specified, values of both \"context\" and \"url\" must start with \"/\".");
}
if (context.equals("/")) {
// Don't produce string starting with '//', many
// browsers interpret this as host name, not as
// path on same host.
return url;
} else {
return (context + url);
}
}
}
示例4: createParamMap
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
/**
*
* Creates the Map that maps parameter name to single parameter
* value.
**/
public static Map<String, String> createParamMap (PageContext pContext)
{
final HttpServletRequest request =
(HttpServletRequest) pContext.getRequest ();
return new EnumeratedMap<String, String> ()
{
public Enumeration<String> enumerateKeys ()
{
return request.getParameterNames ();
}
public String getValue (Object pKey)
{
if (pKey instanceof String) {
return request.getParameter ((String) pKey);
}
else {
return null;
}
}
public boolean isMutable ()
{
return false;
}
};
}
示例5: createParamsMap
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
/**
*
* Creates the Map that maps parameter name to an array of parameter
* values.
**/
public static Map<String, String[]> createParamsMap (PageContext pContext)
{
final HttpServletRequest request =
(HttpServletRequest) pContext.getRequest ();
return new EnumeratedMap<String, String[]> ()
{
public Enumeration<String> enumerateKeys ()
{
return request.getParameterNames ();
}
public String[] getValue (Object pKey)
{
if (pKey instanceof String) {
return request.getParameterValues ((String) pKey);
}
else {
return null;
}
}
public boolean isMutable ()
{
return false;
}
};
}
示例6: createHeaderMap
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
/**
*
* Creates the Map that maps header name to single header
* value.
**/
public static Map<String, String> createHeaderMap (PageContext pContext)
{
final HttpServletRequest request =
(HttpServletRequest) pContext.getRequest ();
return new EnumeratedMap<String, String> ()
{
public Enumeration<String> enumerateKeys ()
{
return request.getHeaderNames ();
}
public String getValue (Object pKey)
{
if (pKey instanceof String) {
return request.getHeader ((String) pKey);
}
else {
return null;
}
}
public boolean isMutable ()
{
return false;
}
};
}
示例7: createHeadersMap
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
/**
*
* Creates the Map that maps header name to an array of header
* values.
**/
public static Map<String, String[]> createHeadersMap (PageContext pContext)
{
final HttpServletRequest request =
(HttpServletRequest) pContext.getRequest ();
return new EnumeratedMap<String, String[]> ()
{
public Enumeration<String> enumerateKeys ()
{
return request.getHeaderNames ();
}
public String[] getValue (Object pKey)
{
if (pKey instanceof String) {
// Drain the header enumeration
List<String> l = new ArrayList<String> ();
Enumeration<String> e = request.getHeaders ((String) pKey);
if (e != null) {
while (e.hasMoreElements ()) {
l.add (e.nextElement ());
}
}
return l.toArray (new String [l.size ()]);
}
else {
return null;
}
}
public boolean isMutable ()
{
return false;
}
};
}
示例8: getLabelEditorLink
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
/** A convenience method to return a hyperlink to the LabelEditor component.
* A blank string will be returned, if the user does not have access to the component 'Jaffa.Admin.LabelEditor'.
* @param pageContext The PageContext of the jsp.
* @param labelFilter The label to be edited. The labelFilter should be of the type 'xyz', '[xyz]'. Values of the type 'abc [xyz] efg [zzz]' will be ignored and a blank string will be returned.
* @return the HTML for the hyperlink to the LabelEditor component.
*/
public static String getLabelEditorLink(PageContext pageContext, String labelFilter) {
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
// Perform the logic only if the user has been authenticated
if (request.getUserPrincipal() != null) {
String labelEditorPrefix = null;
HttpSession session = request.getSession(false);
if (session != null) {
// Check the session for the cached prefix
labelEditorPrefix = (String) session.getAttribute(ATTRIBUTE_LABEL_EDITOR_LINK_PREFIX);
if (labelEditorPrefix == null) {
labelEditorPrefix = constructLabelEditorLinkPrefix(request);
session.setAttribute(ATTRIBUTE_LABEL_EDITOR_LINK_PREFIX, labelEditorPrefix);
}
} else {
// No session, so simply create the prefix each time
labelEditorPrefix = constructLabelEditorLinkPrefix(request);
}
if (labelEditorPrefix.length() > 0) {
// Ensure that the labelFilter is of the type 'xyz' or '[xyz]'
// Remove the outer token markers, if any
// Then proceed only if no more token-markers exist
labelFilter = MessageHelper.removeTokenMarkers(labelFilter);
if (!MessageHelper.hasTokens(labelFilter))
return labelEditorPrefix + labelFilter + LABEL_EDITOR_LINK_SUFFIX;
}
}
// We'll reach this point if the user is not aunthenticated or has no access to the component or if the labelFilter is invalid
// Just return a blank String
return "";
}
示例9: AuthUtil
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
/**
* 构造方法
*/
public AuthUtil(PageContext context)
{
this.request = (HttpServletRequest)context.getRequest();
//this.response = (HttpServletResponse)context.getResponse();
authService = (AuthService)BeanFactory.getBean("authService");
}
示例10: resolveUrl
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
/**
* Utility methods taken from
* org.apache.taglibs.standard.tag.common.core.UrlSupport
*/
public static String resolveUrl(String url, String context, PageContext pageContext) throws JspException {
// don't touch absolute URLs
if (isAbsoluteUrl(url))
return url;
// normalize relative URLs against a context root
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
if (context == null) {
if (url.startsWith("/"))
return (request.getContextPath() + url);
else
return url;
} else {
if (!context.startsWith("/") || !url.startsWith("/")) {
throw new JspTagException(
"In URL tags, when the \"context\" attribute is specified, values of both \"context\" and \"url\" must start with \"/\".");
}
if (context.equals("/")) {
// Don't produce string starting with '//', many
// browsers interpret this as host name, not as
// path on same host.
return url;
} else {
return (context + url);
}
}
}
示例11: getActionMappingURL
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
/**
* Return the form action converted into a server-relative URL.
*/
public String getActionMappingURL(String action, String module, PageContext pageContext, boolean contextRelative) {
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
String contextPath = request.getContextPath();
StringBuffer value = new StringBuffer();
// Avoid setting two slashes at the beginning of an action:
// the length of contextPath should be more than 1
// in case of non-root context, otherwise length==1 (the slash)
if (contextPath.length() > 1) value.append(contextPath);
ModuleConfig moduleConfig = ModuleUtils.getInstance().getModuleConfig(module, request, pageContext.getServletContext());
if ((moduleConfig != null) && (!contextRelative)) {
value.append(moduleConfig.getPrefix());
}
// Use our servlet mapping, if one is specified
String servletMapping =
(String) pageContext.getAttribute(
Globals.SERVLET_KEY,
PageContext.APPLICATION_SCOPE);
if (servletMapping != null) {
String queryString = null;
int question = action.indexOf("?");
if (question >= 0) {
queryString = action.substring(question);
}
String actionMapping = getActionMappingName(action);
if (servletMapping.startsWith("*.")) {
value.append(actionMapping);
value.append(servletMapping.substring(1));
} else if (servletMapping.endsWith("/*")) {
value.append(
servletMapping.substring(0, servletMapping.length() - 2));
value.append(actionMapping);
} else if (servletMapping.equals("/")) {
value.append(actionMapping);
}
if (queryString != null) {
value.append(queryString);
}
}
// Otherwise, assume extension mapping is in use and extension is
// already included in the action property
else {
if (!action.startsWith("/")) {
value.append("/");
}
value.append(action);
}
return value.toString();
}
示例12: AuthLogin
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
/**
* 构造方法
*/
public AuthLogin(PageContext context)
{
this.request = (HttpServletRequest)context.getRequest();
//this.response = (HttpServletResponse)context.getResponse();
}
示例13: MyCookie
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
/**
* 初始化cookie
* @param context PageContext
*/
public MyCookie(PageContext context)
{
this.response = (HttpServletResponse) context.getResponse();
this.request = (HttpServletRequest) context.getRequest();
}