Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URLs and appending parameters

 
Nicole Jones
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to pick and choose what parameters to show and what parameters to not show in a URL?

I have a controller servlet that forwards the request/response to other servlets depending upon one given parameter.

Here is a snippet of code for the controller servlet:


In the other servlets, there is an array of a parameter. What I don't want is the "arrayed" parameter to be appended to the URL. example: http://localhost:8080/myApp/exportData?type=pdf?customerId=1?customerId=2?customerId=3

Here is a snippet of code for the "other" servlet:


I want the controller servlet to list the one parameter in the URL. example: http://localhost:8080/myApp/exportData?type=pdf INSTEAD OF http://localhost:8080/myApp/exportData?type=pdf?customerId=1?customerId=2?customerId=3. Is this possible?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65113
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A forward does not create a new request. The request, and all its parameters, is the same for the original servlet as well as the one to which it is forwarded.
 
Nicole Jones
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:A forward does not create a new request. The request, and all its parameters, is the same for the original servlet as well as the one to which it is forwarded.


Thanks. I'm going to try to use redirects w/ session attributes.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65113
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why? What's wrong with the forward? just ignore any parameters you are not interested in.
 
Nicole Jones
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what do you mean? are you referencing filters and/or wrappers? if so, too messy.

Bear Bibeault wrote:Why? What's wrong with the forward? just ignore any parameters you are not interested in.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65113
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Who said anything about filters and wrappers?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic