It's not a secret anymore!
The moose likes Servlets and the fly likes Problem with the request dispatcher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problem with the request dispatcher" Watch "Problem with the request dispatcher" New topic

Problem with the request dispatcher

suneel kumar
Ranch Hand

Joined: Jan 08, 2007
Posts: 46
I have a problem with the servlets and JSP.I want to communicate with the two systems using servlets and jsps.
1)In my first jsp (a.jsp) i have one text box and one submit button.
when i submit the form it is going to one servlet( which is in my machine).
2)From the i am using
RequestDispatcher rd = context.getRequestDispatcher("http://ipnumber:8080/b.jsp");

3)Problem is while doing this one i am getting exception like request dispatcher must start with "/".
4)Instead of this if i use response.sendRedirect i am able to see the other machine b.jsp., but i am unable to get the same request what i have sent from

5) So, i just want to request one servlet on other machine and at the same time i need to access the request object on the other system

can any one guide me to this.

thanks in advance.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42959
That's not possible. RequestDispatchers only work within one web application, not across servers.

If you need to pass parameters in a redirect you can append them to the URL, like http://ipnumber:8080/b.jsp?param1=value1¶m2=value2. They will be visible in the browser URL field, though.
I agree. Here's the link:
subject: Problem with the request dispatcher
It's not a secret anymore!