aspose file tools*
The moose likes Tomcat and the fly likes Request dispatch from one web app to another Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Request dispatch from one web app to another" Watch "Request dispatch from one web app to another" New topic
Author

Request dispatch from one web app to another

karthik aswin
Greenhorn

Joined: Jun 10, 2009
Posts: 18
Hi all,

Here s my constraint. I have to use request dispatch from one web app to another. I cant use sendRedirect because i do not want to lose the request header. i am using Tomcat 6 as my server. Is there a way to do it?
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3050
    
  36

karthik aswin wrote:because i do not want to lose the request header....... Is there a way to do it?

No way to transfer the request object to another web application. But you can wrap those headers into a SOAP message and send to the other web application through a web service.

Devaka


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
karthik aswin
Greenhorn

Joined: Jun 10, 2009
Posts: 18
Devaka Cooray wrote:
karthik aswin wrote:because i do not want to lose the request header....... Is there a way to do it?

No way to transfer the request object to another web application. But you can wrap those headers into a SOAP message and send to the other web application through a web service.

Devaka


But i heard that If i get the request dispatcher from context, i can pass my request across the application.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41489
    
  53
Since we're talking about Tomcat here, it is, in fact, possible. It is achieved by setting the crossContext attribute of the Context to true. See http://tomcat.apache.org/tomcat-6.0-doc/config/context.html for details.


Ping & DNS - my free Android networking tools app
karthik aswin
Greenhorn

Joined: Jun 10, 2009
Posts: 18
Ulf Dittmer wrote:Since we're talking about Tomcat here, it is, in fact, possible. It is achieved by setting the crossContext attribute of the Context to true. See http://tomcat.apache.org/tomcat-6.0-doc/config/context.html for details.


I tried it but could not get it to work. When i try to access the jsp file of another web app i get the following error HTTP Status 404 - /hello.jsp requested resource not available.

I call the jsp from another application using the following lines

ServletContext ctx=application.getContext("/Spring_MVC");
RequestDispatcher rd =ctx.getRequestDispatcher("/hello.jsp");
rd.forward(request,response);

Am i doing anything wrong here ??
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3050
    
  36

Have you properly set the path attribute of the Context for Spring_MVC ?
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3050
    
  36

Since the discussion is now turned into Tomcat related stuffs, I'm moving this to the Tomcat forum.
karthik aswin
Greenhorn

Joined: Jun 10, 2009
Posts: 18
Devaka Cooray wrote:Have you properly set the path attribute of the Context for Spring_MVC ?


Here is the context attribute i mentioned in server.xml

<Context path="/Spring_MVC" docBase="/Spring_MVC" debug="0" crossContext="true"
reloadable="true">
</context>


Is this right?


Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3050
    
  36

Remove the forward slash (/) from docBase
karthik aswin
Greenhorn

Joined: Jun 10, 2009
Posts: 18
Thanks for the prompt reply !!!



Devaka Cooray wrote:Remove the forward slash (/) from docBase



Tried it. But still getting the same error

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41489
    
  53
Have you tried setting the crossContext attribute of the web app from which you want to forward? That's how I read the docs.
karthik aswin
Greenhorn

Joined: Jun 10, 2009
Posts: 18
Ulf Dittmer wrote:Have you tried setting the crossContext attribute of the web app from which you want to forward? That's how I read the docs.


Done. here s what my server.xml looks like

<Context path="/Spring_MVC" docBase="Spring_MVC" debug="0" crossContext="true"
reloadable="true">
</context>


<Context path="/Orbeon-Test" docBase="Orbeon-Test" debug="0" crossContext="true"
reloadable="true">
</context>

But still getting the same error. Help !
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10033
    
163

Where exactly is hello.jsp placed?


[My Blog] [JavaRanch Journal]
karthik aswin
Greenhorn

Joined: Jun 10, 2009
Posts: 18
Jaikiran Pai wrote:Where exactly is hello.jsp placed?


Inside WebContent folder of the app named Spring_MVC
karthik aswin
Greenhorn

Joined: Jun 10, 2009
Posts: 18
No reply ! I am struck help me outta thiss
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Request dispatch from one web app to another