Re: html servlet flow
- From: Mark Space <markspace@xxxxxxxxxxxxx>
- Date: Sun, 18 Jun 2006 06:59:47 GMT
Well, I don't think of myself as an expert or anything, but I'll give this a shot.
Jeff Kish wrote:
Is this right?
Say there is a hard coded jsp page, say:
What is "hard coded" jsp??? :(
Then the browser packs up the 'mypage.jsp' and formats it in the protocol of http, and send it to the address (tomcat here).
Sorta, but I don't like the "packs up" and calling tomcat an address. There some magic happening with DNS in there too, although most of that is done by your OS.
Then tomcat recognizes the protocol, unpacks the request, and sees "mypage.jsp".
Then it looks wherever it is legal for jsp pages to exist, and starts processing the mypage.jsp?
Sorta again, but tomcat doesn't really recognize the protocol. That's done by the OS, usually a deamon, which sends the packet(s) to Tomcat (or whoever is listening on the port). Of course, if you just send random bytes to tomcat on port 80, it'll probably not give you anything back.
If it is a simple page, it packs up the code/html in the jsp page into
the response and puts it in http format and sends it to the browser.
Not really. JSP are code, and executed. They are never simple pages. A plain text file is pretty much sent as-is. I can't remember now how much the HTTP response header has, but it's pretty minimal for basic response. It's possible no headers at all are sent for plain text, for example.
The request headers can be very simple too. I think I once tested a balky connection by typing "telnet cnn.com 80" on the command line. When I got a prompt, I typed GET and closed the input channel. I got a html page from the cnn.com server back before it closed the channel on it's side.
IE, I sent no headers at all.
When the browser gets the response, it recognizes it is http, unpacks
it, and starts processing the html in the response.
Yes, by the time the browser sees the response, it's all just plain text or plain HTML or just a wvm movie or something (with a small HTTP header attached in the case of the latter 3).
And this 'response' isn't the response parameter in the doGet method,
it is just the general 'response' from the Tomcat.
No, the response is EXACTLY the response parameter of the doGet method. That is EXACTLY what you are constructing; it is exactly the response the browser will see. Stuff the string "Hello World" into the response object and that what the browser will receive (and display). Put random binary bytes in the response and the browser will display computer gibberish.
Extra informatoin like headers etc are in the actual doget 'response'
variable.
Yes, headers are in the response as well. You need to control the header so the browswer will know what it is getting. But mostly you just set the mime-type, most other header parameters are set-up for you.
You really should do a google search for "http tutorial" or similar, I think it'll help you quite a bit.
.
- References:
- html servlet flow
- From: Jeff Kish
- Re: html servlet flow
- From: Jeff Kish
- Re: html servlet flow
- From: Oliver Wong
- Re: html servlet flow
- From: Jeff Kish
- html servlet flow
- Prev by Date: Re: Distribute java program with security
- Next by Date: Re: jsp - I feel like an ass!
- Previous by thread: Re: html servlet flow
- Next by thread: Re: html servlet flow
- Index(es):
Relevant Pages
|