jaggernat
asked on
set value in request
Dear Experts
I have a url like this ..browse.do?option=reports
In my java class i am doing this
if (request.getParameter("opt ion") != null) {
String changetoMyCartAdd = request.getParameter("opti on");
if(changetoMyCartAdd.equal s("reports "))
{
request.setAttribute("opti on","myCar t");
request.setAttribute(chang etoMyCartA dd,"myCart ");
//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
thanks
J
I have a url like this ..browse.do?option=reports
In my java class i am doing this
if (request.getParameter("opt
String changetoMyCartAdd = request.getParameter("opti
if(changetoMyCartAdd.equal
{
request.setAttribute("opti
request.setAttribute(chang
//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
thanks
J
instead of setAttribute try using setParameter
>>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 ...
The output of what? Sounds more like you need to call respone.sendRedirect with the url you want to me ...
ASKER
The output of URL
my url should change to ..browse.do?option=myCart
my url should change to ..browse.do?option=myCart
ASKER
it doesnt show me setParameter, it only shows me setAttribute.
Is setParameter depricated?
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.
ASKER
>>> just use the attribute value that you changed
what ever i changed doesnt work
request.setAttribute(chang etoMyCartA dd,"myCart ");
although i set it using above statement
changetoMyCartAdd still has the value reports. i want changetoMyCartAdd to be "myCart"
or option=myCart
what ever i changed doesnt work
request.setAttribute(chang
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 ..browse.do?option=myCart
>>
URLs don't have outputs. You need to response.sendRedirect from one to the other as i mentioned earlier
The output of URL
my url should change to ..browse.do?option=myCart
>>
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
J
J