Re: html servlet flow



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



Relevant Pages

  • Re: html servlet flow
    ... browser and Tomcat. ... The browser submits an HTTP request, and the server sends an HTTP ... That response usually contains HTML, ...
    (comp.lang.java.programmer)
  • Re: caching problem
    ... >> I have to use a flash file as an intro with a ... response is even worse than normal, due to having to keep re-fetching ... though the actual details of how to do that depend on the browser ... > or failing that you could try using the PHP 'header' command to put ...
    (alt.html)
  • Re: Questions about HTTP headers sent with PHP in HTTP authentication
    ... And how are status codes sent to the browser if not?? ... and 5.1.2 the header function now prevents more than one header to be ... server send multiple response messages to one request?] ...
    (comp.lang.php)
  • [REVS] HTTP Response Smuggling
    ... Amit Klein shows that HTTP Response Splitting is still possible. ... Proxy Server 4.0, DeleGate 8.11.5) simply allow LF where CRLF is expected. ... a Content-Length header of his/her own. ...
    (Securiteam)
  • Re: Hot to prevent sending an HTML from asp.net
    ... Your browser is unlikely to be only making a head request, ... page rather than just a header. ... response, clear the existing response, write the appropriate header, flush ... want my asp to send only the http header response without some html trail. ...
    (microsoft.public.dotnet.framework.aspnet)