• Post Reply Bookmark Topic Watch Topic
  • New Topic

Basic question on names and values  RSS feed

 
Kayla Richard
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.
I am a beginner to servlets and I looked at a few examples. I would like to know from the following line what "cookieName" and "cookieValue" represent. They don't seem to be defined anywhere, how does it know what cookieName or cookieValue is?
String name = request.getParameter( "cookieName" );
String value = request.getParameter( "cookieValue" );
 
Mark Howard
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kayla
"cookieName" and "cookieValue" are user-defined names. You can call them anything you like, and are generally defined in HTTP request query strings or as posted FORM data.
Hope this helps
 
Kayla Richard
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark.
Thank you for replying. How do Http associate these names if you call them anything? Where is the association made? I don't know if I am making myself clear here.
 
Mark Howard
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kayla
Parameters in a request string could be defined in an HTML link as follows:

<a href="/webapp/servlet/MyServlet?cookieName=AAA&cookieValue=BBB">link name</a>

or supplied by a POST action in an HTML form as follows:

<form name="myForm" method="POST"
action="/webapp/servlet/MyServlet">
<input type="text" name="cookieName" value="AAA">
<input type="text" name="cookieValue" value="BBB">
</form>

Clear as mud
 
Kayla Richard
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay Mark!
I get it now.
Thanks now I see the light!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!