Skip to Content
avatar image
Former Member

Removing generated code from JSP pages

Hi,

i'm trying to display a PDF file in the browser but i cannot change the Content-type display. I know it works in Tomcat but in the Portal there's a lot of generated code that restrict me from diplaying a PDF to the client.

How can i remove the Portal generated code??

Thanks,

Marjolaine

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Mar 22, 2004 at 02:49 PM

    You need to make you class extend from AbstractPortalComponent (instead of dynpage or similar) and overwrite the onNodeReady method.

    Cutting in example from iviewstudio.com thread, but I think you need to set the content type on the response (but you should see the general picture)

    import com.sapportals.portal.prt.component.AbstractPortalComponent;

    import com.sapportals.portal.prt.component.IPortalComponentRequest;

    import com.sapportals.portal.prt.component.IPortalComponentResponse;

    import com.sapportals.portal.prt.pom.IEvent;

    public class XMLComponent extends AbstractPortalComponent

    {

    protected void doOnNodeReady(IPortalComponentRequest arg0, IEvent arg1) {

    try {

    Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();

    // modify the empty document here, something like this:

    Element root = doc.createElement("myRoot");

    doc.appendChild(root);

    HttpServletResponse response = arg0.getServletResponse(true);

    DOMSource domSource = new DOMSource(doc);

    StreamResult result = new StreamResult(response.getOutputStream());

    Transformer copyTransformer = TransformerFactory.newInstance().newTransformer();

    copyTransformer.transform(domSource,result);

    } catch (Exception e) {

    arg0.getLogger().severe(e,"while putting out my xml");

    }

    }

    public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)

    {

    // will never be invoked, since 'getServletResponse(true)' (see above)

    }

    }

    Add comment
    10|10000 characters needed characters exceeded