Article by Joey Bernal on Websphere Portal Programming - Websphere

This is a discussion on Article by Joey Bernal on Websphere Portal Programming - Websphere ; Hi All, I need your help portal experts.I had been goin through this article by Joey Bernal. http://www-128.ibm.com/developerwork...11_bernal.html This article mentions that in order to invoke a servlet from a portal page deployed in the same war file use the ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: Article by Joey Bernal on Websphere Portal Programming

  1. Article by Joey Bernal on Websphere Portal Programming

    Hi All,

    I need your help portal experts.I had been goin through this article by Joey Bernal.
    http://www-128.ibm.com/developerwork...11_bernal.html

    This article mentions that in order to invoke a servlet from a portal page deployed in the same war file use the hyperlink:
    " target="_blank">Launch Test Servlet

    I have a servlet for "writing data into a word file" and want to invoke it using the above hyperlink but when i try doing that i get the error "page not found".
    But guide me how can i invoke my servlet from my portlet.
    Using Websphere Portal Server 5.1.0.3 and Faces Portlet.

    Best Regards,
    Pallavi

  2. Re: Article by Joey Bernal on Websphere Portal Programming

    Hi,

    I would use <a href="<cut value="${renderRequest.contextPath}" />/TestServlet">link</a>

    Or without JSTL: <a href="<%=portletRequest.getContextPath()%>/TestServlet">link</a>

    Regards, Marc

  3. Re: Article by Joey Bernal on Websphere Portal Programming

    Hi,

    I would use ut value="${renderRequest.contextPath}" />/TestServlet">link

    Or without JSTL: link

    Regards, Marc

  4. Re: Article by Joey Bernal on Websphere Portal Programming

    Hi Marc,

    Thank you for your reply.
    I have tried using both the links that you suggested.
    a)ut value="${renderRequest.contextPath}" />/TestServlet">link

    Exception thrown in console as: com.ibm.wps.engine.Servlet doGet() class com.ibm.wps.state.nls.exceptions.NlsCannotInterpre tCodecException: EJPEI0073E: The input mediator class com.ibm.wps.state.inputmediators.WPInputMediator@3 42948402 could not interpret codec ut value= for request com.ibm.wps.engine.PortalRequestWrapper@4d917a34.

    b)link
    Error on page: portletRequest cannot be resolved.I have included the in my portlet.

    My Servlet Code is:
    public class WordServlet extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String filen = "myFile.doc";
    String myTextArea = "This is my data that i write into word";
    response.setContentType("application/vnd.ms-word");
    response.setHeader( "content-disposition","attachment;name=\""+filen+"\";filename=\""+filen+"\"");
    response.setHeader("Cache-Control", "no-cache");

    try{
    byte[] buf=new byte[4*1024];
    InputStream inStream=new ByteArrayInputStream(myTextArea.getBytes());
    OutputStream outStream=response.getOutputStream();
    int sizeRead;
    while ( ( sizeRead=inStream.read(buf, 0, buf.length) ) != -1 )
    {
    outStream.write(buf, 0, sizeRead);
    }
    inStream.close();
    outStream.close();

    }
    catch(IOException ex){ ex.printStackTrace();}
    }
    }

    I would be grateful if you could help me.

    Best Regards,
    Pallavi


  5. Re: Article by Joey Bernal on Websphere Portal Programming

    According to your stacktrace, you are using the IBM API. The code I wrote is using the JSR 168 Portlet API. Try to replace 'renderRequest'.

    Marc

+ Reply to Thread