Search in sources :

Example 6 with PageContext

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);
    }
}
Also used : ServletRequest(javax.servlet.ServletRequest) JspException(javax.servlet.jsp.JspException) PageContext(javax.servlet.jsp.PageContext) JspException(javax.servlet.jsp.JspException)

Example 7 with PageContext

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();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) PageContext(javax.servlet.jsp.PageContext) JspWriter(javax.servlet.jsp.JspWriter) Test(org.junit.Test)

Example 8 with PageContext

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();
}
Also used : JspContext(javax.servlet.jsp.JspContext) FeatureDescriptor(java.beans.FeatureDescriptor) ArrayList(java.util.ArrayList) PageContext(javax.servlet.jsp.PageContext)

Example 9 with PageContext

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();
}
Also used : JspContext(javax.servlet.jsp.JspContext) FeatureDescriptor(java.beans.FeatureDescriptor) ArrayList(java.util.ArrayList) PageContext(javax.servlet.jsp.PageContext)

Example 10 with PageContext

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;
    }
}
Also used : PageContext(javax.servlet.jsp.PageContext)

Aggregations

PageContext (javax.servlet.jsp.PageContext)36 JspContext (javax.servlet.jsp.JspContext)12 JspWriter (javax.servlet.jsp.JspWriter)10 IOException (java.io.IOException)6 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 ArrayList (java.util.ArrayList)5 JspException (javax.servlet.jsp.JspException)5 FeatureDescriptor (java.beans.FeatureDescriptor)3 Test (org.junit.Test)2 BannedPeer (i2p.bote.network.BannedPeer)1 DhtPeerStats (i2p.bote.network.DhtPeerStats)1 DhtPeerStatsRow (i2p.bote.network.DhtPeerStatsRow)1 RelayPeer (i2p.bote.network.RelayPeer)1 PrintWriter (java.io.PrintWriter)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Locale (java.util.Locale)1 Map (java.util.Map)1