• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Understanding on web app deployment and working

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
I have pursued my OCPJP certification with 90%.
BUT I'm very new to JSP and Servlet

I will tell my basic understanding on web application deployment and working.

please rectify if necessary

whenever client clicks on URL a HTTP request is made to web server like Apache and if the request is for dynamic
web page then request is passed to Tomcat(Servlet and jsp engine/web container) and that checks the deployment descriptor mapping
and passes the request to concerned Servletfor processing the request (instantiates the concerned servlet and invokes doGet() or doPost() based on HTTP request)
and this servlet will render a HTML page to web server and
that HTML page will be wrapped to HTTP response and will be returned to client browser



please do read and check above quote and let me know if i'm correct or wrong???


thanks in advance
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sawan Mishra wrote:
and this servlet will render a HTML page to web server and
that HTML page will be wrapped to HTTP response and will be returned to client browser


Well servlet does not render HTML page, it is actually meant for control, but lets say for now it can produce some sort of response.
This response is passed to the container which in turn passes it to the application server then to web server and finally the client.
The client is responsible for handling the response which could be HTML, image, PDF,etc.

For more information on this, please take a look at this page.
 
Sawan Mishra
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
but murach's servlet book says:

when a web server receives the request for dynamic web page the server passes the request to web application
then application receives the request and generates a response usually a html page and web server wraps this response
html document in an http response and sends it back to the browser



Anyways if I'm using tomcat then its not application server as it has not implemented all j2ee features so
whatever you said regarding application server may not be applicable here.


please rectify me if necessary

thanks in advance
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The term "application server" has no set definition. Whether Tomcat is an application server or not depends upon your definition of the term.
 
Sawan Mishra
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Amit

Well servlet does not render HTML page, it is actually meant for control, but lets say for now it can produce some sort of response.



But in the servlet we are having all
out.println() statements so it renders a html document to servlet engine(Tomcat) and then html document is sent to web server that wraps it to HTTP response
and sends back this html document to browser.

please rectify me if necessary.

thanks in advance
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure, a servlet can emit anything it wants to as the response, including HTML. But that's not considered the best practice. The servlet should performa any processing that needs to get done in order to prepare the page for display, and then forward to a JSP to actually render the HTML.
 
Sawan Mishra
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bear,

Sure, a servlet can emit anything it wants to as the response, including HTML.
But that's not considered the best practice. The servlet should performa any processing
that needs to get done in order to prepare the page for display, and then forward to a JSP
to actually render the HTML.





thanks Bear for replying. But even if request is forwarded to jsp the jsp itself gets translated to
servlet and compiled and gets loaded to servlet engine and servlet engine runs this servlet so
ultimately whatever we are writing in jsp page must be becoming
out.println("content of jsp page") so servlet renders html code to web server which is sent back to browser
as HTTP response.

I'm not saying that servlet won't do processing but after processing it has to return some html code which will be
sent back to client as HTTP response.

thanks Bear
with regards
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, but that's just hand-waving. It may be the case that a JSP is compiled into a servlet, but you didn't write that servlet. It's also true that the servlet is compiled into byte code, but nobody bothers to say that it's actually the byte code which is generating the HTML. That's because it's irrelevant. Ultimately the byte code is executed by the JVM and converted into machine instructions which are executed by a CPU, but nobody cares that it's the CPU which is really generating the HTML.

 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sawan Mishra wrote:But even if request is forwarded to jsp the jsp itself gets translated to
servlet and compiled and gets loaded to servlet engine and servlet engine runs this servlet so
ultimately whatever we are writing in jsp page must be becoming


As Paul said, that is an irrelevant implementation detail that has no effect (or shouldn't) on how you write servlets and JSPs.
reply
    Bookmark Topic Watch Topic
  • New Topic