Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Request dispatch from one web app to another

 
karthik aswin
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 4402
251
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
karthik aswin
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
karthik aswin
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 4402
251
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you properly set the path attribute of the Context for Spring_MVC ?
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4402
251
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since the discussion is now turned into Tomcat related stuffs, I'm moving this to the Tomcat forum.
 
karthik aswin
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 4402
251
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remove the forward slash (/) from docBase
 
karthik aswin
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the prompt reply !!!



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



Tried it. But still getting the same error

 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where exactly is hello.jsp placed?
 
karthik aswin
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jaikiran Pai wrote:Where exactly is hello.jsp placed?


Inside WebContent folder of the app named Spring_MVC
 
karthik aswin
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No reply ! I am struck help me outta thiss
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic