Can Context switchg help me out?
hi..
i've an application which is in jsf
& i want to integrate it with another application in struts.
now da problem wid me isi have to call a page of the struts app from one of my jsf pages...i think it can be done by context switching... but cant exactly find da way out of it.
the path of my application is "C:\Tomcat 5.5\webapps\myJSFApp"
and the roller is installed at "C:\Tomcat 5.5\webapps\myStrutsApp"
can any body help me?
:)
Ansh
[514 byte] By [
Ansh.a] at [2007-11-27 3:33:18]

# 2
hi Balus.
thnx 4 da reply..
here m attaching da code plz have a luk..
public void forward()
{
FacesContext loginContext=FacesContext.getCurrentInstance();
String url="http://localhost:8080/login/login.faces";
try {
loginContext.getExternalContext().dispatch(url);
} catch (Exception e) {
e.printStackTrace();
}
finally
{
loginContext.responseComplete();
}
}
here m trying 2 swith frm loginContext to the url specified.
4 testing purpose i have both of my app in jsf only.
it still doesn't works.
it gives n error s follows:
/http:/localhost:8080/login/login.jsp
plz do notice da (/) b4 http://
shuld i do sumthing in the tomcat configuration...
Regards,
Ansh..
:)
# 4
well i hve tried dat...
plz hv a luk at da code
public void forward()
{
try
{
FacesContext loginContext=FacesContext.getCurrentInstance();
String url="http://localhost:8080/login/login.faces";
ServletContext rollerContex =(ServletContext) loginContext.getExternalContext().getResourceAsStream(url);
RequestDispatcher rd = ((ServletContext) loginContext).getRequestDispatcher("/"+rollerContex.toString());
}catch(Exception e)
{
e.printStackTrace();
}
}
it gives exception like dis:
java.lang.ClassCastException: com.sun.faces.context.FacesContextImpl
at in.v2solutions.com.LoginHelper.forward(LoginHelper.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
at javax.faces.component.UICommand.broadcast(UICommand.java:312)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
is der ne other options?
# 6
Sorry i had given u another version..
plz hv a luk at dis:
FacesContext loginContext=FacesContext.getCurrentInstance();
HttpServletResponse res=(HttpServletResponse) loginContext.getExternalContext().getResponse();
String url="http://localhost:8080/login/login.faces";
res.sendRedirect(url);
now da exception r like dis
java.lang.IllegalStateException: Cannot forward after response has been committed
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:198