extraacting values from url

Hi all

can soemone tell me how i extract the values from a url?

if i do request.querystring(); i get all th values, but don't know how to get the individual vales

e.g. if i have this url www.domain.com/myscript.jsp?username=me&amount=200

i want to get the values for amount and username

also, if i want to set a http header do i do it like this

response.addHeader("myHeader", "myHeaderValue");

and then if i want to get the header value i do request.getHeader("myHeader");

Thanks for any help

daleconAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

koppchaCommented:
> want to get the values for amount and username
String userName=  request.getParameter("username");
String amount= request.getParameter("amount");


To set the response header you can use
setHeader--If header already exists then it will overwrite the value of that header
addHeader--If header allows headers to have multiple values.

To get the value you have to do
getHeader

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
daleconAuthor Commented:


Hi

Thanks for your help

I have a jsp and i just want to test setting/getting headers

So i have an index.html page with <input> tags and a submit button that goes to myscript.jsp page

In myscript.jsp i have code that gets the parameters in the url - which i can get, but i also want to set a header

So i've done this

<%
response.setHeader("myheader", "123456");

String myheader= request.getHeader("myheader");                              
String userName = request.getParameter("username");
String amount = request.getParameter("amount");
            
System.out.println("myheader " + myheader);
%>


When i check th output the myheader is null

Can you tell me what i'm doing wrong

Thanks for any help
koppchaCommented:
Hi
 Sorry for the delayed response.Please go through this link
http://www.informit.com/articles/article.asp?p=29817&seqNum=8&rl=1

You can not set your own type as header...Why do you want to set the header i mean what is the functionality that you are trying to achieve?
daleconAuthor Commented:


No worries about the getheader -  re-read the documentation, know what i need to do now

Thanks for your help


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.