Skip to Content
author's profile photo Former Member
Former Member

Removing generated code from JSP pages


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??



Add comment
10|10000 characters needed characters exceeded

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on 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 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");


    HttpServletResponse response = arg0.getServletResponse(true);

    DOMSource domSource = new DOMSource(doc);

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

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


    } 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