JSF: Load a view from an external servlet
843842Jan 21 2007 — edited Jan 30 2007Hi,
The application is build with jsf(myfaces).
I need to display into an existing view a view generated by an external servlet.
I declared in the web.xml:
<servlet>
<servlet-name>TestServlet</servlet-name>
<servlet class>package.TestServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/sevlet/TestServlet</url-pattern>
</servlet-mapping>
In the .jsp I just added on a button:
action="#{bean.invoke}"
Where:
public void invoke()
{
String url = "/servlet/TestServlet";
FacesContext context = FacesContext.getCurrentInstance();
try
{
//ExternalContext ex=context.getExternalContext().;
context.getExternalContext().dispatch(url);
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
context.responseComplete();
}
}
If I try to run it I get:
message HTTP method POST is not supported by this URL
description The specified HTTP method is not allowed for the requested resource (HTTP method POST is not supported by this URL).