Skip to Content
author's profile photo Former Member
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 a comment
10|10000 characters needed characters exceeded

Related questions

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 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 a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.