Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference between these 2 methods?  RSS feed

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may be a stupid question, but what is the difference between creating a simple HTML page that directs to a Servlet which produces the dynamic content of the web page, and creating a JSP page that probably still uses the same servlet as mentioned above? Where as the servlet this time probably won't handle any formatting of HTML?
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I generally want my servlets generating as little HTML as possible due to maintenance issues. Servlets tend to get large when they generate html and editing them becomes error prone.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahh, I c. Thanks.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the appropriate method then would be:
RequestJSP to Servlet1 to ResponseJSP to Web Browser.
I had read that before, just didn't know if this was generally good practice or if the example just used it as a "you could do it this way" method.
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Everything I have read recommends this practice.
 
Mark Howard
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or that Model-View-Controller pattern of:
1) Client request invokes Servlet (Controller)
2) Controller servlet creates JavaBeans (Model)
3) Controller servlet forwards request to JSP (View)
4) JSP uses Beans created by Controller servlet
5) JSP renders response to Client
Neat and tidy
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys. That's what I needed to know.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!