• 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

Why servlet in WebApplication

 
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Frieds, I am new to servlet why to use servlet in webapplication. what i know is " use servlet as a controller in mvc and to implemnent business logic . is it correct ? One more thing reason for implementing business logic with servlets , why not jsp.
 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Servlets came into picture as a real good alternative to CGI. Compared to CGI, servlets have a lot of advantages. Have a look at it
This is also good

Servlets can be used as a presentation layer technology. Here we will write HTML tags in java.
Ofcourse, for the ease of use and code maintainability, and a lot more advantages, we can use jsp or any of the similar kind of presentation layer technologies.

(Do a google search for servlets vs jsp.)

Regards,
Teena
 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Friend, I asked why servlet for implementing business logic. why not jsp.
 
Teena George
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

As far as I know, we should not implement business logic in our presentation logic (servlets, jsp, xhtml etc). It should be handled in our business logic layer. For e.g. using EJB.

Regards,

Teena
 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
suppose am not using ejb. i searched in google "Based on the situation we can decide.For example we are using Database related things(Opening a connection,executing statements etc.i.e, called as business logic)it is better to use Servelts(Re usability is possible with servlets but not with jsp's)Most of cases we use jsp's for presentation.i.e,the output nthat has to sent to browser can be done by making use of jsp's " is it correct?
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rajendra,

Most of the things a servlet can do a JSP also can do (a JSP eventually is translated in to a servlet). But the JSP is meant to provide the facility for creating the "view" part of the application. It's easy to write HTML in JSP rather than in servlet.
 
Teena George
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


"Based on the situation we can decide.For example we are using Database related things(Opening a connection,executing statements etc.i.e, called as business logic)it is better to use Servelts(Re usability is possible with servlets but not with jsp's)


Can you provide the link where you have seen this?
 
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
You can use a hammer to bang in a screw, and you can drive on the wrong side of the road if you like. Neither is smart.

Using the right tool for the job, and following accepted conventions and best practices is smart.

Servlets and JSP are intended, and best suited, to be used as part of the Presentation Layer of web applications. As such neither should be used for business logic, which should be ensconced in its own UI-agnostic layer.

Perhaps this article can help.
 
reply
    Bookmark Topic Watch Topic
  • New Topic