Passing values with forms to servlet.

I know how to pass values with a form to a direct JSP example ('www.website.com/index.jsp'). But, I have a servlet that is called ('www.website.com/servlet/test') that actually runs code in the directory ('www.website.com/jsp/code.jsp'). The only way to call is using the servlet, you cannot go to www.website.com/jsp/code.jsp to run it, it must be called using the servlet.

Can you post to the servlet?? or do you need a direct link?
kak39Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

colr__Commented:
You an both POST and GET a servlet, with variables.

colr__
kak39Author Commented:
Is there anything special I need to do in my servlet code to recieve it properly? I tried just posting to ''www.website.com/servlet/test' and it didn't seem to work.
kak39Author Commented:
Is there anyway you could just post to a domain? and then anything in that domain can read your POST??
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

colr__Commented:
Afraid not - if you post to a domain, you will end up posting to the root file of that domain, usually index.jsp or something like that.

In your servlet, use the following to get the arguments posted:

String username = request.getParameter("username");

colr__

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
kak39Author Commented:
Once I do that can I set that Parameter as a Session Cookie/variable? And how woudl i do that?
colr__Commented:
Yup, use the folloiwg to set your cookie:


       Cookie cookie = new Cookie("name","value");
       response.addCookie(mycookie);

colr__
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.