use of javax.servlet.jsp.PageContext in project Aspose.BarCode-for-Java by aspose-barcode.
the class AsposeAPIgetBarcodeUrlTag method doTag.
public void doTag() throws JspException {
try {
ScopedContext scopedContext = (this.scopeName == null) ? ScopedContext.PAGE : ScopedContext.getInstance(this.scopeName);
Object constantValue = getSymbologyValue(BarcodeTypeConstantClass + "." + this.symbology);
constantValue = BarcodeServiceURL + "?billAmount=" + billamount + "&symbology=" + constantValue;
PageContext pageContext = (PageContext) getJspContext();
String webContext = pageContext.getServletContext().getContextPath();
ServletRequest servletRequest = pageContext.getRequest();
String serviceUrl = servletRequest.getScheme() + "://" + servletRequest.getServerName() + ":" + servletRequest.getServerPort() + webContext;
getJspContext().setAttribute(this.varName, serviceUrl + constantValue, scopedContext.getValue());
} catch (Exception e) {
throw new JspException("Exception setting constant " + this.symbology, e);
}
}
use of javax.servlet.jsp.PageContext in project sw360portal by sw360.
the class DisplayDownloadAbstractTest method testThatAllAbstractMethodsAreCalled.
@Test
public void testThatAllAbstractMethodsAreCalled() throws Exception {
HttpServletRequest servletRequest = Mockito.mock(HttpServletRequest.class);
JspWriter jspWriter = Mockito.mock(JspWriter.class);
PageContext pageContext = Mockito.mock(PageContext.class);
when(pageContext.getOut()).thenReturn(jspWriter);
when(pageContext.getRequest()).thenReturn(servletRequest);
DisplayDownloadAbstract displayDownloadAbstractAttachment = Mockito.spy(DisplayDownloadAbstract.class);
displayDownloadAbstractAttachment.setPageContext(pageContext);
displayDownloadAbstractAttachment.doStartTag();
verify(displayDownloadAbstractAttachment, times(1)).configureUrlWriter(any());
verify(displayDownloadAbstractAttachment, times(1)).getImage();
verify(displayDownloadAbstractAttachment, times(1)).getAlternativeText();
verify(displayDownloadAbstractAttachment, times(1)).getTitleText();
}
use of javax.servlet.jsp.PageContext in project Sylvanas by ceruleannn.
the class ScopedAttributeELResolver method getFeatureDescriptors.
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
PageContext ctxt = (PageContext) context.getContext(JspContext.class);
List<FeatureDescriptor> list = new ArrayList<FeatureDescriptor>();
Enumeration<String> e;
Object value;
String name;
e = ctxt.getAttributeNamesInScope(PageContext.PAGE_SCOPE);
while (e.hasMoreElements()) {
name = e.nextElement();
value = ctxt.getAttribute(name, PageContext.PAGE_SCOPE);
FeatureDescriptor descriptor = new FeatureDescriptor();
descriptor.setName(name);
descriptor.setDisplayName(name);
descriptor.setExpert(false);
descriptor.setHidden(false);
descriptor.setPreferred(true);
descriptor.setShortDescription("page scoped attribute");
descriptor.setValue("type", value.getClass());
descriptor.setValue("resolvableAtDesignTime", Boolean.FALSE);
list.add(descriptor);
}
e = ctxt.getAttributeNamesInScope(PageContext.REQUEST_SCOPE);
while (e.hasMoreElements()) {
name = e.nextElement();
value = ctxt.getAttribute(name, PageContext.REQUEST_SCOPE);
FeatureDescriptor descriptor = new FeatureDescriptor();
descriptor.setName(name);
descriptor.setDisplayName(name);
descriptor.setExpert(false);
descriptor.setHidden(false);
descriptor.setPreferred(true);
descriptor.setShortDescription("request scope attribute");
descriptor.setValue("type", value.getClass());
descriptor.setValue("resolvableAtDesignTime", Boolean.FALSE);
list.add(descriptor);
}
if (ctxt.getSession() != null) {
e = ctxt.getAttributeNamesInScope(PageContext.SESSION_SCOPE);
while (e.hasMoreElements()) {
name = e.nextElement();
value = ctxt.getAttribute(name, PageContext.SESSION_SCOPE);
FeatureDescriptor descriptor = new FeatureDescriptor();
descriptor.setName(name);
descriptor.setDisplayName(name);
descriptor.setExpert(false);
descriptor.setHidden(false);
descriptor.setPreferred(true);
descriptor.setShortDescription("session scoped attribute");
descriptor.setValue("type", value.getClass());
descriptor.setValue("resolvableAtDesignTime", Boolean.FALSE);
list.add(descriptor);
}
}
e = ctxt.getAttributeNamesInScope(PageContext.APPLICATION_SCOPE);
while (e.hasMoreElements()) {
name = e.nextElement();
value = ctxt.getAttribute(name, PageContext.APPLICATION_SCOPE);
FeatureDescriptor descriptor = new FeatureDescriptor();
descriptor.setName(name);
descriptor.setDisplayName(name);
descriptor.setExpert(false);
descriptor.setHidden(false);
descriptor.setPreferred(true);
descriptor.setShortDescription("application scoped attribute");
descriptor.setValue("type", value.getClass());
descriptor.setValue("resolvableAtDesignTime", Boolean.FALSE);
list.add(descriptor);
}
return list.iterator();
}
use of javax.servlet.jsp.PageContext in project tomcat70 by apache.
the class ScopedAttributeELResolver method getFeatureDescriptors.
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
PageContext ctxt = (PageContext) context.getContext(JspContext.class);
List<FeatureDescriptor> list = new ArrayList<FeatureDescriptor>();
Enumeration<String> e;
Object value;
String name;
e = ctxt.getAttributeNamesInScope(PageContext.PAGE_SCOPE);
while (e.hasMoreElements()) {
name = e.nextElement();
value = ctxt.getAttribute(name, PageContext.PAGE_SCOPE);
FeatureDescriptor descriptor = new FeatureDescriptor();
descriptor.setName(name);
descriptor.setDisplayName(name);
descriptor.setExpert(false);
descriptor.setHidden(false);
descriptor.setPreferred(true);
descriptor.setShortDescription("page scoped attribute");
descriptor.setValue("type", value.getClass());
descriptor.setValue("resolvableAtDesignTime", Boolean.FALSE);
list.add(descriptor);
}
e = ctxt.getAttributeNamesInScope(PageContext.REQUEST_SCOPE);
while (e.hasMoreElements()) {
name = e.nextElement();
value = ctxt.getAttribute(name, PageContext.REQUEST_SCOPE);
FeatureDescriptor descriptor = new FeatureDescriptor();
descriptor.setName(name);
descriptor.setDisplayName(name);
descriptor.setExpert(false);
descriptor.setHidden(false);
descriptor.setPreferred(true);
descriptor.setShortDescription("request scope attribute");
descriptor.setValue("type", value.getClass());
descriptor.setValue("resolvableAtDesignTime", Boolean.FALSE);
list.add(descriptor);
}
if (ctxt.getSession() != null) {
e = ctxt.getAttributeNamesInScope(PageContext.SESSION_SCOPE);
while (e.hasMoreElements()) {
name = e.nextElement();
value = ctxt.getAttribute(name, PageContext.SESSION_SCOPE);
FeatureDescriptor descriptor = new FeatureDescriptor();
descriptor.setName(name);
descriptor.setDisplayName(name);
descriptor.setExpert(false);
descriptor.setHidden(false);
descriptor.setPreferred(true);
descriptor.setShortDescription("session scoped attribute");
descriptor.setValue("type", value.getClass());
descriptor.setValue("resolvableAtDesignTime", Boolean.FALSE);
list.add(descriptor);
}
}
e = ctxt.getAttributeNamesInScope(PageContext.APPLICATION_SCOPE);
while (e.hasMoreElements()) {
name = e.nextElement();
value = ctxt.getAttribute(name, PageContext.APPLICATION_SCOPE);
FeatureDescriptor descriptor = new FeatureDescriptor();
descriptor.setName(name);
descriptor.setDisplayName(name);
descriptor.setExpert(false);
descriptor.setHidden(false);
descriptor.setPreferred(true);
descriptor.setShortDescription("application scoped attribute");
descriptor.setValue("type", value.getClass());
descriptor.setValue("resolvableAtDesignTime", Boolean.FALSE);
list.add(descriptor);
}
return list.iterator();
}
use of javax.servlet.jsp.PageContext in project tomcat70 by apache.
the class JspFactoryImpl method internalGetPageContext.
private PageContext internalGetPageContext(Servlet servlet, ServletRequest request, ServletResponse response, String errorPageURL, boolean needsSession, int bufferSize, boolean autoflush) {
try {
PageContext pc;
if (USE_POOL) {
PageContextPool pool = localPool.get();
if (pool == null) {
pool = new PageContextPool();
localPool.set(pool);
}
pc = pool.get();
if (pc == null) {
pc = new PageContextImpl();
}
} else {
pc = new PageContextImpl();
}
pc.initialize(servlet, request, response, errorPageURL, needsSession, bufferSize, autoflush);
return pc;
} catch (Throwable ex) {
ExceptionUtils.handleThrowable(ex);
if (ex instanceof RuntimeException) {
throw (RuntimeException) ex;
}
log.fatal("Exception initializing page context", ex);
return null;
}
}
Aggregations