views:

94

answers:

4

Hi All,

I have two web application which are deployed in the same J2EE Application server. I need to redirect from one web application to another. Also I need to set some information in the Header from web application 1 so that it is available in web application 2. When I try to access the information which set in the header of Web App1 in Web App2, I'm getting "null". I'm using response.sendRedirect("http://localhost/webapp2") in Web Application 1 to redirect. Please help me to solve this.

Thanks, Apps.

A: 

You could send the information as URL parameters.

Redirect to http://localhost/webapp2?param1=value1&param2=value2 ....

letronje
I need to set the information in header.This is because web application 2 which is deployed on Production server gets the information from header(this is set by external security manager). We need to use web application 2 without modifying the existing code.
Deepa
A: 

One of the options would be to simple pass information as GET attributes in the URL you used in sendRedirect call.

iYasha
A: 

one option could be URL rewritting and passing param in URL like /id=abc&name=abc

if data is too long then you can use shared database

Edit:

you can use HttpURLConnection to

org.life.java
I need to set the information in header.This is because web application 2 which is deployed on Production server gets the information from header(this is set by external security manager). We need to use web application 2 without modifying the existing code.
Deepa
+4  A: 

A redirect is processed by the client (the browser). So only the client gets the headers you sent. The headers will not be passed to the webapp redirected to.

You can do one of the following things to pass information from one webapp to another:

  • pass data as request parameter
  • send data as cookie without path restriction
  • use cross context dispatching

A cookie received by the client will be send back to the server. The client does not know it is a different webapp. You just need to set the cookie path to /.

Cross context dispacthing is done by an internal forward in the container (use a RequestDispatcher from the ServletContext). The client will never know, the request is handled by another webapp. You than can set a request attribute to pass data. Cross context dispatching has to be enabled by the container for security reasons.

Arne Burmeister
I'm using WebSphere Application Server. I didn't find much information on Cross context dispatching. There is something called Remote Request Dispatching. But it requires a Network Deployment Version of WAS. Is it possible to do that across two web applications deployed on the same container? Could you please let me know the configurations that needs to be made?
Deepa
I'm no IBM consultant, but it should work. Don't know what the default config is, but I found something in the IBM pages: http://publib.boulder.ibm.com/wasce/V2.0.0/en/container-specific-web-application-settings.html
Arne Burmeister