Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Servlet-controller

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why servlet is used as controller why not JSP page?
[ December 29, 2004: Message edited by: nandakumar yathirajula ]
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP is a complement to servlet. Servlet is not really good at presentation, therefore JSP came. JSP can do whatever a Servlet can, but JSP is not really meant for that. In other words these are not the alternatives of each other. Both have a different purpose.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You certainly could use a JSP as a controller but I'm not sure why you would want to.

With the doPost and doGet methods there to be overridden, servlets are perfectly laid out for the task. JSPs are nice for the view tier because they look to a web designer, like HTML, PHP, ASP pages but while coding the control flow, it's nice to be in a pure Java environment.

Also, with servlets as the controllers, you can tighten security to your app by denying direct access to JSP pages. This way the only URLs that run on your server are those that you've defined in your deployment descriptor.

You could hammer a nail with the back of a wrench if you had to.....
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cent percent agreement with Ben.

If you look further in JSPs we have somemore complements like JSTL, Custom Tags Libs, EL, to discourage the use of scriplets even. One of the primary purpose of these stuff is to implement the tag like structure in JSPs. So it looks more like HTML, ASP, etc. We are encouraging web developers to use JSP no matter they know java or not.

Using JSP as a controller is not right, as Ben explained quite well, and I believe in doing right things.

cheers.
 
machines help you to do more, but experience less. Experience this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic