Link to home
Start Free TrialLog in
Avatar of jaggernat

asked on

set value in request

Dear Experts

I have a url like this

In my java class i am doing this

if (request.getParameter("option") != null) {
            String changetoMyCartAdd = request.getParameter("option");
                  //Here i want to change reports to myCart

My final output should be  option=myCart  i.e.  value of option  should be myCart

the above code doesnt work. any ideas

Avatar of Ajay-Singh

instead of setAttribute try using setParameter
Avatar of CEHJ
>>My final output should be  option=myCart

The output of what? Sounds more like you need to call respone.sendRedirect with the url you want to me ...
Avatar of jaggernat


The output of URL

my url should change to
it doesnt show me setParameter, it only shows me setAttribute.
Is setParameter depricated?
Attributes and Parameters are different things and you can't change the value of parameters you can only change the values of attributes. Why are you trying to change a parameter value? If you are wanting to use the changed value later on just use the attribute value that you changed.
>>> just use the attribute value that you changed

what ever i changed doesnt work

although i set it using above statement
changetoMyCartAdd still has the value reports. i want changetoMyCartAdd to be "myCart"

or option=myCart

 The output of URL

my url should change to

URLs don't have outputs. You need to response.sendRedirect from one to the other as i mentioned earlier
you need to rebuild the entire request string, you cannot do it by modifying the requrest
Avatar of reach2piyush
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial