File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes what should i use servlet or jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "what should i use servlet or jsp" Watch "what should i use servlet or jsp" New topic

what should i use servlet or jsp

Arun Maalik
Ranch Hand

Joined: Oct 25, 2005
Posts: 216
Dear sir

Suppose a project has been asigned to me. How will i know that whether i have to used servlet or jsp.

with regard

Arun kumar maalik
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63844

You don't choose one or the other. You use both to their best advantages.

Perhaps, this article on web application structure might be helpful.
[ August 24, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [About Bear] [Books by Bear]
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
And quite possibly you should use neither.
If you need to ask this question that's the most likely answer and you should tell them you don't have the skills to complete the project.

krishna prasad gunasekaran
Ranch Hand

Joined: Jul 25, 2006
Posts: 158
hello arun, to begin with, i am an amateur, and have just started a project. i have tried my best to answer.

MVC pattern would be the answer to your question. leave all the business logic to model(POJC, EJB), presentation logic to jsp, and control(servlet) as a mediator between view and model. Though you can call model from view, it' a bad practise.
Think of jsp as a dymnamic HTML page that clients see(ofcourse, that what they are developed for). with dynamism comes the scripting. don't use secripting in jsp, use ELs, tags etc.,instead.

so, to epitomize, use all the three (jsp, servlet, and POJC or EJB).

thank you and see if it's enough, else reply.

have a great day,
krishna prasad
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

Use Servlets to handle the incoming request, inspect the request, and figure out what the heck the client wants you to do.

Use a JSP to format a nice HTML or WML page to be sent back to the user.

If it's not control logic, which sho uld be in the Servlet, or display logic that should be in the JSP, use a JavaBean or POJO or even an EJB.

You can do it, dude!

Here are some good multimedia presentations on creating Servlets and JSPs using WSAD and IRAD. Even if you're not using those tools, the code still applies.

Good luck!
[ August 27, 2006: Message edited by: Bear Bibeault ]
I agree. Here's the link:
subject: what should i use servlet or jsp
It's not a secret anymore!