What are the advantages of jsp over servlet?

this is a very weird question.... they're two components that should be used together.
a servlet is supposed to contain your business logic (your actual Java code), while a jsp file is only supposed to contain the GUI and calls to the servlets.

yes, you can put Java code directly in your .jsp file, but you should avoid that whenever possible.
yes, you can generate your html code in your servlet, but you should avoid that whenever possible.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.