throws ELException
{
if (! (env instanceof PageContextImpl.PageELContext))
return null;
PageContextImpl page
= ((PageContextImpl.PageELContext) env).getPageContext();
switch (_index) {
case PAGE_CONTEXT:
return page;
case APPLICATION_SCOPE:
return new AttributeMap(page, PageContext.APPLICATION_SCOPE);
case SESSION_SCOPE:
return new AttributeMap(page, PageContext.SESSION_SCOPE);
case REQUEST_SCOPE:
return new AttributeMap(page, PageContext.REQUEST_SCOPE);
case PAGE_SCOPE:
return new AttributeMap(page, PageContext.PAGE_SCOPE);
case PARAM_VALUES:
return page.getRequest().getParameterMap();
case PARAM: {
HashMap<String,String> map = new HashMap<String,String>();
Map pMap = page.getRequest().getParameterMap();
Iterator iter = pMap.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
String key = (String) entry.getKey();
String []value = (String []) entry.getValue();
map.put(key, value[0]);
}
return map;
}
case INIT_PARAM:
{
ServletContext app = page.getServletContext();
HashMap<String,String> map = new HashMap<String,String>();
Enumeration e = app.getInitParameterNames();
while (e.hasMoreElements()) {
String name = (String) e.nextElement();
map.put(name, app.getInitParameter(name));
}
return map;
}
case HEADER:
{
HttpServletRequest req = (HttpServletRequest) page.getRequest();
HashMap<String,String> map = new HashMap<String,String>();
Enumeration e = req.getHeaderNames();
while (e.hasMoreElements()) {
String name = (String) e.nextElement();
map.put(name, req.getHeader(name));
}
return map;
}
case HEADER_VALUES:
{
HttpServletRequest req = (HttpServletRequest) page.getRequest();
HashMap<String,String[]> map = new HashMap<String,String[]>();
Enumeration e = req.getHeaderNames();
while (e.hasMoreElements()) {
String name = (String) e.nextElement();
Enumeration values = req.getHeaders(name);
ArrayList<String> list = new ArrayList<String>();
while (values.hasMoreElements())
list.add((String) values.nextElement());
map.put(name, list.toArray(new String[list.size()]));
}
return map;
}
case COOKIE:
{
HashMap<String,Object> map = new HashMap<String,Object>();
Cookie []cookies = ((HttpServletRequest) page.getRequest()).getCookies();
for (int i = 0; cookies != null && i < cookies.length; i++) {
if (map.get(cookies[i].getName()) == null)
map.put(cookies[i].getName(), cookies[i]);
}