When I pass parameters using response.redirect("URL?Parameter1=value1,Parameter2=value2"); in a servlet, the target JSP page fails to get the values for Parameter1 and Parameter2. Why?

Troy Niven

I can see a couple of things that could cause problems.

Here's an example of how I do this.

String theURL = "http://your_server.com/yourpage.jsp?"+ "Parameter1=value1&Parameter2=value2";
theURL = response.encodeRedirectURL(theURL);
response.sendRedirect(theURL);

Notice that the parameters need to be separated with an ampersand, rather than a comma.
I also use the encodeRedirectURL method, which will essentially URLencode the request. This is necessary when adding parameters to the URL.

Following the above example, you should be able to retrieve the variables within the JSP page, using the regular request.getParameter("parameter_name"); method.
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact