javax.servlet.jsp.JspContext Java Examples
The following examples show how to use
javax.servlet.jsp.JspContext.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JspContextWrapper.java From tomcatsrc with Apache License 2.0 | 6 votes |
public JspContextWrapper(JspContext jspContext, ArrayList<String> nestedVars, ArrayList<String> atBeginVars, ArrayList<String> atEndVars, Map<String,String> aliases) { this.invokingJspCtxt = (PageContext) jspContext; if (jspContext instanceof JspContextWrapper) { rootJspCtxt = ((JspContextWrapper)jspContext).rootJspCtxt; } else { rootJspCtxt = invokingJspCtxt; } this.nestedVars = nestedVars; this.atBeginVars = atBeginVars; this.atEndVars = atEndVars; this.pageAttributes = new HashMap<String, Object>(16); this.aliases = aliases; if (nestedVars != null) { this.originalNestedVars = new HashMap<String, Object>(nestedVars.size()); } syncBeginTagFile(); }
Example #2
Source File: ScopedAttributeELResolver.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
@Override public void setValue(ELContext context, Object base, Object property, Object value) throws NullPointerException, PropertyNotFoundException, PropertyNotWritableException, ELException { if (context == null) { throw new NullPointerException(); } if (base == null) { context.setPropertyResolved(true); if (property != null) { String key = property.toString(); PageContext page = (PageContext) context .getContext(JspContext.class); int scope = page.getAttributesScope(key); if (scope != 0) { page.setAttribute(key, value, scope); } else { page.setAttribute(key, value); } } } }
Example #3
Source File: JspContextWrapper.java From Tomcat8-Source-Read with MIT License | 6 votes |
public JspContextWrapper(JspTag jspTag, JspContext jspContext, ArrayList<String> nestedVars, ArrayList<String> atBeginVars, ArrayList<String> atEndVars, Map<String,String> aliases) { this.jspTag = jspTag; this.invokingJspCtxt = (PageContext) jspContext; if (jspContext instanceof JspContextWrapper) { rootJspCtxt = ((JspContextWrapper)jspContext).rootJspCtxt; } else { rootJspCtxt = invokingJspCtxt; } this.nestedVars = nestedVars; this.atBeginVars = atBeginVars; this.atEndVars = atEndVars; this.pageAttributes = new HashMap<>(16); this.aliases = aliases; if (nestedVars != null) { this.originalNestedVars = new HashMap<>(nestedVars.size()); } else { this.originalNestedVars = null; } syncBeginTagFile(); }
Example #4
Source File: ScopedAttributeELResolver.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
@Override public Object getValue(ELContext context, Object base, Object property) throws NullPointerException, PropertyNotFoundException, ELException { if (context == null) { throw new NullPointerException(); } if (base == null) { context.setPropertyResolved(true); if (property != null) { String key = property.toString(); PageContext page = (PageContext) context .getContext(JspContext.class); return page.findAttribute(key); } } return null; }
Example #5
Source File: PankuzuTag.java From sinavi-jfw with Apache License 2.0 | 6 votes |
/** * パンクズリストを表示します。 * このメソッドはJSP-BODYを評価せずに、 * 既存のHTMLテンプレート、あるいはクラスコンフィグオーバライドされたHTMLテンプレートを利用します。 * @throws JspException JSP処理中にエラーが発生した場合 * @throws IOException 入出力エラーの場合 */ protected void render() throws JspException, IOException { render(new JspFragment() { @Override public JspContext getJspContext() { return PankuzuTag.this.getJspContext(); } @Override public void invoke(Writer out) throws JspException, IOException { JspContext context = getJspContext(); ViewId vid = (ViewId) context.getAttribute(var); String encodedUrl = encodeURL(vid.getUrl()); String item = Strings.substitute(DEFAULT_TEMPLATE, Maps .hash("url", encodedUrl) .map("label", Strings.escapeHTML(vid.getLabel())) .map("query", trimQueryMarkerIfGetRequestParameterExists(encodedUrl, vid.getQuery()))); context.getOut().print(item); } }); }
Example #6
Source File: ScopedAttributeELResolver.java From tomcatsrc with Apache License 2.0 | 6 votes |
@Override public Object getValue(ELContext context, Object base, Object property) throws NullPointerException, PropertyNotFoundException, ELException { if (context == null) { throw new NullPointerException(); } if (base == null) { context.setPropertyResolved(true); if (property != null) { String key = property.toString(); PageContext page = (PageContext) context .getContext(JspContext.class); return page.findAttribute(key); } } return null; }
Example #7
Source File: ScopedAttributeELResolver.java From tomcatsrc with Apache License 2.0 | 6 votes |
@Override public void setValue(ELContext context, Object base, Object property, Object value) throws NullPointerException, PropertyNotFoundException, PropertyNotWritableException, ELException { if (context == null) { throw new NullPointerException(); } if (base == null) { context.setPropertyResolved(true); if (property != null) { String key = property.toString(); PageContext page = (PageContext) context .getContext(JspContext.class); int scope = page.getAttributesScope(key); if (scope != 0) { page.setAttribute(key, value, scope); } else { page.setAttribute(key, value); } } } }
Example #8
Source File: ScopedAttributeELResolver.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Override public void setValue(ELContext context, Object base, Object property, Object value) { Objects.requireNonNull(context); if (base == null) { context.setPropertyResolved(base, property); if (property != null) { String key = property.toString(); PageContext page = (PageContext) context.getContext(JspContext.class); int scope = page.getAttributesScope(key); if (scope != 0) { page.setAttribute(key, value, scope); } else { page.setAttribute(key, value); } } } }
Example #9
Source File: JspContextWrapper.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
public JspContextWrapper(JspContext jspContext, ArrayList<String> nestedVars, ArrayList<String> atBeginVars, ArrayList<String> atEndVars, Map<String,String> aliases) { this.invokingJspCtxt = (PageContext) jspContext; if (jspContext instanceof JspContextWrapper) { rootJspCtxt = ((JspContextWrapper)jspContext).rootJspCtxt; } else { rootJspCtxt = invokingJspCtxt; } this.nestedVars = nestedVars; this.atBeginVars = atBeginVars; this.atEndVars = atEndVars; this.pageAttributes = new HashMap<String, Object>(16); this.aliases = aliases; if (nestedVars != null) { this.originalNestedVars = new HashMap<String, Object>(nestedVars.size()); } syncBeginTagFile(); }
Example #10
Source File: JspContextWrapper.java From packagedrone with Eclipse Public License 1.0 | 6 votes |
public JspContextWrapper(JspContext jspContext, ArrayList<String> nestedVars, ArrayList<String> atBeginVars, ArrayList<String> atEndVars, Map<String, String> aliases) { this.invokingJspCtxt = (PageContext) jspContext; this.nestedVars = nestedVars; this.atBeginVars = atBeginVars; this.atEndVars = atEndVars; this.pageAttributes = new Hashtable<String, Object>(16); this.aliases = aliases; if (nestedVars != null) { this.originalNestedVars = new HashMap<String, Object>(nestedVars.size()); } syncBeginTagFile(); }
Example #11
Source File: JspContextWrapper.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public Object getContext(@SuppressWarnings("rawtypes") Class key) { if (key == JspContext.class) { return pageContext; } return wrapped.getContext(key); }
Example #12
Source File: JspContextWrapper.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Override public Object getContext(@SuppressWarnings("rawtypes") Class key) { if (key == JspContext.class) { return pageContext; } return wrapped.getContext(key); }
Example #13
Source File: JspContextWrapper.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public Object getContext(@SuppressWarnings("rawtypes") Class key) { if (key == JspContext.class) { return pageContext; } return wrapped.getContext(key); }
Example #14
Source File: JspContextWrapper.java From packagedrone with Eclipse Public License 1.0 | 5 votes |
public ELContext getELContext() { if (elContext == null) { PageContext pc = invokingJspCtxt; while (pc instanceof JspContextWrapper) { pc = ((JspContextWrapper)pc).invokingJspCtxt; } PageContextImpl pci = (PageContextImpl) pc; elContext = pci.getJspApplicationContext().createELContext( invokingJspCtxt.getELContext().getELResolver()); elContext.putContext(javax.servlet.jsp.JspContext.class, this); ((ELContextImpl)elContext).setVariableMapper( new VariableMapperImpl()); } return elContext; }
Example #15
Source File: ImplicitObjectELResolver.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public Object getValue(ELContext context, Object base, Object property) { Objects.requireNonNull(context); if (base == null && property != null) { int idx = Arrays.binarySearch(SCOPE_NAMES, property.toString()); if (idx >= 0) { PageContext page = (PageContext) context .getContext(JspContext.class); context.setPropertyResolved(base, property); switch (idx) { case APPLICATIONSCOPE: return ScopeManager.get(page).getApplicationScope(); case COOKIE: return ScopeManager.get(page).getCookie(); case HEADER: return ScopeManager.get(page).getHeader(); case HEADERVALUES: return ScopeManager.get(page).getHeaderValues(); case INITPARAM: return ScopeManager.get(page).getInitParam(); case PAGECONTEXT: return ScopeManager.get(page).getPageContext(); case PAGESCOPE: return ScopeManager.get(page).getPageScope(); case PARAM: return ScopeManager.get(page).getParam(); case PARAM_VALUES: return ScopeManager.get(page).getParamValues(); case REQUEST_SCOPE: return ScopeManager.get(page).getRequestScope(); case SESSION_SCOPE: return ScopeManager.get(page).getSessionScope(); } } } return null; }
Example #16
Source File: UidGenerator.java From Bootstrap.jsp with GNU Lesser General Public License v2.1 | 5 votes |
public static String getUid(JspContext context) { String uuid = null; do { long rand = Double.doubleToLongBits(Math.random()); uuid = Long.toHexString(rand).substring(0, 4); } while (context.getAttribute(uuid) != null); context.setAttribute(uuid, uuid); return uuid; }
Example #17
Source File: JspFragmentHelper.java From Tomcat8-Source-Read with MIT License | 5 votes |
public JspFragmentHelper( int discriminator, JspContext jspContext, JspTag parentTag ) { this.discriminator = discriminator; this.jspContext = jspContext; if(jspContext instanceof PageContext) { _jspx_page_context = (PageContext)jspContext; } else { _jspx_page_context = null; } this.parentTag = parentTag; }
Example #18
Source File: JspFragmentHelper.java From packagedrone with Eclipse Public License 1.0 | 4 votes |
public JspContext getJspContext() { return this.jspContext; }
Example #19
Source File: ImplicitObjectELResolver.java From tomcatsrc with Apache License 2.0 | 4 votes |
@Override public Object getValue(ELContext context, Object base, Object property) throws NullPointerException, PropertyNotFoundException, ELException { if (context == null) { throw new NullPointerException(); } if (base == null && property != null) { int idx = Arrays.binarySearch(SCOPE_NAMES, property.toString()); if (idx >= 0) { PageContext page = (PageContext) context .getContext(JspContext.class); context.setPropertyResolved(true); switch (idx) { case APPLICATIONSCOPE: return ScopeManager.get(page).getApplicationScope(); case COOKIE: return ScopeManager.get(page).getCookie(); case HEADER: return ScopeManager.get(page).getHeader(); case HEADERVALUES: return ScopeManager.get(page).getHeaderValues(); case INITPARAM: return ScopeManager.get(page).getInitParam(); case PAGECONTEXT: return ScopeManager.get(page).getPageContext(); case PAGESCOPE: return ScopeManager.get(page).getPageScope(); case PARAM: return ScopeManager.get(page).getParam(); case PARAM_VALUES: return ScopeManager.get(page).getParamValues(); case REQUEST_SCOPE: return ScopeManager.get(page).getRequestScope(); case SESSION_SCOPE: return ScopeManager.get(page).getSessionScope(); } } } return null; }
Example #20
Source File: CallTag.java From packagedrone with Eclipse Public License 1.0 | 4 votes |
@Override public void doTag () throws JspException, IOException { final JspFragment body = (JspFragment)getJspContext ().getAttribute ( DefineTag.ATTR_PREFIX + this.name ); if ( body == null ) { throw new JspException ( String.format ( "Unable to find macro '%s'", this.name ) ); } final JspContext ctx = body.getJspContext (); // set attributes to body context final Map<String, Object> oldEntries = new HashMap<> ( this.data.size () ); for ( final Map.Entry<String, Object> entry : this.data.entrySet () ) { oldEntries.put ( entry.getKey (), ctx.getAttribute ( entry.getKey (), PageContext.PAGE_SCOPE ) ); ctx.setAttribute ( entry.getKey (), entry.getValue (), PageContext.PAGE_SCOPE ); } // invoke body.invoke ( getJspContext ().getOut () ); // set old values, so we don't clutter up the context for the next caller for ( final String key : this.data.keySet () ) { final Object val = oldEntries.get ( key ); if ( val == null ) { ctx.removeAttribute ( key, PageContext.PAGE_SCOPE ); } else { ctx.setAttribute ( key, val, PageContext.PAGE_SCOPE ); } } }
Example #21
Source File: HtmlTagSupport.java From Bootstrap.jsp with GNU Lesser General Public License v2.1 | 4 votes |
@Override public JspContext getJspContext() { return super.getJspContext(); }
Example #22
Source File: JspFragmentHelper.java From tomcatsrc with Apache License 2.0 | 4 votes |
@Override public JspContext getJspContext() { return this.jspContext; }
Example #23
Source File: PageNavigationTagTest.java From sinavi-jfw with Apache License 2.0 | 4 votes |
@Test public void jspFragmentが設定される() throws Exception { PartialList<String> display = new PartialList<String>(); for (int i = 0; i < 110; i++) { display.add(Integer.toString(i)); } display.setElementCount(110); display.setPartCount(11); display.setElementCountPerPart(10); display.setPartIndex(7); PageNavigationTag tag = new PageNavigationTag(); tag.setPageContext(context); tag.setPartial(display); tag.setAction("/list"); JspFragment fragment = new JspFragment() { @Override public JspContext getJspContext() { return context; } @Override public void invoke(Writer out) throws JspException, IOException { out.write("----"); } }; tag.setOmission(fragment); tag.doStartTag(); tag.doEndTag(); String actual = resp.getContentAsString(); actual = actual.replaceAll("<span class=\"jfw_paginate_navi_head\">", ""); actual = actual.replaceAll("<span class=\"jfw_paginate_navi_previous\">", ""); actual = actual.replaceAll("<span class=\"jfw_paginate_navi_page\">", ""); actual = actual.replaceAll("<span class=\"jfw_paginate_navi_page_selected\">", ""); actual = actual.replaceAll("<span class=\"jfw_paginate_navi_next\">", ""); actual = actual.replaceAll("<span class=\"jfw_paginate_navi_tail\">", ""); actual = actual.replaceAll("<span class=\"jfw_paginate_navi_omission\">", ""); actual = actual.replaceAll("</span>", "\n"); String[] split = actual.split("\n"); assertThat(split.length, is(15)); assertThat(Arrays.asList(split), hasItem("<a href=\"/list?pageNumber=1\"><<</a>")); assertThat(Arrays.asList(split), hasItem("<a href=\"/list?pageNumber=6\"><</a>")); assertThat(Arrays.asList(split), hasItem("<a href=\"/list?pageNumber=2\">2</a>")); assertThat(Arrays.asList(split), hasItem("<a href=\"/list?pageNumber=11\">11</a>")); assertThat(Arrays.asList(split), hasItem("7")); assertThat(Arrays.asList(split), hasItem("----")); assertThat(Arrays.asList(split), hasItem("<a href=\"/list?pageNumber=8\">></a>")); assertThat(Arrays.asList(split), hasItem("<a href=\"/list?pageNumber=11\">>></a>")); }
Example #24
Source File: VelocityJspFragment.java From velocity-tools with Apache License 2.0 | 4 votes |
@Override public JspContext getJspContext() { return pageContext; }
Example #25
Source File: ImplicitObjectELResolver.java From lams with GNU General Public License v2.0 | 4 votes |
/** * If the base object is <code>null</code>, and the property matches * the name of a JSP implicit object, returns the implicit object. * * <p>The <code>propertyResolved</code> property of the * <code>ELContext</code> object must be set to <code>true</code> by * this resolver before returning if an implicit object is matched. If * this property is not <code>true</code> after this method is called, * the caller should ignore the return value.</p> * * @param context The context of this evaluation. * @param base Only <code>null</code> is handled by this resolver. * Other values will result in an immediate return. * @param property The name of the implicit object to resolve. * @return If the <code>propertyResolved</code> property of * <code>ELContext</code> was set to <code>true</code>, then * the implicit object; otherwise undefined. * @throws NullPointerException if context is <code>null</code> * @throws ELException if an exception was thrown while performing * the property or variable resolution. The thrown exception * must be included as the cause property of this exception, if * available. */ public Object getValue(ELContext context, Object base, Object property) { if (context == null) { throw new NullPointerException(); } if (base != null) { return null; } PageContext ctxt = (PageContext)context.getContext(JspContext.class); if ("pageContext".equals(property)) { context.setPropertyResolved(true); return ctxt; } ImplicitObjects implicitObjects = ImplicitObjects.getImplicitObjects(ctxt); if ("pageScope".equals(property)) { context.setPropertyResolved(true); return implicitObjects.getPageScopeMap(); } if ("requestScope".equals(property)) { context.setPropertyResolved(true); return implicitObjects.getRequestScopeMap(); } if ("sessionScope".equals(property)) { context.setPropertyResolved(true); return implicitObjects.getSessionScopeMap(); } if ("applicationScope".equals (property)) { context.setPropertyResolved(true); return implicitObjects.getApplicationScopeMap (); } if ("param".equals (property)) { context.setPropertyResolved(true); return implicitObjects.getParamMap(); } if ("paramValues".equals (property)) { context.setPropertyResolved(true); return implicitObjects.getParamsMap(); } if ("header".equals (property)) { context.setPropertyResolved(true); return implicitObjects.getHeaderMap(); } if ("headerValues".equals (property)) { context.setPropertyResolved(true); return implicitObjects.getHeadersMap(); } if ("initParam".equals (property)) { context.setPropertyResolved(true); return implicitObjects.getInitParamMap (); } if ("cookie".equals (property)) { context.setPropertyResolved(true); return implicitObjects.getCookieMap (); } return null; }
Example #26
Source File: ScopedAttributeELResolver.java From lams with GNU General Public License v2.0 | 4 votes |
/** * If the base object is <code>null</code>, searches the page, * request, session and application scopes for an attribute with * the given name and returns it, or <code>null</code> if no * attribute exists with the current name. * * <p>The <code>propertyResolved</code> property of the * <code>ELContext</code> object must be set to <code>true</code> by * this resolver before returning if base is <code>null</code>. If * this property is not <code>true</code> after this method is called, * the caller should ignore the return value.</p> * * @param context The context of this evaluation. * @param base Only <code>null</code> is handled by this resolver. * Other values will result in an immediate return. * @param property The name of the scoped attribute to resolve. * @return If the <code>propertyResolved</code> property of * <code>ELContext</code> was set to <code>true</code>, then * the scoped attribute; otherwise undefined. * @throws NullPointerException if context is <code>null</code> * @throws ELException if an exception was thrown while performing * the property or variable resolution. The thrown exception * must be included as the cause property of this exception, if * available. */ public Object getValue(ELContext context, Object base, Object property) { if (context == null) { throw new NullPointerException(); } if (base == null) { context.setPropertyResolved(true); if (property instanceof String) { String attribute = (String) property; PageContext ctxt = (PageContext) context.getContext(JspContext.class); return ctxt.findAttribute(attribute); } } return null; }
Example #27
Source File: JspFragmentHelper.java From Tomcat8-Source-Read with MIT License | 4 votes |
@Override public JspContext getJspContext() { return this.jspContext; }
Example #28
Source File: ImplicitObjectELResolver.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
@Override public Object getValue(ELContext context, Object base, Object property) throws NullPointerException, PropertyNotFoundException, ELException { if (context == null) { throw new NullPointerException(); } if (base == null && property != null) { int idx = Arrays.binarySearch(SCOPE_NAMES, property.toString()); if (idx >= 0) { PageContext page = (PageContext) context .getContext(JspContext.class); context.setPropertyResolved(true); switch (idx) { case APPLICATIONSCOPE: return ScopeManager.get(page).getApplicationScope(); case COOKIE: return ScopeManager.get(page).getCookie(); case HEADER: return ScopeManager.get(page).getHeader(); case HEADERVALUES: return ScopeManager.get(page).getHeaderValues(); case INITPARAM: return ScopeManager.get(page).getInitParam(); case PAGECONTEXT: return ScopeManager.get(page).getPageContext(); case PAGESCOPE: return ScopeManager.get(page).getPageScope(); case PARAM: return ScopeManager.get(page).getParam(); case PARAM_VALUES: return ScopeManager.get(page).getParamValues(); case REQUEST_SCOPE: return ScopeManager.get(page).getRequestScope(); case SESSION_SCOPE: return ScopeManager.get(page).getSessionScope(); } } } return null; }
Example #29
Source File: ScopedAttributeELResolver.java From Tomcat8-Source-Read with MIT License | 4 votes |
@Override public Object getValue(ELContext context, Object base, Object property) { Objects.requireNonNull(context); Object result = null; if (base == null) { context.setPropertyResolved(base, property); if (property != null) { String key = property.toString(); PageContext page = (PageContext) context.getContext(JspContext.class); result = page.findAttribute(key); if (result == null) { boolean resolveClass = true; // Performance short-cut available when running on Tomcat if (AST_IDENTIFIER_KEY != null) { // Tomcat will set this key to Boolean.TRUE if the // identifier is a stand-alone identifier (i.e. // identifier) rather than part of an AstValue (i.e. // identifier.something). Imports do not need to be // checked if this is a stand-alone identifier Boolean value = (Boolean) context.getContext(AST_IDENTIFIER_KEY); if (value != null && value.booleanValue()) { resolveClass = false; } } // This might be the name of an imported class ImportHandler importHandler = context.getImportHandler(); if (importHandler != null) { Class<?> clazz = null; if (resolveClass) { clazz = importHandler.resolveClass(key); } if (clazz != null) { result = new ELClass(clazz); } if (result == null) { // This might be the name of an imported static field clazz = importHandler.resolveStatic(key); if (clazz != null) { try { result = clazz.getField(key).get(null); } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) { // Most (all?) of these should have been // prevented by the checks when the import // was defined. } } } } } } } return result; }
Example #30
Source File: SearchByTag.java From Online-Library-System with GNU General Public License v2.0 | 4 votes |
public void setJspContext(JspContext arg0) { this.jspContext = arg0; }