aspose file tools*
The moose likes Servlets and the fly likes Request Dispatch adding new parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Request Dispatch adding new parameters" Watch "Request Dispatch adding new parameters" New topic
Author

Request Dispatch adding new parameters

Sham Jowsaki
Ranch Hand

Joined: May 22, 2001
Posts: 146
HI all,
In Request Dispatcher method i need add one more parameter in my first servlet and then it has to forward to second servlet along with old parameter and new parameters (created in first servlet).
it is always returning null(created in first servlet).. can you pls advise me.
tks
jowsaki
boyet silverio
Ranch Hand

Joined: Aug 28, 2002
Posts: 173
hello Sham,
I understand a jsp (where parameters were provided) was called first. The jsp then forwards to the first servlet where you want to add new "parameters" say to be retrieved in the second
servlet. Parameters can not be added in the first servlet but "attributes" can be added instead, by using e.g.
request.setAttribute("newParam", newParam); // in the first servlet before forwarding to the second
request.getRequestDispatcher("/SecondServlet").forward(request, response);
Retrieve the "attribute" in second servlet thru
String newParam = (String)request.getAttribute("newParam");
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Request Dispatch adding new parameters