Hi BOUTTE
You
you cannot use the request dispatcher to pass the attributes around in
different web apps, it requires the resource to which you want to dispatch the
request be in the same application context.
You
could do this by the simple approach ( :-) simple is the best ). Pass these
parameters as you pass your normal parameters, appended to the URL. Taking the
example below, your response.sendRedirect() line will change
to:
response.sendRedirect("http://localhost:7001/menu/test2.jsp?Language=toto");
The line above this is not required
anymore.
Now,
from inside the servlet/jsp which is available on the above
redirect URL, read up the parameters passed in the normal way,
i.e.,
String
Language = request.getParameter("Language");
I
guess this should do the trick.
Just
in case you don't wanna expose your parameter/value pair to the user through the
URL, you could invoke the resoiurce using "POST" semantics. If that is the case,
slight modification will be required to the above code, but it will still
work.
Best
Regards
Sanjeev
-----Original
Message-----
Hi,As everybody knows, sessions are not share between different
web application (JSP 1.2 / Servlet 2.3 Weblogic 6.1 SP3). I'm trying to pass parameters from one Web Application to another and i wonder
how to that.
I have found one solution :
1. Use a servlet filter to do that, but i can't get it to work !*** Test.JSP ***
<%@ page language = "java" %>
<%@ page isThreadSafe = "true" %>
<%@ page session="true" %>
<%@ page autoflush="true" %>
<%@ page isErrorPage="false" %>
<%
request.getSession().setAttribute("Language","toto"); -> Not required!!!
response.sendRedirect("http://localhost:7001/menu/test2.jsp");
%>*** Test2.jsp *** (noything interesting for the moment )*** Servlet Filter ***package utils;import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;public class TestFilter implements Filter
{
private FilterConfig filterConfig;public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain)
throws ServletException, IOException
{
System.out.println("****************************filter*************************");
System.out.println("**** Attribute language : " + request.getAttribute("Language"));
System.out.println("**** Attribute language : " + request.getParameter("Language"));
System.out.println("****************************filter*************************");
if (request instanceof HttpServletRequest)
{
HttpServletRequest httpr = (HttpServletRequest) request;
System.out.println("**** Attribute language : " + httpr.getSession().getAttribute("Language"));
}
else
System.out.println("false");
}
public FilterConfig getFilterConfig()
{
// Execute tasks
return filterConfig;
}public void setFilterConfig(FilterConfig cfg)
{
// Execute tasks
filterConfig = cfg;
}
}The servlet filter is working, i'm watching messages but
the attribute is always null and i don't see why it is null.
(Maybe, i would have to create a request dispatcher who takes
all attributes in session and sets them as header values
in send redirect ?)If you have any ideas, please tell me.Thanks Sebastien