Forums Register Login

Few Basic Questions

+Pie Number of slices to send: Send
Hi all,
I just started study for my SCWCD certification, however I've already come up with half a dozen questions that haven't been address in the book I'm reading. Can someone please answer the following questions or advise a book I can read to answer these question:
1. A request contains the parameter names and values which come from the
URL or from a body of a form. Is there any other place
where parameter(s) can come from?
2. What is the purpose of a cookie?
3. What does a cookie contain?
4. How does a session differ from a cookie?
5. What are the benefits of using a cookie instead of a session
or visa versa?
Thanks for your help.
+Pie Number of slices to send: Send
 


A request contains the parameter names and values which come from the
URL or from a body of a form. Is there any other place
where parameter(s) can come from?


No. There are the only two ways of passing parameters. However if you need to pass some data along with the request object as you move from JSP to JSP or any other combination, you can utilize setting attributes. Format of getting attributes is similar to getting parameters getAttribute(name)


What is the purpose of a cookie?


A cookies is a piece of information ( name value pair ) that a browser can store on a user's machine. The request for storing a cookie comes from the server.
When ever you request for any page ( http://www.javaranch.com/cgi-bin/ubb ) the brwoser would check if there are any cookies that are eligible to be sent to that server [ These cookies were previously stored on client's machine on the request of this server ]. If there are any, they are sent to the server.
On the server side you would use request.getCo0kies() to get an array of cookies. [ I hope you get difference between passing cookies and passing parameters]


What does a cookie contain?


It would contain name value pair


How does a session differ from a cookie?


You can implement session tracking using cookies. Cookies are 'means' to achieve 'ends' ( session tracking)


What are the benefits of using a cookie instead of a session
or visa versa?


Session tracking can be implemented using url rewriting or using the Session object provided by the application server. Generally cookies are not used for session tracking in practical scenario. They are generally used to remember the user preferences. More details you can find in coreservlets book where Marty describes the different scenarios of using cookies. Benefits of Cookies[http://csajsp-chapters.corewebprogramming.com/CSAJSP-Chapter8.pdf]
Thanks
+Pie Number of slices to send: Send
 


No. There are the only two ways of passing parameters. However if you need to pass some data along with the request object as you move from JSP to JSP or any other combination, you can utilize setting attributes. Format of getting attributes is similar to getting parameters getAttribute(name)


So are you saying that if I need to pass some data along with the request object when moving from JSP to JSP or any other combination, I would need to set attributes by utilizing the session or cookie, is that correct?


A cookies is a piece of information ( name value pair ) that a browser can store on a user's machine. The request for storing a cookie comes from the server.


Cookie sounds so familiar to the session or request. Since they both are "name value pair", correct? Only difference is that a session resides specifically on the server and a request only exist for a POST?


You can implement session tracking using cookies.


Can you please elaborate on this further? What do you mean by session tracking, like what for example?
Thanks for the information.
+Pie Number of slices to send: Send
Hello Shannon !
I suggest you re-visit some basics with respect to three topics:
HTTP, Servlets and JSPs.
You should focus on the concepts of an HTTP request to a Web-server, how a Server "handles" the request. Also spend some time on the concept of Sessions((In other words, the mechanism with which numerous calls from the sames client can be tied together), the types of Session tracking, how Servlets can help with this, etc
There seems to be some confusion on your part about these basic topics and answering your quesions in bits and pieces is only going to confuse you more.
If you study the above topics, I am sure you will be able to answer your own questions.
Hope I have helped you.
-Sri
+Pie Number of slices to send: Send
You also might want to take a look at http://resources.corejsp.com/scwcd.html.
Cheers-
- Marty
Just let me do the talking. Ahem ... so ... you see ... we have this tiny ad...
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 778 times.
Similar Threads
Confusion between Cookie and JSession
Question about URL rewriting
any good summary on choosing overloaded method with autoboxing/widening/var parameters?
Motivation and Reason for the "How Tomcat Works" book
Use of Cookie
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 06:29:51.