JSP or Servlet?

ce_neha

ce_neha

@ce-neha-RCoDQE Oct 25, 2024
Hi ,

What should we used a servlet or a jsp?
In which type of applications we can find a servlet better to be used?







Please assist
Thanks!

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Mahesh Dahale

    Mahesh Dahale

    @mahesh-E2tZ3t Nov 26, 2009

    well, JSP may be great for serving up dynamic Web content and separating content from presentation
    JSP as a high-level abstraction of servlets
    servlets excellent for server-side processing
  • sookie

    sookie

    @sookie-T06sFW Nov 26, 2009

    ce_neha
    Hi ,

    What should we used a servlet or a jsp?
    In which type of applications we can find a servlet better to be used?
    Hi ce_neha,

    If your application is web based like having more focus on UI[User Interface] than Java programming - I will say go for JSPs but if your application is more dependent on Java rather than UI. Go for Servlets.

    And if you say, it is a mix of both then I would always recommend to make your UI in JSP only and do Java programming part in Servlets. It is considered as a bad practice if someone use "Java" in JSPs [scriptlets should be avoided] and "HTML" tags in "Java"

    Hope , I cleared your doubt. If still any doubts, feel free to ask. 😀
  • ce_neha

    ce_neha

    @ce-neha-RCoDQE Nov 27, 2009

    Hi ,

    I read somewhere that "JSP only deals with textual data, you will have to continue to use servlets when communicating with Java applets and applications."

    Please clarify the above statement,what applications are we referring to?
    or explain it with an example.




    Thanks.
  • sarveshgupta

    sarveshgupta

    @sarveshgupta-txtmu5 Nov 27, 2009

    Will clear your doubt give some time
  • sookie

    sookie

    @sookie-T06sFW Dec 5, 2009

    ce_neha
    Hi ,

    I read somewhere that "JSP only deals with textual data, you will have to continue to use servlets when communicating with Java applets and applications."

    Please clarify the above statement,what applications are we referring to?
    or explain it with an example.

    Thanks.
    Hi ce_neha,

    I think you read it here - #-Link-Snipped-#

    Well they mean to say that JSP just allow you to handle UI part. It will not allow a Java program(Here a servlet specifically) to communicate with other Java programs and its methods. So in that case you will have to go for Servlets only. And again as I said before also. All your Java code should be kept in servlets only. Use JSP only for UI purpose. Though it provides you few feature of incorporating Java code but avoid using it if you are making an application keeping dynamic thing in mind.

    Feel free to ask if still not clear. 😀

    Thanks !
  • callyD

    callyD

    @callyd-6BKFb3 Dec 6, 2009

    My understanding is JSP is for those who are not hardcore Java programmers. It offers ease of programming. Servlets are for hardcore java programmers. Servlets offer more flexibility to implement complex validation rules.
  • sookie

    sookie

    @sookie-T06sFW Dec 7, 2009

    callyD
    My understanding is JSP is for those who are not hardcore Java programmers. It offers ease of programming. Servlets are for hardcore java programmers. Servlets offer more flexibility to implement complex validation rules.
    Please change your understanding for making better web applications in future. I seriously hate people who add JAVA code in JSP pages. Just because of such understandings and coding practices only, security of web applications become a major issue at times.