Did you try:

"/page2?foo=&bar=123"

Normally parameters come as key/value pairs, separated by an equal sign.


On 12/01/16 09:21, Mark Olsson wrote:
I'm getting unexpected parameter handling with a
request.getRequestDispatcher().forward().  Not sure if this is a bug or I'm
using gRD.f wrong, but here's the situation:

A POST is made with form data to a servlet (didn't try with a multipart
content, just regular) and the servlet decides to redirect to another
servlet using request.getRequestDispatcher().forward(), but adds parameters
on the new address.  Address parameters with a value "asdf=123" *are* sent
to the new servlet but parameters without a value *aren't*.

Example:
1. POST made to page1 with parameters input1="asdf" and button1 (no value).
2. The servlet handling page1 redirects to page2 and adds 2 parameters:
request.getRequestDispatcher("/page2?foo&bar=123").forward(request,response).
3. page2 gets the original parameters input1="asdf", button1, and new
bar="123" but not foo.  foo is in the browser address and is in the request
query string, but it's not one of the parameters sent along with the
request object.  Neither request.getParameterNames() nor
request.getParameter() will find "foo".  It also doesn't appear in the list
of parameters in Netbeans' server monitor.
4. Changing the order of the parameters (/page2?bar=123&foo) doesn't fix
it, but adding a value to foo does (/page2?foo=x&bar=123).

So what's up with valueless parameters on a servlet forward?

Tomcat: 8.0.26
Java: 1.8.0_60 Oracle
OS: Win7 and Linux 3.14.20-20.44.amzn1.x86_64


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to