WebSphere Portal Server - Invoke a Servlet from my FacesPortlet class

This is Interesting: Free IT Magazines  
Home > Archive > WebSphere Portal Server > February 2007 > Invoke a Servlet from my FacesPortlet class





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Invoke a Servlet from my FacesPortlet class

2007-02-20, 1:28 am

Hello,

I think this has been asked before, but I can't seem to find an answer to it. I am trying to invoke a Servlet from my FacesPortlet class, but I keep getting this error:

com.ibm.wps.servlet.response.ServletResponseWrapper sendError EJPPG1039E: HTTP error reported by Portlet: 404 SRVE0190E: File not found: "/TestServlet"

Here is the code I am using to call my servlet from the render() method of my portlet class:

PortletContext ctxt = (PortletContext)FacesContext.getCurrentInstance().getExternalContext().getContext();
PortletRequestDispatcher dispatcher = ctxt.getRequestDispatcher("/TestServlet");
dispatcher.include(request, response);

My servlet has a mapping in my web.xml file:

<servlet>
<display-name>TestServlet</display-name>
<servlet-name>TestServlet</servlet-name>
<servlet-class>pagecode.TestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/TestServlet</url-pattern>
</servlet-mapping>

I think my URL is messed up.... I have seen posts that recommend adding renderRequest.getContextPath() to the URL, but that didn't seem to work. If anyone can point me in the right direction I would be grateful.

Thanks in advance!

2007-02-20, 7:17 pm

Ok, so I added /servlet to my path and things work great now. Portlet invokes my servlet in doView

portletrequestdispatcher = getPortletContext().getRequestDispatcher("/servlet/TestServlet");
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com