When to choose JSP and When to choose Servlet in Web Application

Hi,
I know that using JSP over servlet has only one advantage like for huge Application you can devide presentation layer from business logic. Is there any other advantage.
Also, if anyone can tell me how to handle FTP request in Servlet as HttpServlet supports only HTTP.
Thanks.
Subs

Depends on what you're rying to accomplish. If you want to generate a bunch of HTML then JSP is the way to go. If you just want to extend the server (i.e. add functionality that isn't specific to any one screen of your application), then Servlets are the way to go.
Additionaly, if you have a lot of HTML forms, and want to do it right, check out Struts. This would be the case if you wanted to both extend the server and generate HTML. It's an MVC framework available from Jakarta. It's fairly tried and true at this point. It makes it very easy to maintain, extend, and develop with. It also comes with a wealth of custom tag libraries out of the box. I have developed two projects with it so far and find it a pleasure to work with.
http://jakarta.apache.org/struts/index.html
Regards,
Kyle

Similar Messages

  • When to use jsp,and when to use servlet?

    I think that jsp and servlet can realize the same functions, because when run a jsp, it is transferred to a servlet program, so when to use jsp and when to use servlet?
    I am now developing the input interface for a website, I just use jsp and javabean to connect to weblogic and database, and I didn't use servlet, Is there any unseemliness?
    Thank you!

    IMHO I use servlets to control the flow between my jsp's based on a number of factors in a webapp. For instance, user authorization. If a user has the authorization to conduct various administrative functions on an application (like change user rights, reset passwords etc) they will have access to specific buttons or links on some screens that others will not. I use servlets to establish what access rights a user has and direct them to the appropriate pages. I also use servlets to test data validity on form input screens. I know that I can also do this with JavaScript but that can be disabled by the client and in order to prevent that I also double check the form input from a servlet. All my jsp's do is display the results of a business process (which is held in a JavaBean or EJB) and the servlets act as the controllers for the application, connecting to multiple databases, verifying application state, flow control etc. I try to keep the jsp as simple as possible as some of them are maintained by html developers who lack the necessary experience to write java code. I hope this helps.

  • When to use inheritance and when not to?

    I've just been trying find out when to use inheritance and when not to use inheritance? I know that inheritance gives advantages such as code reuse and maintainability. But when are their times not to use inheritance that may effect the design of a project?
    Also when should one consider aggregation over inheritance(is-a relationship)?
    thanks,
    plandis

    Hi
    Answering this question usually requires a few books, so, I'm sorry, it's not really as simple as choosing between using a screwdriver vs. a hammer.
    But, very short, inheritance should ideally only be used when there exist a strict 'is-a' relationship. However, sometimes it may be clever to inherit when you have a 'is-almost-a' relationship... And sometimes this is a stupid move. This depends on the context/circumstances.
    Aggregation is normally considered a 'has-a' relationship, thereby differing clearly from inheritance. The old 'car' model says "a car is-a vehicle and has-some (at least) wheels."
    The wheels are aggregated to the car class, that itself is inherited from vehicle.
    However, this is just a good rule-of-thumb and there may be circumstantial reasons for not following these guidelines.

  • Masterdata - when to use it and when not to use it

    Hi!
    I have had some discussion with my colleagues about the use of masterdata on Oracle databases. Some of them tells me that I should use it if the data don't change often (ofcourse.....). This should ALWAYS be done they say. But I don't agree on this..
    Is it really necessary to make a lot of masterdata (and also views that has to be used) if the data is only to be loaded once a day, and the number of records is max 1000?
    I can't see the effect on this...
    Can someone give me a guideline for when to use masterdata, and when I don't need to use masterdata (if there are any article on this, please give it to me).
    Best Regards
    Helge

    Hi
    Answering this question usually requires a few books, so, I'm sorry, it's not really as simple as choosing between using a screwdriver vs. a hammer.
    But, very short, inheritance should ideally only be used when there exist a strict 'is-a' relationship. However, sometimes it may be clever to inherit when you have a 'is-almost-a' relationship... And sometimes this is a stupid move. This depends on the context/circumstances.
    Aggregation is normally considered a 'has-a' relationship, thereby differing clearly from inheritance. The old 'car' model says "a car is-a vehicle and has-some (at least) wheels."
    The wheels are aggregated to the car class, that itself is inherited from vehicle.
    However, this is just a good rule-of-thumb and there may be circumstantial reasons for not following these guidelines.

  • I get this error message when I open Firefox and when I go between tabs TypeError: PC_PREF_OBJ is undefined

    I get this message when I open Firefox and when I go between tabs.
    TypeError: PC_PREF_OBJ is undefined
    I have tried to re-install, but that doesn't help.

    If you close Firefox, then start Firefox in Safe Mode, does the problem still occur? For instructions on starting in Safe Mode, see [[Safe Mode]].
    Extensions can sometimes be the cause of problems. If the problem does not occur in [[Safe Mode]], then you can disable your extensions one-by-one until you find out which one is causing the problem.
    See [[Troubleshooting extensions and themes]]

  • What does it mean when you computer crashes and when you turn it back on it shows you a blank blue screen with a little folder and a question mark in the middle?

    What does it mean when you computer crashes and when you turn it back on it shows you a blank blue screen with a little folder and a question mark in the middle? It's a old imac from 1997.

    I don't have original discs that it came with.
    Then you still can use the second option with the keyboard combo I posted, called "resetting the PRAM."
    Also when you way hold the c key down do you mean turn computer off and turn back on holding the c key?
    Yes, or you can simply restart. As you don't have the CDs, this isn't on the plate any more.
    The internal backup battery is not expensive and, in most iMacs is user-replacable. If yours has a tray-loading optical drive like this one:
    it takes a major teardown to replace the internal battery. If this is the case, you'd be better off to leave the computer plugged in all the time; that eliminates the main reason for having a working battery.
    If it has a slot-loading optical drive like this one:
    things are much easier. The battery is visible through the RAM access door on the bottom of the computer case. The manual:
    http://manuals.info.apple.com/en_US/iMacG3_2000UserManual.PDF
    has sketches of how to access the RAM and therefore the backup battery. Unfortunately, the pdf on the manual goes up sideways on-screen and the RAM instructions are pretty deep into the manual. It's probably easier to scroll (for a while) to the section on adding RAM and print the applicable pages.
    When you work on the battery, some sort of non-conductive pliers or large tweezer or forceps help unless you have tiny fingers. Make sure to note the polarity of the old battery and install the new one in the same orientation.
    The battery itself is readily available. If price is no oblect, you can get it for a small rasom from Radio Shack Store ("Tandy" outside the US) as part number 23-026.
    Online, they are dirt-cheap even after adding shipping. I buy backup batteries form this outfit:
    3.6v Newer Technology Lithium 1/2 AA PRAM Computer Clock Battery

  • WHEN TO USE SYS_REFCURSOR AND WHEN NOT TO USE REFCURSOR

    SYS_REFCURSOR is a Weakly Defined Cursor
    DECLARE emp_refcur SYS_REFCURSOR;
    when this is so simple
    why this
    DECLARE TYPE emp_cur_type IS REF CURSOR RETURN emp%ROWTYPE; my_rec emp_cur_type; ?
    Can anyone explain in what situations we should prefer among these ..when both can give same result set .

    > WHEN TO USE SYS_REFCURSOR AND WHEN NOT TO USE REFCURSOR
    When the requirements define that one is better suited than the other.
    There are no hard and fast rules about when to use a specific tool. There are however basic concepts of what the purpose of the tool is, and what typical problems the tool can address.
    Ref cursors in PL/SQL.. usually not the best of ideas. Ref cursors are designed for client-server processing.
    1) The client makes a request for data/information.
    2) PL applies the back-end server logic and construct a SQL statement for the client.
    3) PL passes the SQL to the SQL engine where it is parsed and a SQL cursor created.
    4) PL passes a reference handle to SQL cursor back to the client
    5) The client can now fetch the rows output from the cursor.
    Advantages.
    - The client does not need to know SQL, db structures, business logic, etc
    - The PL code can be improved, modified, new business logic added, without even touching a single byte of client code
    So what are the advantages where the "client" in the above is another PL/SQL program? None really.
    A "real" client (an external one like Java, C#, Delphi, etc) can receive the ref cursor handle and dynamically at run-time determine the projection (output) of the cursor.
    PL code cannot (unless using the latest 11g features). In PL code, a ref cursor is actually implemented as a DBMS_SQL cursor. A DBMS_SQL cursor is to PL code what ref cursor is to Java/C#/etc.
    So whether you define a strongly typed or weakly typed ref cursor in PL/SQL code... typical response is "so what?" as ref cursors are not really intended for PL code. Not that there are exceptions - they do come in handy at times.. but as exceptions to the rule.
    So my response is "so what?" - it is more important to *correctly" chose what type of client cursor data type you want to use to interact with the back-end SQL cursor. Once that decision has been made (based on technical sound logic), then one can look at  (minor) issues such as weak vs. strong ref cursors.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Im 6 days late on my warrinty and I had no clue I was. And now when I call people and when they call me they cant hear me, but I can hear them.

    Im 6 days late on my warrinty and I had no clue I was. And now when I call people and when they call me they cant hear me, but I can hear them.

    Apple Store Genius makes all decisions regarding implementation of Warranty Coverage. Maybe you have AppleCare coverage and don't even know. If the Genius decides to cover under Warranty then it was worth taking to Apple. If Genius decides no Warranty, then replacement iPhone 4 is $149.

  • When to use interface and when Abstract Class?

    In a recent interview I was asked "When to use interface and when Abstract Class?" Explain with an example.
    Also in what situations a class should be made final(real time example)

    Interface is a pure contract with no implementation. Typically used to define a communication contract between two different sub-systems. Example EJB home interface. This also allows the design to change as long as the contract is met.
    Abstract class is when there exists a lot of common functionality already known and can be coded. However, a few unknowns exists (typically about data) for which abstract methods need to be defined and implemented by the sub class.
    Example: Consider a workflow engine. A great example for abstract class. The workflow process has lot of common code that is independent of the workflow type (vendor flow, contract flow, payment flow etc). However, certain decisions on the route to take will depend on value of data being submitted. So the base class will define a abstract Data getData() method and proceed assuming data will come. The implementing subclass will provide the actual logic for getting the data.
    Also see the "Template" design pattern.
    Note: To some extent the common code design drives the behavior of the abstract methods. So if the design changes then so "might" the behavior expected from the abstract methods.

  • My phone displays "Network search". Current time and date. When sim sim svtavlena and when there is no

    My phone displays "Network search". Current time and date. When sim sim svtavlena and when there is no.
    Мой айффон постоянно пишет поиск сети, даже если достать сим карту. Дата и время тоят правильно, сброс сети я пробовал, не помогает.

    Hi, AlexKot.  
    Thank you for visiting Apple Support Communities.
    It sounds like you are experiencing an issue with your iPhone searching for service.  If you have not resolved this issue, I would recommend trying the troubleshooting steps in the article below.
    If you see No Service or Searching in the status bar of your iPhone or iPad
    http://support.apple.com/kb/ts4429
    Cheers,
    Jason H.

  • How to create and save a file in flex web application ?

    Hi,
          I want to create and save a file form flex web application. Is it possible ?
    I have done some googling and found that its only possible through file referece, which needs some serverside implementation be called.
    Is it not possible with file reference to create and save file directly ?
    Can any one suggest how to over come this.
    Thanks in advance.

    Alex,
    code written with the Flex Builder 3 libraries will certainly run in Flash Player 10. However, what you need is not so much the capabilities of FP10 but the library functionalities of the Flex 4 package. And I think that Flex 4 code will only run in FP10 and not 9 (but haven't tested this as at work we have not yet been permitted to upgrade, so there is not a lot of point going for Flex 4!).
    Richard

  • WHEN CLICKING ON HELP AND SUPPORT, I CHOOSE A TOPIC AND THE NOTEPAD SHOWS UP WITH JUMBLED LETTER. Y?

    vkfkvmnjbnvjgbvkfnkmdnjvrkgjkvlddmck...THIS IS WHAT I SEE WHEN I CLICK HELP AND SUPPORT

    Hello, what browser and computer are you using?
    MrMatthew - HP Support Forums Moderator
    Click the Kudos star as a way to say "thank you" for helpful posts.
    Be sure to come back and click the 'Accept as Solution' button on the post that solved your issue - it may help someone else.

  • IMP: When will go HTTP and When we will go for SOAP????

    Hey Experts,
    Here i have requirement like that, I want to syn the date from SAP to external applications eg.., dot net So here which adapter i need to use here ,Either HTTP or SOAP??
    When we will go for Http and when we will go SOAP ? and which suits for dot net applications and which suits for java kind of applications ...
    Can you explain me what is the difference between this two adapter and which is the best one???
    Thanks in Advance
    Regards
    JS

    Sarathy,
    So here which adapter i need to use here ,Either HTTP or SOAP??
    It completely depends on the receiving system. I prefer web services, so if they can receive web services, then go for SOAP.
    When we will go for Http and when we will go SOAP ? and which suits for dot net applications and which suits for java kind of applications ...
    It completely depends on the scenario. In system integration, you first identify the scenario, and then choose the adapter which best suits the scenario.
    On .NET applications, it's easier to create / maintain web services.
    Can you explain me what is the difference between this two adapter and which is the best one???
    Please do a search on SDN / SAP Help, you will find plenty of blogs / forum postings on this topic.
    Regards,
    Neetesh

  • When to use inheritance and When to use Composition

    java support both inheratiance and composition .I also know "is a" and
    "has a realitionship" but there is always a problem with me to understanding whethere i have to use extends or having a object of a class has a member of othere class.
    and also "A pure OOP must support polimorphisim,inheretiance,encapluction,Abstraction and Composition" correct me if i am wrong
    thank you and have a nice day.

    Bruce Eckel, author of Thinking In Java, has this to say about composition vs. inheritance:
    When deciding between inheritance and composition, ask if you need to upcast to the base type. If not, prefer composition (member objects) to inheritance. This can eliminate the perceived need for multiple base types. If you inherit, users will think they are supposed to upcast.
    Choose composition first when creating new classes from existing classes. You should only used inheritance if it is required by your design. If you use inheritance where composition will work, your designs will become needlessly complicated.
    Bill Venners: Composition versus Inheritance
    Use inheritance (of implementation) only when the class satisfies the following criteria:
    1) "Is a special kind of," not "is a role played by a";
    2) Never needs to transmute to be an object in some other class;
    3) Extends rather than overrides or nullifies superclass;
    4) Does not subclass what is merely a utility class (useful functionality you'd like to reuse); and
    5) Within PD: expresses special kinds of roles, transactions, or things.
    -- from Java Design: Building Better Apps and Applets (2nd Edition), by Peter Coad and Mark Mayfield

  • System cache cleaning - when is it safe, and when is not?

    System cache cleaning is one of those so-called "maintenance" tasks that you may read about on the forums on Mac OS X guides that has mixed reviews, and typically is not necessary. In fact, when it is done at the wrong time, data corruption can lead to a situation where an erase and reinstall is necessary. I can't reproduce it easily, but I will say I've had it happen to at least three of my clients, so it is not as random as one would hope.
    You've probably heard of browser cache, and that's safe to clean anytime you like. One thing you'll notice about when you do, is that some websites will load slower, and others will load faster depending on your internet connection, and the frequency those websites get updated.
    System cache on the other hand which you'll find in ByHost and Cache folders in your Hard drive -> Library, System -> Library, Users -> yourname -> Library are a much more sensitive type of file. These will optimize the speed of frequently done operations on the operating system itself as well as specific applications which require those folders. When one of these files get corrupted, programs won't launch, will unexpectedly quit, will launch and close on their own, and in some cases Disk Utility won't function normally, or System Preference panels won't launch. To avoid these problems:
    1. Only do system cache cleaning after your data is completely backed up to your satisfaction, so that a system restore won't waste your time.
    2. Do it when no other applications are running, and there are no memory resident programs that may be affected by such cleaning in Apple menu -> System Preferences -> Accounts -> Login or Startup Items. Check the Process or Activity Viewer applications for applications you might have installed.
    3. Do not allow the process to be interrupted until it is finished. If any power outage happens, you may be left with a corrupted cache file.
    If you have a corrupted cache problem, attempt to isolate if it is happening just to one account by creating another account with Apple Menu -> System Preferences -> Accounts with admin access and see if it impacts that account as well. Do the following depending on whether or not it does affect that account:
    1. If isolated to one user, go back to the user and delete that user's Library folder's cache files relating to system and Launchservices, and log out and log back in the user twice. If it disappears as a problem once, and reappears, something you are running is persistentantly corrupting that user's cache folder, and you may have to move all the non-corrupt files to the new user.
    2. If it is not isolated to the user go to the System and Library folders under the hard drive and see if the Launchservices files and System cache files are removed if the issue disappears on reboot, and if it does, does it reappear after a second reboot. If it reappears after a second reboot, then you have the scary prospect of an erase and install of your system.
    Don't use automatic utilities to manage your system or user cache files. If anything only manually clean the cache when it is necessary and you have corrupted files. The cache is there to speed your system, and should otherwise not be touched.

    System cache cleaning is one of those so-called "maintenance" tasks that you may read about on the forums on Mac OS X guides that has mixed reviews, and typically is not necessary. In fact, when it is done at the wrong time, data corruption can lead to a situation where an erase and reinstall is necessary. I can't reproduce it easily, but I will say I've had it happen to at least three of my clients, so it is not as random as one would hope.
    You've probably heard of browser cache, and that's safe to clean anytime you like. One thing you'll notice about when you do, is that some websites will load slower, and others will load faster depending on your internet connection, and the frequency those websites get updated.
    System cache on the other hand which you'll find in ByHost and Cache folders in your Hard drive -> Library, System -> Library, Users -> yourname -> Library are a much more sensitive type of file. These will optimize the speed of frequently done operations on the operating system itself as well as specific applications which require those folders. When one of these files get corrupted, programs won't launch, will unexpectedly quit, will launch and close on their own, and in some cases Disk Utility won't function normally, or System Preference panels won't launch. To avoid these problems:
    1. Only do system cache cleaning after your data is completely backed up to your satisfaction, so that a system restore won't waste your time.
    2. Do it when no other applications are running, and there are no memory resident programs that may be affected by such cleaning in Apple menu -> System Preferences -> Accounts -> Login or Startup Items. Check the Process or Activity Viewer applications for applications you might have installed.
    3. Do not allow the process to be interrupted until it is finished. If any power outage happens, you may be left with a corrupted cache file.
    If you have a corrupted cache problem, attempt to isolate if it is happening just to one account by creating another account with Apple Menu -> System Preferences -> Accounts with admin access and see if it impacts that account as well. Do the following depending on whether or not it does affect that account:
    1. If isolated to one user, go back to the user and delete that user's Library folder's cache files relating to system and Launchservices, and log out and log back in the user twice. If it disappears as a problem once, and reappears, something you are running is persistentantly corrupting that user's cache folder, and you may have to move all the non-corrupt files to the new user.
    2. If it is not isolated to the user go to the System and Library folders under the hard drive and see if the Launchservices files and System cache files are removed if the issue disappears on reboot, and if it does, does it reappear after a second reboot. If it reappears after a second reboot, then you have the scary prospect of an erase and install of your system.
    Don't use automatic utilities to manage your system or user cache files. If anything only manually clean the cache when it is necessary and you have corrupted files. The cache is there to speed your system, and should otherwise not be touched.

Maybe you are looking for

  • How do I delete photos in the icloud and have them stay gone?

    How do I delete photos in the icloud and have them stay gone!

  • How to close Purchase Order and mark to deletion flag.??

    Hi, We need to close all Open POs(For archiving, some old data) through a report. Considering .....                    1. PO-GR-IR and              2. STO-Outboundelivery-PGI-IBD-PGR Checked few threads, though useful but still more information requi

  • Hwo to "track the mouse position"

    I m a java newbie, and need to write a small program to track the mouse position. basically, it opens a small window, and tell you the current mouse x, y coordinate. when mouse moves, hte x, y changes... by the way, how can i compile it to .exe file,

  • Accounting homework help

    Can't do Accounting Homework? Email me your accounting homework & accounting assignments & I will send you back the solutions. In addition to Accounting homework help & accounting assignments help, I also help in online accounting exams, online accou

  • Black box back on iCal Alarms

    I just installed a QuickTime update and the alarm clock from iCal's alarm window is now the black box. This has happened before with a QuickTime update and it was fixed by enabling Flash: System Preferences->QuickTime->Advanced->check enable Flash bo