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?
 
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__
0
 
colr__Commented:
You an both POST and GET a servlet, with variables.

colr__
0
 
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.
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
kak39Author Commented:
Is there anyway you could just post to a domain? and then anything in that domain can read your POST??
0
 
kak39Author Commented:
Once I do that can I set that Parameter as a Session Cookie/variable? And how woudl i do that?
0
 
colr__Commented:
Yup, use the folloiwg to set your cookie:


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

colr__
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.